diff --git a/build.gradle b/build.gradle index 2e610636..03eedb8b 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'fabric-loom' version "${loom_version}" + id "net.fabricmc.fabric-loom" version "${loom_version}" id 'org.moddedmc.wiki.toolkit' version '0.3.2' } @@ -10,24 +10,23 @@ base { } repositories { - maven { url 'https://maven.terraformersmc.com/' } // Required for Biolith + maven { url 'https://maven.terraformersmc.com' } // Required for Biolith } dependencies { minecraft "com.mojang:minecraft:${project.minecraft_version}" - mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" - modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" + implementation "net.fabricmc:fabric-loader:${project.loader_version}" - modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" + implementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}" - modApi include("com.terraformersmc:biolith-fabric:${biolith_version}") { + api include("com.terraformersmc:biolith-fabric:${biolith_version}") { exclude(group: "net.fabricmc.fabric-api") } compileOnly "com.google.code.findbugs:jsr305:3.0.2" // Version list: https://maven.su5ed.dev/#/releases/org/sinytra/wiki-exporter-fabric - modRuntimeOnly "org.sinytra:wiki-exporter-fabric:2.2.1+1.21.11" + //runtimeOnly "org.sinytra:wiki-exporter-fabric:2.2.1+1.21.11" } loom { @@ -76,14 +75,14 @@ processResources { tasks.withType(JavaCompile).configureEach { it.options.encoding = "UTF-8" - it.options.release = 21 + it.options.release = 25 } java { withSourcesJar() - sourceCompatibility = JavaVersion.VERSION_21 - targetCompatibility = JavaVersion.VERSION_21 + sourceCompatibility = JavaVersion.VERSION_25 + targetCompatibility = JavaVersion.VERSION_25 } jar { diff --git a/docs/customize/mob_variants.mdx b/docs/customize/mob_variants.mdx index 3be6fc3d..c2632ea3 100644 --- a/docs/customize/mob_variants.mdx +++ b/docs/customize/mob_variants.mdx @@ -13,7 +13,7 @@ Duck variants are defined in the `data//promenade/duck_variant` folde * [JSON Object] * [String] `asset_id` - The resource location of the texture to use for the adult duck. - * [String] `baby_texture` - The resource location of the texture to use for the duckling. (defaults to `promenade:entity/duck/duckling`) + * [String] `baby_asset_id` - The resource location of the texture to use for the duckling. (defaults to `promenade:entity/duck/duckling`) * [String] `spawn_conditions` - The spawn conditions of this variant, see [spawn conditions](https://minecraft.wiki/w/Mob_variant_definitions#Spawn_condition). ### Capybara @@ -21,10 +21,14 @@ Duck variants are defined in the `data//promenade/duck_variant` folde Capybara variants are defined in the `data//promenade/capybara_variant` folder. * [JSON Object] - * [String] `small_eyes_texture` - The resource location of the texture to use for adult capybaras. - * [String] `large_eyes_texture` - The resource location of the texture to use for baby capybaras and farting adult capybaras. - * [String] `closed_eyes_texture` - The resource location of the texture to use for sleeping capybaras. - * [String] `spawn_conditions` - The spawn conditions of this variant, see [spawn conditions](https://minecraft.wiki/w/Mob_variant_definitions#Spawn_condition). + * `assets` - Assets used for the adult. + * [String] `normal` - The resource location of the texture to use for normal adult capybaras. + * [String] `surprised` - The resource location of the texture to use for surprised adult capybaras. (eg. when farting) + * [String] `sleeping` - The resource location of the texture to use sleeping adult capybaras. + * `baby_assets` - Assets used for the baby. + * [String] `normal` - The resource location of the texture to use for normal baby capybaras. + * [String] `surprised` - The resource location of the texture to use for surprised baby capybaras. (eg. when farting) + * [String] `sleeping` - The resource location of the texture to use sleeping baby capybaras. ### Sunken diff --git a/gradle.properties b/gradle.properties index 5e69e2f9..2929c527 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,13 +9,12 @@ loader_name=Fabric loader_icon=https://fabricmc.net/assets/logo.png # check these on https://fabricmc.net/versions.html -minecraft_version=1.21.11 -yarn_mappings=1.21.11+build.3 -loader_version=0.18.3 -loom_version=1.14-SNAPSHOT +minecraft_version=26.1 +loader_version=0.18.6 +loom_version=1.15-SNAPSHOT # Fabric API -fabric_version=0.140.2+1.21.11 +fabric_api_version=0.145.1+26.1 # https://maven.terraformersmc.com/releases/com/terraformersmc/biolith-fabric -biolith_version=3.5.0-beta.3 \ No newline at end of file +biolith_version=3.6.0-alpha.4 \ No newline at end of file diff --git a/gradlew b/gradlew index f5feea6d..3a163de7 100644 --- a/gradlew +++ b/gradlew @@ -1,7 +1,7 @@ -#!/bin/sh +#!/usr/bin/env sh # -# Copyright © 2015-2021 the original authors. +# Copyright 2015 the original author or authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,104 +15,69 @@ # See the License for the specific language governing permissions and # limitations under the License. # -# SPDX-License-Identifier: Apache-2.0 -# ############################################################################## -# -# 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/HEAD/platforms/jvm/plugins-application/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 +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null -# This is normally unused -# shellcheck disable=SC2034 -APP_BASE_NAME=${0##*/} -# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s -' "$PWD" ) || exit +APP_NAME="Gradle" +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"' # 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 @@ -122,9 +87,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD=$JAVA_HOME/jre/sh/java + JAVACMD="$JAVA_HOME/jre/sh/java" else - JAVACMD=$JAVA_HOME/bin/java + JAVACMD="$JAVA_HOME/bin/java" fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -133,120 +98,88 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD=java - if ! command -v java >/dev/null 2>&1 - then - die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + 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 location of your Java installation." - fi fi # Increase the maximum file descriptors if we can. -if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then - case $MAX_FD in #( - max*) - # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC2039,SC3045 - MAX_FD=$( ulimit -H -n ) || - warn "Could not query maximum file descriptor limit" - esac - case $MAX_FD in #( - '' | soft) :;; #( - *) - # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC2039,SC3045 - 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 Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi # For Cygwin or MSYS, switch paths to Windows format before running java -if "$cygwin" || "$msys" ; then - APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) - - JAVACMD=$( cygpath --unix "$JAVACMD" ) - +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi # Now convert the arguments - kludge to limit ourselves to /bin/sh - 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=`expr $i + 1` done + case $i in + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac fi +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=`save "$@"` -# 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"' - -# Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, -# and any embedded shellness will be escaped. -# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be -# treated as '${Hostname}' itself on the command line. - -set -- \ - "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ - "$@" - -# Stop when "xargs" is not available. -if ! command -v xargs >/dev/null 2>&1 -then - die "xargs is not available" -fi - -# 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' ' ' - )" '"$@"' +# 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" -exec "$JAVACMD" "$@" +exec "$JAVACMD" "$@" \ No newline at end of file diff --git a/gradlew.bat b/gradlew.bat index 9d21a218..477c8966 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -13,10 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem -@rem SPDX-License-Identifier: Apache-2.0 -@rem -@if "%DEBUG%"=="" @echo off +@if "%DEBUG%" == "" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -27,8 +25,7 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%"=="" set DIRNAME=. -@rem This is normally unused +if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @@ -43,13 +40,13 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if %ERRORLEVEL% equ 0 goto execute +if "%ERRORLEVEL%" == "0" goto execute -echo. 1>&2 -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 -echo. 1>&2 -echo Please set the JAVA_HOME variable in your environment to match the 1>&2 -echo location of your Java installation. 1>&2 +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. goto fail @@ -59,11 +56,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto execute -echo. 1>&2 -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 -echo. 1>&2 -echo Please set the JAVA_HOME variable in your environment to match the 1>&2 -echo location of your Java installation. 1>&2 +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. goto fail @@ -78,17 +75,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar :end @rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd +if "%ERRORLEVEL%"=="0" goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 :mainEnd if "%OS%"=="Windows_NT" endlocal -:omega +:omega \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index 75c4d726..d678c772 100644 --- a/settings.gradle +++ b/settings.gradle @@ -4,7 +4,6 @@ pluginManagement { name = 'Fabric' url = 'https://maven.fabricmc.net/' } - mavenCentral() gradlePluginPortal() } } \ No newline at end of file diff --git a/src/client/java/fr/hugman/promenade/client/PromenadeClient.java b/src/client/java/fr/hugman/promenade/client/PromenadeClient.java index 7b082be4..857d9f83 100644 --- a/src/client/java/fr/hugman/promenade/client/PromenadeClient.java +++ b/src/client/java/fr/hugman/promenade/client/PromenadeClient.java @@ -1,8 +1,7 @@ package fr.hugman.promenade.client; -import fr.hugman.promenade.client.color.PromenadeBlockColors; -import fr.hugman.promenade.client.particle.PromenadeParticleFactories; -import fr.hugman.promenade.client.render.block.PromenadeBlockRenderLayers; +import fr.hugman.promenade.client.color.block.PromenadeBlockColors; +import fr.hugman.promenade.client.particle.PromenadeParticles; import fr.hugman.promenade.client.render.entity.PromenadeEntityRenderers; import fr.hugman.promenade.client.render.entity.model.PromenadeEntityModelLayers; import net.fabricmc.api.ClientModInitializer; @@ -11,9 +10,8 @@ public class PromenadeClient implements ClientModInitializer { @Override public void onInitializeClient() { PromenadeEntityModelLayers.register(); - PromenadeBlockRenderLayers.register(); PromenadeBlockColors.register(); PromenadeEntityRenderers.register(); - PromenadeParticleFactories.register(); + PromenadeParticles.register(); } } \ No newline at end of file diff --git a/src/client/java/fr/hugman/promenade/client/color/PromenadeBlockColors.java b/src/client/java/fr/hugman/promenade/client/color/PromenadeBlockColors.java deleted file mode 100644 index be6ba9ea..00000000 --- a/src/client/java/fr/hugman/promenade/client/color/PromenadeBlockColors.java +++ /dev/null @@ -1,24 +0,0 @@ -package fr.hugman.promenade.client.color; - -import fr.hugman.promenade.block.PromenadeBlocks; -import fr.hugman.promenade.world.biome.PromenadeFoliageColors; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry; -import net.minecraft.client.color.world.BiomeColors; -import net.minecraft.world.biome.FoliageColors; - -@Environment(EnvType.CLIENT) -public final class PromenadeBlockColors { - public static void register() { - ColorProviderRegistry.BLOCK.register((state, world, pos, tintIndex) -> PromenadeFoliageColors.PALM, PromenadeBlocks.PALM_LEAVES, PromenadeBlocks.SNOWY_PALM_LEAVES, PromenadeBlocks.PALM_HANGING_LEAVES, PromenadeBlocks.PALM_LEAF_PILE); - ColorProviderRegistry.BLOCK.register((state, world, pos, tintIndex) -> pos != null && world != null ? BiomeColors.getFoliageColor(world, pos) : FoliageColors.DEFAULT, - PromenadeBlocks.SNOWY_OAK_LEAVES, PromenadeBlocks.SNOWY_JUNGLE_LEAVES, PromenadeBlocks.SNOWY_ACACIA_LEAVES, PromenadeBlocks.SNOWY_DARK_OAK_LEAVES, PromenadeBlocks.SNOWY_MANGROVE_LEAVES, - PromenadeBlocks.OAK_LEAF_PILE, PromenadeBlocks.JUNGLE_LEAF_PILE, PromenadeBlocks.ACACIA_LEAF_PILE, PromenadeBlocks.DARK_OAK_LEAF_PILE, PromenadeBlocks.MANGROVE_LEAF_PILE, - PromenadeBlocks.SAP_MAPLE_LEAVES, PromenadeBlocks.SNOWY_SAP_MAPLE_LEAVES, PromenadeBlocks.SAP_MAPLE_LEAF_PILE, PromenadeBlocks.FALLEN_SAP_MAPLE_LEAVES, - PromenadeBlocks.SNOWY_OAK_LEAVES, PromenadeBlocks.SNOWY_JUNGLE_LEAVES - ); - ColorProviderRegistry.BLOCK.register((state, world, pos, tintIndex) -> FoliageColors.SPRUCE, PromenadeBlocks.SPRUCE_LEAF_PILE, PromenadeBlocks.SNOWY_SPRUCE_LEAVES); - ColorProviderRegistry.BLOCK.register((state, world, pos, tintIndex) -> FoliageColors.BIRCH, PromenadeBlocks.BIRCH_LEAF_PILE, PromenadeBlocks.SNOWY_BIRCH_LEAVES); - } -} diff --git a/src/client/java/fr/hugman/promenade/client/color/block/PromenadeBlockColors.java b/src/client/java/fr/hugman/promenade/client/color/block/PromenadeBlockColors.java new file mode 100644 index 00000000..84176df0 --- /dev/null +++ b/src/client/java/fr/hugman/promenade/client/color/block/PromenadeBlockColors.java @@ -0,0 +1,23 @@ +package fr.hugman.promenade.client.color.block; + +import fr.hugman.promenade.block.PromenadeBlocks; +import fr.hugman.promenade.world.biome.PromenadeFoliageColors; +import net.fabricmc.fabric.api.client.rendering.v1.BlockColorRegistry; +import net.minecraft.client.color.block.BlockTintSources; +import net.minecraft.world.level.FoliageColor; + +import java.util.List; + +public final class PromenadeBlockColors { + public static void register() { + BlockColorRegistry.register(List.of(BlockTintSources.foliage()), + PromenadeBlocks.SNOWY_OAK_LEAVES, PromenadeBlocks.SNOWY_JUNGLE_LEAVES, PromenadeBlocks.SNOWY_ACACIA_LEAVES, PromenadeBlocks.SNOWY_DARK_OAK_LEAVES, PromenadeBlocks.SNOWY_MANGROVE_LEAVES, + PromenadeBlocks.OAK_LEAF_PILE, PromenadeBlocks.JUNGLE_LEAF_PILE, PromenadeBlocks.ACACIA_LEAF_PILE, PromenadeBlocks.DARK_OAK_LEAF_PILE, PromenadeBlocks.MANGROVE_LEAF_PILE, + PromenadeBlocks.SAP_MAPLE_LEAVES, PromenadeBlocks.SNOWY_SAP_MAPLE_LEAVES, PromenadeBlocks.SAP_MAPLE_LEAF_PILE, PromenadeBlocks.FALLEN_SAP_MAPLE_LEAVES, + PromenadeBlocks.SNOWY_OAK_LEAVES, PromenadeBlocks.SNOWY_JUNGLE_LEAVES + ); + BlockColorRegistry.register(List.of(BlockTintSources.constant(FoliageColor.FOLIAGE_EVERGREEN)), PromenadeBlocks.SPRUCE_LEAF_PILE, PromenadeBlocks.SNOWY_SPRUCE_LEAVES); + BlockColorRegistry.register(List.of(BlockTintSources.constant(FoliageColor.FOLIAGE_BIRCH)), PromenadeBlocks.BIRCH_LEAF_PILE, PromenadeBlocks.SNOWY_BIRCH_LEAVES); + BlockColorRegistry.register(List.of(BlockTintSources.constant(PromenadeFoliageColors.PALM)), PromenadeBlocks.PALM_LEAVES, PromenadeBlocks.SNOWY_PALM_LEAVES, PromenadeBlocks.PALM_HANGING_LEAVES, PromenadeBlocks.PALM_LEAF_PILE); + } +} diff --git a/src/client/java/fr/hugman/promenade/client/particle/PromenadeLeavesParticle.java b/src/client/java/fr/hugman/promenade/client/particle/PromenadeLeavesParticle.java new file mode 100644 index 00000000..84ba3d57 --- /dev/null +++ b/src/client/java/fr/hugman/promenade/client/particle/PromenadeLeavesParticle.java @@ -0,0 +1,25 @@ +package fr.hugman.promenade.client.particle; + +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.client.particle.FallingLeavesParticle; +import net.minecraft.client.particle.Particle; +import net.minecraft.client.particle.ParticleProvider; +import net.minecraft.client.particle.SpriteSet; +import net.minecraft.core.particles.SimpleParticleType; +import net.minecraft.util.RandomSource; +import org.jetbrains.annotations.Nullable; + +public class PromenadeLeavesParticle { + public static class MapleLeavesProvider implements ParticleProvider { + private final SpriteSet sprites; + + public MapleLeavesProvider(SpriteSet sprites) { + this.sprites = sprites; + } + + @Override + public @Nullable Particle createParticle(SimpleParticleType options, ClientLevel level, double x, double y, double z, double velocityX, double velocityY, double velocityZ, RandomSource random) { + return new FallingLeavesParticle(level, x, y, z, this.sprites.get(random), 0.07F, 5.0F, true, false, 1.5F, 0.021F); + } + } +} diff --git a/src/client/java/fr/hugman/promenade/client/particle/PromenadeLeavesParticleFactories.java b/src/client/java/fr/hugman/promenade/client/particle/PromenadeLeavesParticleFactories.java deleted file mode 100644 index 885a281b..00000000 --- a/src/client/java/fr/hugman/promenade/client/particle/PromenadeLeavesParticleFactories.java +++ /dev/null @@ -1,28 +0,0 @@ -package fr.hugman.promenade.client.particle; - -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -import net.minecraft.client.particle.LeavesParticle; -import net.minecraft.client.particle.Particle; -import net.minecraft.client.particle.ParticleFactory; -import net.minecraft.client.particle.SpriteProvider; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.particle.SimpleParticleType; -import net.minecraft.util.math.random.Random; -import org.jetbrains.annotations.Nullable; - -public class PromenadeLeavesParticleFactories { - @Environment(EnvType.CLIENT) - public static class MapleLeavesFactory implements ParticleFactory { - private final SpriteProvider spriteProvider; - - public MapleLeavesFactory(SpriteProvider spriteProvider) { - this.spriteProvider = spriteProvider; - } - - @Override - public @Nullable Particle createParticle(SimpleParticleType parameters, ClientWorld world, double x, double y, double z, double velocityX, double velocityY, double velocityZ, Random random) { - return new LeavesParticle(world, x, y, z, this.spriteProvider.getSprite(random), 0.07F, 5.0F, true, false, 1.5F, 0.021F); - } - } -} diff --git a/src/client/java/fr/hugman/promenade/client/particle/PromenadeParticleFactories.java b/src/client/java/fr/hugman/promenade/client/particle/PromenadeParticleFactories.java deleted file mode 100644 index b85c895b..00000000 --- a/src/client/java/fr/hugman/promenade/client/particle/PromenadeParticleFactories.java +++ /dev/null @@ -1,21 +0,0 @@ -package fr.hugman.promenade.client.particle; - -import fr.hugman.promenade.particle.PromenadeParticleTypes; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry; -import net.minecraft.client.particle.LeavesParticle; - -@Environment(EnvType.CLIENT) -public class PromenadeParticleFactories { - public static void register() { - var instance = ParticleFactoryRegistry.getInstance(); - - instance.register(PromenadeParticleTypes.BLUSH_SAKURA_BLOSSOM, LeavesParticle.CherryLeavesFactory::new); - instance.register(PromenadeParticleTypes.COTTON_SAKURA_BLOSSOM, LeavesParticle.CherryLeavesFactory::new); - - instance.register(PromenadeParticleTypes.MIKADO_MAPLE_LEAF, PromenadeLeavesParticleFactories.MapleLeavesFactory::new); - instance.register(PromenadeParticleTypes.FULVOUS_MAPLE_LEAF, PromenadeLeavesParticleFactories.MapleLeavesFactory::new); - instance.register(PromenadeParticleTypes.VERMILION_MAPLE_LEAF, PromenadeLeavesParticleFactories.MapleLeavesFactory::new); - } -} diff --git a/src/client/java/fr/hugman/promenade/client/particle/PromenadeParticles.java b/src/client/java/fr/hugman/promenade/client/particle/PromenadeParticles.java new file mode 100644 index 00000000..ccabd3fc --- /dev/null +++ b/src/client/java/fr/hugman/promenade/client/particle/PromenadeParticles.java @@ -0,0 +1,18 @@ +package fr.hugman.promenade.client.particle; + +import fr.hugman.promenade.particle.PromenadeParticleTypes; +import net.fabricmc.fabric.api.client.particle.v1.ParticleProviderRegistry; +import net.minecraft.client.particle.FallingLeavesParticle; + +public class PromenadeParticles { + public static void register() { + var instance = ParticleProviderRegistry.getInstance(); + + instance.register(PromenadeParticleTypes.BLUSH_SAKURA_BLOSSOM, FallingLeavesParticle.CherryProvider::new); + instance.register(PromenadeParticleTypes.COTTON_SAKURA_BLOSSOM, FallingLeavesParticle.CherryProvider::new); + + instance.register(PromenadeParticleTypes.MIKADO_MAPLE_LEAF, PromenadeLeavesParticle.MapleLeavesProvider::new); + instance.register(PromenadeParticleTypes.FULVOUS_MAPLE_LEAF, PromenadeLeavesParticle.MapleLeavesProvider::new); + instance.register(PromenadeParticleTypes.VERMILION_MAPLE_LEAF, PromenadeLeavesParticle.MapleLeavesProvider::new); + } +} diff --git a/src/client/java/fr/hugman/promenade/client/render/block/PromenadeBlockRenderLayers.java b/src/client/java/fr/hugman/promenade/client/render/block/PromenadeBlockRenderLayers.java deleted file mode 100644 index 182fd2e7..00000000 --- a/src/client/java/fr/hugman/promenade/client/render/block/PromenadeBlockRenderLayers.java +++ /dev/null @@ -1,109 +0,0 @@ -package fr.hugman.promenade.client.render.block; - -import fr.hugman.promenade.block.PromenadeBlocks; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -import net.fabricmc.fabric.api.client.rendering.v1.BlockRenderLayerMap; -import net.minecraft.client.render.BlockRenderLayer; - -@Environment(EnvType.CLIENT) -public final class PromenadeBlockRenderLayers { - public static void register() { - - BlockRenderLayerMap.putBlocks(BlockRenderLayer.CUTOUT, - PromenadeBlocks.OAK_LEAF_PILE, - PromenadeBlocks.SPRUCE_LEAF_PILE, - PromenadeBlocks.BIRCH_LEAF_PILE, - PromenadeBlocks.JUNGLE_LEAF_PILE, - PromenadeBlocks.ACACIA_LEAF_PILE, - PromenadeBlocks.CHERRY_LEAF_PILE, - PromenadeBlocks.DARK_OAK_LEAF_PILE, - PromenadeBlocks.MANGROVE_LEAF_PILE, - PromenadeBlocks.PALE_OAK_LEAF_PILE, - PromenadeBlocks.AZALEA_LEAF_PILE, - PromenadeBlocks.FLOWERING_AZALEA_LEAF_PILE, - PromenadeBlocks.DANDELION_PILE, - PromenadeBlocks.POPPY_PILE, - PromenadeBlocks.BLUE_ORCHID_PILE, - PromenadeBlocks.ALLIUM_PILE, - PromenadeBlocks.AZURE_BLUET_PILE, - PromenadeBlocks.RED_TULIP_PILE, - PromenadeBlocks.ORANGE_TULIP_PILE, - PromenadeBlocks.WHITE_TULIP_PILE, - PromenadeBlocks.PINK_TULIP_PILE, - PromenadeBlocks.OXEYE_DAISY_PILE, - PromenadeBlocks.CORNFLOWER_PILE, - PromenadeBlocks.LILY_OF_THE_VALLEY_PILE, - PromenadeBlocks.WITHER_ROSE_PILE, - PromenadeBlocks.SNOWY_OAK_LEAVES, - PromenadeBlocks.SNOWY_SPRUCE_LEAVES, - PromenadeBlocks.SNOWY_BIRCH_LEAVES, - PromenadeBlocks.SNOWY_JUNGLE_LEAVES, - PromenadeBlocks.SNOWY_ACACIA_LEAVES, - PromenadeBlocks.SNOWY_CHERRY_LEAVES, - PromenadeBlocks.SNOWY_DARK_OAK_LEAVES, - PromenadeBlocks.SNOWY_PALE_OAK_LEAVES, - PromenadeBlocks.SNOWY_MANGROVE_LEAVES, - PromenadeBlocks.SNOWY_AZALEA_LEAVES, - PromenadeBlocks.SNOWY_FLOWERING_AZALEA_LEAVES, - PromenadeBlocks.BLUSH_SAKURA_BLOSSOMS, - PromenadeBlocks.SNOWY_BLUSH_SAKURA_BLOSSOMS, - PromenadeBlocks.BLUSH_SAKURA_BLOSSOM_PILE, - PromenadeBlocks.BLUSH_SAKURA_SAPLING, - PromenadeBlocks.POTTED_BLUSH_SAKURA_SAPLING, - PromenadeBlocks.COTTON_SAKURA_BLOSSOMS, - PromenadeBlocks.SNOWY_COTTON_SAKURA_BLOSSOMS, - PromenadeBlocks.COTTON_SAKURA_BLOSSOM_PILE, - PromenadeBlocks.COTTON_SAKURA_SAPLING, - PromenadeBlocks.POTTED_COTTON_SAKURA_SAPLING, - PromenadeBlocks.SAP_MAPLE_SAPLING, - PromenadeBlocks.POTTED_SAP_MAPLE_SAPLING, - PromenadeBlocks.SAP_MAPLE_LEAVES, - PromenadeBlocks.SNOWY_SAP_MAPLE_LEAVES, - PromenadeBlocks.SAP_MAPLE_LEAF_PILE, - PromenadeBlocks.FALLEN_SAP_MAPLE_LEAVES, - PromenadeBlocks.VERMILION_MAPLE_SAPLING, - PromenadeBlocks.POTTED_VERMILION_MAPLE_SAPLING, - PromenadeBlocks.VERMILION_MAPLE_LEAVES, - PromenadeBlocks.SNOWY_VERMILION_MAPLE_LEAVES, - PromenadeBlocks.VERMILION_MAPLE_LEAF_PILE, - PromenadeBlocks.FALLEN_VERMILION_MAPLE_LEAVES, - PromenadeBlocks.FULVOUS_MAPLE_SAPLING, - PromenadeBlocks.POTTED_FULVOUS_MAPLE_SAPLING, - PromenadeBlocks.FULVOUS_MAPLE_LEAVES, - PromenadeBlocks.SNOWY_FULVOUS_MAPLE_LEAVES, - PromenadeBlocks.FULVOUS_MAPLE_LEAF_PILE, - PromenadeBlocks.FALLEN_FULVOUS_MAPLE_LEAVES, - PromenadeBlocks.MIKADO_MAPLE_SAPLING, - PromenadeBlocks.POTTED_MIKADO_MAPLE_SAPLING, - PromenadeBlocks.MIKADO_MAPLE_LEAVES, - PromenadeBlocks.SNOWY_MIKADO_MAPLE_LEAVES, - PromenadeBlocks.MIKADO_MAPLE_LEAF_PILE, - PromenadeBlocks.FALLEN_MIKADO_MAPLE_LEAVES, - PromenadeBlocks.PALM_LEAVES, - PromenadeBlocks.SNOWY_PALM_LEAVES, - PromenadeBlocks.POTTED_DARK_AMARANTH_ROOTS, - PromenadeBlocks.DARK_AMARANTH_FUNGUS, - PromenadeBlocks.POTTED_DARK_AMARANTH_FUNGUS - ); - - BlockRenderLayerMap.putBlocks(BlockRenderLayer.CUTOUT, - PromenadeBlocks.SAKURA_DOOR, - PromenadeBlocks.SAKURA_TRAPDOOR, - PromenadeBlocks.MAPLE_DOOR, - PromenadeBlocks.MAPLE_TRAPDOOR, - PromenadeBlocks.PALM_DOOR, - PromenadeBlocks.PALM_TRAPDOOR, - PromenadeBlocks.PALM_SAPLING, - PromenadeBlocks.POTTED_PALM_SAPLING, - PromenadeBlocks.PALM_HANGING_LEAVES, - PromenadeBlocks.PALM_LEAF_PILE, - PromenadeBlocks.DARK_AMARANTH_DOOR, - PromenadeBlocks.DARK_AMARANTH_TRAPDOOR, - PromenadeBlocks.DARK_AMARANTH_ROOTS, - PromenadeBlocks.COILED_VINES, - PromenadeBlocks.COILED_VINES_PLANT, - PromenadeBlocks.BLUEBERRY_BUSH - ); - } -} diff --git a/src/client/java/fr/hugman/promenade/client/render/entity/CapybaraEntityRenderer.java b/src/client/java/fr/hugman/promenade/client/render/entity/CapybaraEntityRenderer.java index ab2c33a9..5aafa240 100644 --- a/src/client/java/fr/hugman/promenade/client/render/entity/CapybaraEntityRenderer.java +++ b/src/client/java/fr/hugman/promenade/client/render/entity/CapybaraEntityRenderer.java @@ -1,55 +1,57 @@ package fr.hugman.promenade.client.render.entity; -import fr.hugman.promenade.client.render.entity.model.CapybaraEntityModel; +import fr.hugman.promenade.client.render.entity.model.capybara.BabyCapybaraModel; +import fr.hugman.promenade.client.render.entity.model.capybara.AdultCapybaraModel; import fr.hugman.promenade.client.render.entity.model.PromenadeEntityModelLayers; -import fr.hugman.promenade.client.render.entity.state.CapybaraEntityRenderState; -import fr.hugman.promenade.entity.CapybaraEntity; +import fr.hugman.promenade.client.render.entity.model.capybara.CapybaraModel; +import fr.hugman.promenade.client.render.entity.state.CapybaraRenderState; +import fr.hugman.promenade.entity.Capybara; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.client.render.entity.AgeableMobEntityRenderer; -import net.minecraft.client.render.entity.EntityRendererFactory; -import net.minecraft.client.texture.MissingSprite; -import net.minecraft.util.Identifier; +import net.minecraft.client.renderer.entity.AgeableMobRenderer; +import net.minecraft.client.renderer.entity.EntityRendererProvider; +import net.minecraft.client.renderer.texture.MissingTextureAtlasSprite; +import net.minecraft.resources.Identifier; -@Environment(EnvType.CLIENT) -public class CapybaraEntityRenderer extends AgeableMobEntityRenderer { - public CapybaraEntityRenderer(EntityRendererFactory.Context context) { +public class CapybaraEntityRenderer extends AgeableMobRenderer { + public CapybaraEntityRenderer(EntityRendererProvider.Context context) { super( context, - new CapybaraEntityModel(context.getPart(PromenadeEntityModelLayers.CAPYBARA)), - new CapybaraEntityModel(context.getPart(PromenadeEntityModelLayers.CAPYBARA_BABY)), + new AdultCapybaraModel(context.bakeLayer(PromenadeEntityModelLayers.CAPYBARA)), + new BabyCapybaraModel(context.bakeLayer(PromenadeEntityModelLayers.CAPYBARA_BABY)), 0.5f ); } @Override - public CapybaraEntityRenderState createRenderState() { - return new CapybaraEntityRenderState(); + public CapybaraRenderState createRenderState() { + return new CapybaraRenderState(); } @Override - public Identifier getTexture(CapybaraEntityRenderState state) { + public Identifier getTextureLocation(CapybaraRenderState state) { if (state.variant == null) { - return MissingSprite.getMissingSpriteId(); + return MissingTextureAtlasSprite.getLocation(); } - if (state.closedEyes) { - return state.variant.closedEyesTexture().texturePath(); + var textureInfo = state.isBaby ? state.variant.babyInfo() : state.variant.adultInfo(); + if (state.sleeping) { + return textureInfo.sleeping().texturePath(); } - return state.largeEyes ? state.variant.largeEyesTexture().texturePath() : state.variant.smallEyesTexture().texturePath(); + return state.surprised ? textureInfo.surprised().texturePath() : textureInfo.normal().texturePath(); } @Override - public void updateRenderState(E capybara, CapybaraEntityRenderState state, float f) { - super.updateRenderState(capybara, state, f); - state.earWiggleAnimState.copyFrom(capybara.earWiggleAnimState); - state.fallToSleepAnimState.copyFrom(capybara.fallToSleepAnimState); - state.sleepingAnimState.copyFrom(capybara.sleepingAnimState); - state.wakeUpAnimState.copyFrom(capybara.wakeUpAnimState); - state.fartAnimState.copyFrom(capybara.fartAnimState); + public void extractRenderState(E capybara, CapybaraRenderState state, float f) { + super.extractRenderState(capybara, state, f); + state.earWiggleAnimationState.copyFrom(capybara.earWiggleAnimState); + state.fallToSleepAnimationState.copyFrom(capybara.fallToSleepAnimState); + state.sleepingAnimationState.copyFrom(capybara.sleepingAnimState); + state.wakeUpAnimationState.copyFrom(capybara.wakeUpAnimState); + state.fartAnimationState.copyFrom(capybara.fartAnimState); state.variant = capybara.getVariant().value(); - state.closedEyes = capybara.hasClosedEyes(); - state.largeEyes = capybara.hasLargeEyes(); + state.sleeping = capybara.isVisuallySleeping(); + state.surprised = capybara.isSurprised(); state.earWiggleSpeed = capybara.getEarWiggleSpeed(); state.canAngleHead = capybara.canAngleHead(); } diff --git a/src/client/java/fr/hugman/promenade/client/render/entity/CreeperOverlayRenderer.java b/src/client/java/fr/hugman/promenade/client/render/entity/CreeperOverlayRenderer.java index 11fd8fb4..46a7fdbe 100644 --- a/src/client/java/fr/hugman/promenade/client/render/entity/CreeperOverlayRenderer.java +++ b/src/client/java/fr/hugman/promenade/client/render/entity/CreeperOverlayRenderer.java @@ -1,32 +1,31 @@ package fr.hugman.promenade.client.render.entity; +import com.mojang.blaze3d.vertex.PoseStack; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.client.render.command.OrderedRenderCommandQueue; -import net.minecraft.client.render.entity.feature.FeatureRenderer; -import net.minecraft.client.render.entity.feature.FeatureRendererContext; -import net.minecraft.client.render.entity.model.CreeperEntityModel; -import net.minecraft.client.render.entity.model.EntityModel; -import net.minecraft.client.render.entity.model.EntityModelLayer; -import net.minecraft.client.render.entity.model.LoadedEntityModels; -import net.minecraft.client.render.entity.state.CreeperEntityRenderState; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.util.Identifier; +import net.minecraft.client.model.EntityModel; +import net.minecraft.client.model.geom.EntityModelSet; +import net.minecraft.client.model.geom.ModelLayerLocation; +import net.minecraft.client.model.monster.creeper.CreeperModel; +import net.minecraft.client.renderer.SubmitNodeCollector; +import net.minecraft.client.renderer.entity.RenderLayerParent; +import net.minecraft.client.renderer.entity.layers.RenderLayer; +import net.minecraft.client.renderer.entity.state.CreeperRenderState; +import net.minecraft.resources.Identifier; -@Environment(EnvType.CLIENT) -public class CreeperOverlayRenderer> extends FeatureRenderer { - private final CreeperEntityModel model; +public class CreeperOverlayRenderer> extends RenderLayer { + private final CreeperModel model; private final Identifier texture; - public CreeperOverlayRenderer(FeatureRendererContext context, LoadedEntityModels loader, EntityModelLayer layer, Identifier texture) { + public CreeperOverlayRenderer(RenderLayerParent context, EntityModelSet loader, ModelLayerLocation layer, Identifier texture) { super(context); - this.model = new CreeperEntityModel(loader.getModelPart(layer)); + this.model = new CreeperModel(loader.bakeLayer(layer)); this.texture = texture; } @Override - public void render(MatrixStack matrices, OrderedRenderCommandQueue queue, int light, S state, float limbAngle, float limbDistance) { - render(this.model, this.texture, matrices, queue, light, state, -1, 1); + public void submit(PoseStack poseStack, SubmitNodeCollector submitNodeCollector, int i, S entityRenderState, float f, float g) { + coloredCutoutModelCopyLayerRender(this.model, this.texture, poseStack, submitNodeCollector, i, entityRenderState, -1, 1); } } diff --git a/src/client/java/fr/hugman/promenade/client/render/entity/DuckEntityRenderer.java b/src/client/java/fr/hugman/promenade/client/render/entity/DuckEntityRenderer.java index a47057dd..1920cd7b 100644 --- a/src/client/java/fr/hugman/promenade/client/render/entity/DuckEntityRenderer.java +++ b/src/client/java/fr/hugman/promenade/client/render/entity/DuckEntityRenderer.java @@ -1,48 +1,51 @@ package fr.hugman.promenade.client.render.entity; -import fr.hugman.promenade.client.render.entity.model.DuckEntityModel; +import fr.hugman.promenade.client.render.entity.model.duck.AdultDuckModel; +import fr.hugman.promenade.client.render.entity.model.duck.BabyDuckModel; +import fr.hugman.promenade.client.render.entity.model.duck.DuckModel; import fr.hugman.promenade.client.render.entity.model.PromenadeEntityModelLayers; -import fr.hugman.promenade.client.render.entity.state.DuckEntityRenderState; -import fr.hugman.promenade.entity.DuckEntity; +import fr.hugman.promenade.client.render.entity.state.DuckRenderState; +import fr.hugman.promenade.entity.Duck; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.client.render.entity.AgeableMobEntityRenderer; -import net.minecraft.client.render.entity.EntityRendererFactory; -import net.minecraft.client.texture.MissingSprite; -import net.minecraft.util.Identifier; -import net.minecraft.util.math.MathHelper; +import net.minecraft.client.renderer.entity.AgeableMobRenderer; +import net.minecraft.client.renderer.entity.EntityRendererProvider; +import net.minecraft.client.renderer.texture.MissingTextureAtlasSprite; +import net.minecraft.resources.Identifier; +import net.minecraft.util.Mth; @Environment(EnvType.CLIENT) -public class DuckEntityRenderer extends AgeableMobEntityRenderer { - public DuckEntityRenderer(EntityRendererFactory.Context context) { +public class DuckEntityRenderer extends AgeableMobRenderer { + public DuckEntityRenderer(EntityRendererProvider.Context context) { super( context, - new DuckEntityModel(context.getPart(PromenadeEntityModelLayers.DUCK)), - new DuckEntityModel(context.getPart(PromenadeEntityModelLayers.DUCK_BABY)), + new AdultDuckModel(context.bakeLayer(PromenadeEntityModelLayers.DUCK)), + new BabyDuckModel(context.bakeLayer(PromenadeEntityModelLayers.DUCK_BABY)), 0.3F ); } @Override - public DuckEntityRenderState createRenderState() { - return new DuckEntityRenderState(); + public DuckRenderState createRenderState() { + return new DuckRenderState(); } @Override - public Identifier getTexture(DuckEntityRenderState state) { + public Identifier getTextureLocation(DuckRenderState state) { if (state.variant == null) { - return MissingSprite.getMissingSpriteId(); + return MissingTextureAtlasSprite.getLocation(); } - if (state.baby) { + if (state.isBaby) { return state.variant.babyTexture().texturePath(); } return state.variant.texture().texturePath(); } - public void updateRenderState(DuckEntity duck, DuckEntityRenderState state, float f) { - super.updateRenderState(duck, state, f); - state.flapProgress = MathHelper.lerp(f, duck.prevFlapProgress, duck.flapProgress); - state.maxWingDeviation = MathHelper.lerp(f, duck.prevMaxWingDeviation, duck.maxWingDeviation); + @Override + public void extractRenderState(Duck duck, DuckRenderState state, float f) { + super.extractRenderState(duck, state, f); + state.flapProgress = Mth.lerp(f, duck.prevFlapProgress, duck.flapProgress); + state.maxWingDeviation = Mth.lerp(f, duck.prevMaxWingDeviation, duck.maxWingDeviation); state.variant = duck.getVariant().value(); } } \ No newline at end of file diff --git a/src/client/java/fr/hugman/promenade/client/render/entity/LushCreeperRenderer.java b/src/client/java/fr/hugman/promenade/client/render/entity/LushCreeperRenderer.java index 888e877e..8b917546 100644 --- a/src/client/java/fr/hugman/promenade/client/render/entity/LushCreeperRenderer.java +++ b/src/client/java/fr/hugman/promenade/client/render/entity/LushCreeperRenderer.java @@ -1,38 +1,37 @@ package fr.hugman.promenade.client.render.entity; +import com.mojang.blaze3d.vertex.PoseStack; import fr.hugman.promenade.Promenade; import fr.hugman.promenade.client.render.entity.model.PromenadeEntityModelLayers; -import fr.hugman.promenade.entity.LushCreeperEntity; +import fr.hugman.promenade.entity.LushCreeper; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.client.render.entity.EntityRendererFactory; -import net.minecraft.client.render.entity.MobEntityRenderer; -import net.minecraft.client.render.entity.model.CreeperEntityModel; -import net.minecraft.client.render.entity.state.CreeperEntityRenderState; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.util.Identifier; -import net.minecraft.util.math.MathHelper; - -@Environment(EnvType.CLIENT) -public class LushCreeperRenderer extends MobEntityRenderer { +import net.minecraft.client.model.monster.creeper.CreeperModel; +import net.minecraft.client.renderer.entity.EntityRendererProvider; +import net.minecraft.client.renderer.entity.MobRenderer; +import net.minecraft.client.renderer.entity.state.CreeperRenderState; +import net.minecraft.resources.Identifier; +import net.minecraft.util.Mth; + +public class LushCreeperRenderer extends MobRenderer { private static final Identifier TEXTURE = Promenade.id("textures/entity/lush_creeper/base.png"); private static final Identifier OVERLAY_TEXTURE = Promenade.id("textures/entity/lush_creeper/overlay.png"); - public LushCreeperRenderer(EntityRendererFactory.Context context) { - super(context, new CreeperEntityModel(context.getPart(PromenadeEntityModelLayers.LUSH_CREEPER)), 0.5F); - this.addFeature(new CreeperOverlayRenderer<>(this, context.getEntityModels(), PromenadeEntityModelLayers.LUSH_CREEPER_OUTER, OVERLAY_TEXTURE)); + public LushCreeperRenderer(EntityRendererProvider.Context context) { + super(context, new CreeperModel(context.bakeLayer(PromenadeEntityModelLayers.LUSH_CREEPER)), 0.5F); + this.addLayer(new CreeperOverlayRenderer<>(this, context.getModelSet(), PromenadeEntityModelLayers.LUSH_CREEPER_OUTER, OVERLAY_TEXTURE)); } @Override - public CreeperEntityRenderState createRenderState() { - return new CreeperEntityRenderState(); + public CreeperRenderState createRenderState() { + return new CreeperRenderState(); } @Override - protected void scale(CreeperEntityRenderState creeperEntityRenderState, MatrixStack matrixStack) { - float f = creeperEntityRenderState.fuseTime; - float g = 1.0F + MathHelper.sin(f * 100.0F) * f * 0.01F; - f = MathHelper.clamp(f, 0.0F, 1.0F); + protected void scale(CreeperRenderState creeperEntityRenderState, PoseStack matrixStack) { + float f = creeperEntityRenderState.swelling; + float g = 1.0F + Mth.sin(f * 100.0F) * f * 0.01F; + f = Mth.clamp(f, 0.0F, 1.0F); f *= f; f *= f; float h = (1.0F + f * 0.4F) * g; @@ -41,19 +40,20 @@ protected void scale(CreeperEntityRenderState creeperEntityRenderState, MatrixSt } @Override - protected float getAnimationCounter(CreeperEntityRenderState state) { - float f = state.fuseTime; - return (int) (f * 10.0F) % 2 == 0 ? 0.0F : MathHelper.clamp(f, 0.5F, 1.0F); + protected float getWhiteOverlayProgress(CreeperRenderState state) { + float f = state.swelling; + return (int) (f * 10.0F) % 2 == 0 ? 0.0F : Mth.clamp(f, 0.5F, 1.0F); } @Override - public Identifier getTexture(CreeperEntityRenderState state) { + public Identifier getTextureLocation(CreeperRenderState state) { return TEXTURE; } - public void updateRenderState(LushCreeperEntity lushCreeper, CreeperEntityRenderState creeperEntityRenderState, float f) { - super.updateRenderState(lushCreeper, creeperEntityRenderState, f); - creeperEntityRenderState.fuseTime = lushCreeper.getLerpedFuseTime(f); - creeperEntityRenderState.charged = lushCreeper.isCharged(); + @Override + public void extractRenderState(LushCreeper lushCreeper, CreeperRenderState creeperEntityRenderState, float f) { + super.extractRenderState(lushCreeper, creeperEntityRenderState, f); + creeperEntityRenderState.swelling = lushCreeper.getSwelling(f); + creeperEntityRenderState.isPowered = lushCreeper.isPowered(); } } diff --git a/src/client/java/fr/hugman/promenade/client/render/entity/PromenadeEntityRenderers.java b/src/client/java/fr/hugman/promenade/client/render/entity/PromenadeEntityRenderers.java index 79145efc..9fc6f018 100644 --- a/src/client/java/fr/hugman/promenade/client/render/entity/PromenadeEntityRenderers.java +++ b/src/client/java/fr/hugman/promenade/client/render/entity/PromenadeEntityRenderers.java @@ -2,21 +2,19 @@ import fr.hugman.promenade.client.render.entity.model.PromenadeEntityModelLayers; import fr.hugman.promenade.entity.PromenadeEntityTypes; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -import net.fabricmc.fabric.api.client.rendering.v1.EntityRendererRegistry; -import net.minecraft.client.render.entity.BoatEntityRenderer; -import net.minecraft.client.render.entity.model.EntityModelLayer; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.vehicle.AbstractBoatEntity; +import net.minecraft.client.model.geom.ModelLayerLocation; +import net.minecraft.client.renderer.entity.BoatRenderer; +import net.minecraft.client.renderer.entity.EntityRendererProvider; +import net.minecraft.client.renderer.entity.EntityRenderers; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.vehicle.boat.AbstractBoat; -@Environment(EnvType.CLIENT) public class PromenadeEntityRenderers { public static void register() { - EntityRendererRegistry.register(PromenadeEntityTypes.CAPYBARA, CapybaraEntityRenderer::new); - EntityRendererRegistry.register(PromenadeEntityTypes.DUCK, DuckEntityRenderer::new); - EntityRendererRegistry.register(PromenadeEntityTypes.LUSH_CREEPER, LushCreeperRenderer::new); - EntityRendererRegistry.register(PromenadeEntityTypes.SUNKEN, SunkenEntityRenderer::new); + EntityRenderers.register(PromenadeEntityTypes.CAPYBARA, CapybaraEntityRenderer::new); + EntityRenderers.register(PromenadeEntityTypes.DUCK, DuckEntityRenderer::new); + EntityRenderers.register(PromenadeEntityTypes.LUSH_CREEPER, LushCreeperRenderer::new); + EntityRenderers.register(PromenadeEntityTypes.SUNKEN, SunkenEntityRenderer::new); registerBoat(PromenadeEntityTypes.SAKURA_BOAT, PromenadeEntityModelLayers.SAKURA_BOAT); registerBoat(PromenadeEntityTypes.SAKURA_CHEST_BOAT, PromenadeEntityModelLayers.SAKURA_CHEST_BOAT); @@ -26,7 +24,7 @@ public static void register() { registerBoat(PromenadeEntityTypes.PALM_CHEST_BOAT, PromenadeEntityModelLayers.PALM_CHEST_BOAT); } - private static void registerBoat(EntityType type, EntityModelLayer modelLayer) { - EntityRendererRegistry.register(type, context -> new BoatEntityRenderer(context, modelLayer)); + private static void registerBoat(EntityType type, ModelLayerLocation modelId) { + EntityRenderers.register(type, context -> new BoatRenderer(context, modelId)); } } diff --git a/src/client/java/fr/hugman/promenade/client/render/entity/SunkenEntityRenderer.java b/src/client/java/fr/hugman/promenade/client/render/entity/SunkenEntityRenderer.java index 9ced905d..2f37769c 100644 --- a/src/client/java/fr/hugman/promenade/client/render/entity/SunkenEntityRenderer.java +++ b/src/client/java/fr/hugman/promenade/client/render/entity/SunkenEntityRenderer.java @@ -1,61 +1,61 @@ package fr.hugman.promenade.client.render.entity; +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.math.Axis; import fr.hugman.promenade.client.render.entity.model.PromenadeEntityModelLayers; import fr.hugman.promenade.client.render.entity.model.SunkenEntityModel; -import fr.hugman.promenade.client.render.entity.state.SunkenEntityRenderState; -import fr.hugman.promenade.entity.SunkenEntity; +import fr.hugman.promenade.client.render.entity.state.SunkenRenderState; +import fr.hugman.promenade.entity.Sunken; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.client.render.entity.AbstractSkeletonEntityRenderer; -import net.minecraft.client.render.entity.EntityRendererFactory; -import net.minecraft.client.texture.MissingSprite; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.util.Identifier; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.RotationAxis; +import net.minecraft.client.renderer.entity.AbstractSkeletonRenderer; +import net.minecraft.client.renderer.entity.EntityRendererProvider; +import net.minecraft.client.renderer.texture.MissingTextureAtlasSprite; +import net.minecraft.resources.Identifier; +import net.minecraft.util.Mth; @Environment(EnvType.CLIENT) -public class SunkenEntityRenderer extends AbstractSkeletonEntityRenderer { - public SunkenEntityRenderer(EntityRendererFactory.Context context) { +public class SunkenEntityRenderer extends AbstractSkeletonRenderer { + public SunkenEntityRenderer(EntityRendererProvider.Context context) { super( context, PromenadeEntityModelLayers.SUNKEN_EQUIPMENT, - new SunkenEntityModel(context.getPart(PromenadeEntityModelLayers.SUNKEN)) + new SunkenEntityModel(context.bakeLayer(PromenadeEntityModelLayers.SUNKEN)) ); } @Override - public SunkenEntityRenderState createRenderState() { - return new SunkenEntityRenderState(); + public SunkenRenderState createRenderState() { + return new SunkenRenderState(); } @Override - protected void setupTransforms(SunkenEntityRenderState state, MatrixStack matrices, float bodyYaw, float baseHeight) { - float h = state.leaningPitch; - float i = state.pitch; + protected void setupRotations(SunkenRenderState state, PoseStack poseStack, float bodyYaw, float baseHeight) { + float h = state.swimAmount; + float i = state.xRot; - super.setupTransforms(state, matrices, bodyYaw, baseHeight); + super.setupRotations(state, poseStack, bodyYaw, baseHeight); if (h > 0.0F) { - float jx = state.touchingWater ? -90.0F - i : -90.0F; - float k = MathHelper.lerp(h, 0.0F, jx); - matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(k)); - if (state.isSwimming) { - matrices.translate(0.0F, -1.0F, 0.3F); + float jx = state.isInWater ? -90.0F - i : -90.0F; + float k = Mth.lerp(h, 0.0F, jx); + poseStack.mulPose(Axis.XP.rotationDegrees(k)); + if (state.isVisuallySwimming) { + poseStack.translate(0.0F, -1.0F, 0.3F); } } } @Override - public Identifier getTexture(SunkenEntityRenderState state) { + public Identifier getTextureLocation(SunkenRenderState state) { if (state.variant == null) { - return MissingSprite.getMissingSpriteId(); + return MissingTextureAtlasSprite.getLocation(); } return state.variant.texture().texturePath(); } @Override - public void updateRenderState(SunkenEntity sunken, SunkenEntityRenderState state, float f) { - super.updateRenderState(sunken, state, f); + public void extractRenderState(Sunken sunken, SunkenRenderState state, float f) { + super.extractRenderState(sunken, state, f); state.variant = sunken.getVariant().value(); } } diff --git a/src/client/java/fr/hugman/promenade/client/render/entity/animation/CapybaraAnimations.java b/src/client/java/fr/hugman/promenade/client/render/entity/animation/CapybaraAnimations.java index 822ccc74..119c73a9 100644 --- a/src/client/java/fr/hugman/promenade/client/render/entity/animation/CapybaraAnimations.java +++ b/src/client/java/fr/hugman/promenade/client/render/entity/animation/CapybaraAnimations.java @@ -2,387 +2,386 @@ import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.client.render.entity.animation.AnimationDefinition; -import net.minecraft.client.render.entity.animation.AnimationHelper; -import net.minecraft.client.render.entity.animation.Keyframe; -import net.minecraft.client.render.entity.animation.Transformation; -import net.minecraft.client.render.entity.model.EntityModelPartNames; +import net.minecraft.client.animation.AnimationChannel; +import net.minecraft.client.animation.AnimationDefinition; +import net.minecraft.client.animation.Keyframe; +import net.minecraft.client.animation.KeyframeAnimations; +import net.minecraft.client.model.geom.PartNames; -@Environment(EnvType.CLIENT) public class CapybaraAnimations { - public static final AnimationDefinition EAR_WIGGLE = AnimationDefinition.Builder.create(0.2f) - .addBoneAnimation(EntityModelPartNames.RIGHT_EAR, new Transformation(Transformation.Targets.ROTATE, - new Keyframe(0f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(0.1f, AnimationHelper.createRotationalVector(-13.5f, -15f, 13f), Transformation.Interpolations.CUBIC), - new Keyframe(0.2f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.LEFT_EAR, new Transformation(Transformation.Targets.ROTATE, - new Keyframe(0f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(0.1f, AnimationHelper.createRotationalVector(-13.5f, 15f, -13f), Transformation.Interpolations.CUBIC), - new Keyframe(0.2f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) + public static final AnimationDefinition EAR_WIGGLE = AnimationDefinition.Builder.withLength(0.2f) + .addAnimation(PartNames.RIGHT_EAR, new AnimationChannel(AnimationChannel.Targets.ROTATION, + new Keyframe(0f, KeyframeAnimations.degreeVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.1f, KeyframeAnimations.degreeVec(-13.5f, -15f, 13f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.2f, KeyframeAnimations.degreeVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM))) + .addAnimation(PartNames.LEFT_EAR, new AnimationChannel(AnimationChannel.Targets.ROTATION, + new Keyframe(0f, KeyframeAnimations.degreeVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.1f, KeyframeAnimations.degreeVec(-13.5f, 15f, -13f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.2f, KeyframeAnimations.degreeVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM))) .build(); - public static final AnimationDefinition WALKING = AnimationDefinition.Builder.create(1.5f).looping() - .addBoneAnimation(EntityModelPartNames.BODY, new Transformation(Transformation.Targets.ROTATE, - new Keyframe(0f, AnimationHelper.createRotationalVector(0f, 0f, 2.5f), Transformation.Interpolations.CUBIC), - new Keyframe(0.75f, AnimationHelper.createRotationalVector(0f, 0f, -2.5f), Transformation.Interpolations.CUBIC), - new Keyframe(1.5f, AnimationHelper.createRotationalVector(0f, 0f, 2.5f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.HEAD, new Transformation(Transformation.Targets.ROTATE, - new Keyframe(0f, AnimationHelper.createRotationalVector(0f, 0f, -5f), Transformation.Interpolations.CUBIC), - new Keyframe(0.75f, AnimationHelper.createRotationalVector(0f, 0f, 5f), Transformation.Interpolations.CUBIC), - new Keyframe(1.5f, AnimationHelper.createRotationalVector(0f, 0f, -5f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.RIGHT_FRONT_LEG, new Transformation(Transformation.Targets.ROTATE, - new Keyframe(0f, AnimationHelper.createRotationalVector(27.5f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(0.75f, AnimationHelper.createRotationalVector(-27.5f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(1.5f, AnimationHelper.createRotationalVector(27.5f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.LEFT_FRONT_LEG, new Transformation(Transformation.Targets.ROTATE, - new Keyframe(0f, AnimationHelper.createRotationalVector(-27.5f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(0.75f, AnimationHelper.createRotationalVector(27.5f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(1.5f, AnimationHelper.createRotationalVector(-27.5f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.RIGHT_HIND_LEG, new Transformation(Transformation.Targets.ROTATE, - new Keyframe(0f, AnimationHelper.createRotationalVector(-27.5f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(0.75f, AnimationHelper.createRotationalVector(27.5f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(1.5f, AnimationHelper.createRotationalVector(-27.5f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.LEFT_HIND_LEG, new Transformation(Transformation.Targets.ROTATE, - new Keyframe(0f, AnimationHelper.createRotationalVector(27.5f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(0.75f, AnimationHelper.createRotationalVector(-27.5f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(1.5f, AnimationHelper.createRotationalVector(27.5f, 0f, 0f), Transformation.Interpolations.CUBIC))).build(); + public static final AnimationDefinition WALKING = AnimationDefinition.Builder.withLength(1.5f).looping() + .addAnimation(PartNames.BODY, new AnimationChannel(AnimationChannel.Targets.ROTATION, + new Keyframe(0f, KeyframeAnimations.degreeVec(0f, 0f, 2.5f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.75f, KeyframeAnimations.degreeVec(0f, 0f, -2.5f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.5f, KeyframeAnimations.degreeVec(0f, 0f, 2.5f), AnimationChannel.Interpolations.CATMULLROM))) + .addAnimation(PartNames.HEAD, new AnimationChannel(AnimationChannel.Targets.ROTATION, + new Keyframe(0f, KeyframeAnimations.degreeVec(0f, 0f, -5f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.75f, KeyframeAnimations.degreeVec(0f, 0f, 5f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.5f, KeyframeAnimations.degreeVec(0f, 0f, -5f), AnimationChannel.Interpolations.CATMULLROM))) + .addAnimation(PartNames.RIGHT_FRONT_LEG, new AnimationChannel(AnimationChannel.Targets.ROTATION, + new Keyframe(0f, KeyframeAnimations.degreeVec(27.5f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.75f, KeyframeAnimations.degreeVec(-27.5f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.5f, KeyframeAnimations.degreeVec(27.5f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM))) + .addAnimation(PartNames.LEFT_FRONT_LEG, new AnimationChannel(AnimationChannel.Targets.ROTATION, + new Keyframe(0f, KeyframeAnimations.degreeVec(-27.5f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.75f, KeyframeAnimations.degreeVec(27.5f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.5f, KeyframeAnimations.degreeVec(-27.5f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM))) + .addAnimation(PartNames.RIGHT_HIND_LEG, new AnimationChannel(AnimationChannel.Targets.ROTATION, + new Keyframe(0f, KeyframeAnimations.degreeVec(-27.5f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.75f, KeyframeAnimations.degreeVec(27.5f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.5f, KeyframeAnimations.degreeVec(-27.5f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM))) + .addAnimation(PartNames.LEFT_HIND_LEG, new AnimationChannel(AnimationChannel.Targets.ROTATION, + new Keyframe(0f, KeyframeAnimations.degreeVec(27.5f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.75f, KeyframeAnimations.degreeVec(-27.5f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.5f, KeyframeAnimations.degreeVec(27.5f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM))).build(); - public static final AnimationDefinition FALL_TO_SLEEP = AnimationDefinition.Builder.create(1.9167667f) - .addBoneAnimation(EntityModelPartNames.ROOT, new Transformation(Transformation.Targets.MOVE_ORIGIN, - new Keyframe(0f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(0.8343334f, AnimationHelper.createTranslationalVector(-1f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(1.5834333f, AnimationHelper.createTranslationalVector(-12f, -5f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.ROOT, new Transformation(Transformation.Targets.ROTATE, - new Keyframe(0f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(0.8343334f, AnimationHelper.createRotationalVector(0f, 0f, -10f), Transformation.Interpolations.CUBIC), - new Keyframe(1.5834333f, AnimationHelper.createRotationalVector(0f, 0f, -90f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.ROOT, new Transformation(Transformation.Targets.SCALE, - new Keyframe(0f, AnimationHelper.createScalingVector(1f, 1f, 1f), Transformation.Interpolations.LINEAR), - new Keyframe(1.375f, AnimationHelper.createScalingVector(1f, 1f, 1f), Transformation.Interpolations.CUBIC), - new Keyframe(1.4583433f, AnimationHelper.createScalingVector(0.8f, 1.1f, 1.1f), Transformation.Interpolations.CUBIC), - new Keyframe(1.5834333f, AnimationHelper.createScalingVector(1.2f, 0.9f, 0.9f), Transformation.Interpolations.CUBIC), - new Keyframe(1.6766667f, AnimationHelper.createScalingVector(1f, 1f, 1f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.RIGHT_FRONT_LEG, new Transformation(Transformation.Targets.ROTATE, - new Keyframe(0f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(0.8343334f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(1.3433333f, AnimationHelper.createRotationalVector(0f, 0f, -60f), Transformation.Interpolations.CUBIC), - new Keyframe(1.625f, AnimationHelper.createRotationalVector(-7.5f, 0f, 17.5f), Transformation.Interpolations.CUBIC), - new Keyframe(1.7916767f, AnimationHelper.createRotationalVector(-7.387326251354352f, -1.2987564674722307f, 7.583846147258555f), Transformation.Interpolations.LINEAR), - new Keyframe(1.9167667f, AnimationHelper.createRotationalVector(-7.5f, 0f, 17.5f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.RIGHT_FRONT_LEG, new Transformation(Transformation.Targets.SCALE, - new Keyframe(0.8343334f, AnimationHelper.createScalingVector(1f, 1f, 1f), Transformation.Interpolations.LINEAR), - new Keyframe(0.9583434f, AnimationHelper.createScalingVector(1f, 0.8f, 1f), Transformation.Interpolations.LINEAR), - new Keyframe(1.0834333f, AnimationHelper.createScalingVector(1f, 0.8f, 1f), Transformation.Interpolations.LINEAR), - new Keyframe(1.1676667f, AnimationHelper.createScalingVector(1f, 1f, 1f), Transformation.Interpolations.LINEAR))) - .addBoneAnimation(EntityModelPartNames.LEFT_FRONT_LEG, new Transformation(Transformation.Targets.MOVE_ORIGIN, - new Keyframe(0f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(0.8343334f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.LEFT_FRONT_LEG, new Transformation(Transformation.Targets.ROTATE, - new Keyframe(0f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(0.8343334f, AnimationHelper.createRotationalVector(0f, 0f, 40f), Transformation.Interpolations.CUBIC), - new Keyframe(1.1676667f, AnimationHelper.createRotationalVector(-0.8329438344855409f, -2.0100084957616673f, -31.292852606551207f), Transformation.Interpolations.CUBIC), - new Keyframe(1.625f, AnimationHelper.createRotationalVector(-20f, 0f, 5f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.LEFT_FRONT_LEG, new Transformation(Transformation.Targets.SCALE, - new Keyframe(0.8343334f, AnimationHelper.createScalingVector(1f, 1f, 1f), Transformation.Interpolations.LINEAR), - new Keyframe(0.9583434f, AnimationHelper.createScalingVector(1f, 0.8f, 1f), Transformation.Interpolations.LINEAR), - new Keyframe(1.0834333f, AnimationHelper.createScalingVector(1f, 0.8f, 1f), Transformation.Interpolations.LINEAR), - new Keyframe(1.1676667f, AnimationHelper.createScalingVector(1f, 1f, 1f), Transformation.Interpolations.LINEAR))) - .addBoneAnimation(EntityModelPartNames.RIGHT_HIND_LEG, new Transformation(Transformation.Targets.ROTATE, - new Keyframe(0f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(0.8343334f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(1.3433333f, AnimationHelper.createRotationalVector(0f, 0f, -77.5f), Transformation.Interpolations.CUBIC), - new Keyframe(1.625f, AnimationHelper.createRotationalVector(22.480717026093316f, 0.9564494572955482f, 20.19008655601783f), Transformation.Interpolations.CUBIC), - new Keyframe(1.7916767f, AnimationHelper.createRotationalVector(22.018164129528486f, 4.751129561951075f, 10.924817551732758f), Transformation.Interpolations.LINEAR), - new Keyframe(1.9167667f, AnimationHelper.createRotationalVector(22.480717026093316f, 0.9564494572955482f, 20.19008655601783f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.LEFT_HIND_LEG, new Transformation(Transformation.Targets.MOVE_ORIGIN, - new Keyframe(0f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(0.8343334f, AnimationHelper.createTranslationalVector(-1f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.LEFT_HIND_LEG, new Transformation(Transformation.Targets.ROTATE, - new Keyframe(0f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(0.8343334f, AnimationHelper.createRotationalVector(0f, 0f, 42.5f), Transformation.Interpolations.CUBIC), - new Keyframe(1.1676667f, AnimationHelper.createRotationalVector(5.989807308760465f, 9.302389729048627f, -28.590097057579058f), Transformation.Interpolations.CUBIC), - new Keyframe(1.625f, AnimationHelper.createRotationalVector(27.5f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.HEAD, new Transformation(Transformation.Targets.MOVE_ORIGIN, - new Keyframe(0f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(1.7083433f, AnimationHelper.createTranslationalVector(-1f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.HEAD, new Transformation(Transformation.Targets.ROTATE, - new Keyframe(0f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(0.8343334f, AnimationHelper.createRotationalVector(4.990462591650612f, 4.99522900802458f, -20.218651201461853f), Transformation.Interpolations.CUBIC), - new Keyframe(1.25f, AnimationHelper.createRotationalVector(0f, 0f, 27.5f), Transformation.Interpolations.CUBIC), - new Keyframe(1.5f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(1.7083433f, AnimationHelper.createRotationalVector(0f, 0f, -5f), Transformation.Interpolations.CUBIC))).build(); + public static final AnimationDefinition FALL_TO_SLEEP = AnimationDefinition.Builder.withLength(1.9167667f) + .addAnimation(PartNames.ROOT, new AnimationChannel(AnimationChannel.Targets.POSITION, + new Keyframe(0f, KeyframeAnimations.posVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.8343334f, KeyframeAnimations.posVec(-1f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.5834333f, KeyframeAnimations.posVec(-12f, -5f, 0f), AnimationChannel.Interpolations.CATMULLROM))) + .addAnimation(PartNames.ROOT, new AnimationChannel(AnimationChannel.Targets.ROTATION, + new Keyframe(0f, KeyframeAnimations.degreeVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.8343334f, KeyframeAnimations.degreeVec(0f, 0f, -10f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.5834333f, KeyframeAnimations.degreeVec(0f, 0f, -90f), AnimationChannel.Interpolations.CATMULLROM))) + .addAnimation(PartNames.ROOT, new AnimationChannel(AnimationChannel.Targets.SCALE, + new Keyframe(0f, KeyframeAnimations.scaleVec(1f, 1f, 1f), AnimationChannel.Interpolations.LINEAR), + new Keyframe(1.375f, KeyframeAnimations.scaleVec(1f, 1f, 1f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.4583433f, KeyframeAnimations.scaleVec(0.8f, 1.1f, 1.1f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.5834333f, KeyframeAnimations.scaleVec(1.2f, 0.9f, 0.9f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.6766667f, KeyframeAnimations.scaleVec(1f, 1f, 1f), AnimationChannel.Interpolations.CATMULLROM))) + .addAnimation(PartNames.RIGHT_FRONT_LEG, new AnimationChannel(AnimationChannel.Targets.ROTATION, + new Keyframe(0f, KeyframeAnimations.degreeVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.8343334f, KeyframeAnimations.degreeVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.3433333f, KeyframeAnimations.degreeVec(0f, 0f, -60f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.625f, KeyframeAnimations.degreeVec(-7.5f, 0f, 17.5f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.7916767f, KeyframeAnimations.degreeVec(-7.387326251354352f, -1.2987564674722307f, 7.583846147258555f), AnimationChannel.Interpolations.LINEAR), + new Keyframe(1.9167667f, KeyframeAnimations.degreeVec(-7.5f, 0f, 17.5f), AnimationChannel.Interpolations.CATMULLROM))) + .addAnimation(PartNames.RIGHT_FRONT_LEG, new AnimationChannel(AnimationChannel.Targets.SCALE, + new Keyframe(0.8343334f, KeyframeAnimations.scaleVec(1f, 1f, 1f), AnimationChannel.Interpolations.LINEAR), + new Keyframe(0.9583434f, KeyframeAnimations.scaleVec(1f, 0.8f, 1f), AnimationChannel.Interpolations.LINEAR), + new Keyframe(1.0834333f, KeyframeAnimations.scaleVec(1f, 0.8f, 1f), AnimationChannel.Interpolations.LINEAR), + new Keyframe(1.1676667f, KeyframeAnimations.scaleVec(1f, 1f, 1f), AnimationChannel.Interpolations.LINEAR))) + .addAnimation(PartNames.LEFT_FRONT_LEG, new AnimationChannel(AnimationChannel.Targets.POSITION, + new Keyframe(0f, KeyframeAnimations.posVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.8343334f, KeyframeAnimations.posVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM))) + .addAnimation(PartNames.LEFT_FRONT_LEG, new AnimationChannel(AnimationChannel.Targets.ROTATION, + new Keyframe(0f, KeyframeAnimations.degreeVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.8343334f, KeyframeAnimations.degreeVec(0f, 0f, 40f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.1676667f, KeyframeAnimations.degreeVec(-0.8329438344855409f, -2.0100084957616673f, -31.292852606551207f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.625f, KeyframeAnimations.degreeVec(-20f, 0f, 5f), AnimationChannel.Interpolations.CATMULLROM))) + .addAnimation(PartNames.LEFT_FRONT_LEG, new AnimationChannel(AnimationChannel.Targets.SCALE, + new Keyframe(0.8343334f, KeyframeAnimations.scaleVec(1f, 1f, 1f), AnimationChannel.Interpolations.LINEAR), + new Keyframe(0.9583434f, KeyframeAnimations.scaleVec(1f, 0.8f, 1f), AnimationChannel.Interpolations.LINEAR), + new Keyframe(1.0834333f, KeyframeAnimations.scaleVec(1f, 0.8f, 1f), AnimationChannel.Interpolations.LINEAR), + new Keyframe(1.1676667f, KeyframeAnimations.scaleVec(1f, 1f, 1f), AnimationChannel.Interpolations.LINEAR))) + .addAnimation(PartNames.RIGHT_HIND_LEG, new AnimationChannel(AnimationChannel.Targets.ROTATION, + new Keyframe(0f, KeyframeAnimations.degreeVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.8343334f, KeyframeAnimations.degreeVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.3433333f, KeyframeAnimations.degreeVec(0f, 0f, -77.5f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.625f, KeyframeAnimations.degreeVec(22.480717026093316f, 0.9564494572955482f, 20.19008655601783f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.7916767f, KeyframeAnimations.degreeVec(22.018164129528486f, 4.751129561951075f, 10.924817551732758f), AnimationChannel.Interpolations.LINEAR), + new Keyframe(1.9167667f, KeyframeAnimations.degreeVec(22.480717026093316f, 0.9564494572955482f, 20.19008655601783f), AnimationChannel.Interpolations.CATMULLROM))) + .addAnimation(PartNames.LEFT_HIND_LEG, new AnimationChannel(AnimationChannel.Targets.POSITION, + new Keyframe(0f, KeyframeAnimations.posVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.8343334f, KeyframeAnimations.posVec(-1f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM))) + .addAnimation(PartNames.LEFT_HIND_LEG, new AnimationChannel(AnimationChannel.Targets.ROTATION, + new Keyframe(0f, KeyframeAnimations.degreeVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.8343334f, KeyframeAnimations.degreeVec(0f, 0f, 42.5f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.1676667f, KeyframeAnimations.degreeVec(5.989807308760465f, 9.302389729048627f, -28.590097057579058f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.625f, KeyframeAnimations.degreeVec(27.5f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM))) + .addAnimation(PartNames.HEAD, new AnimationChannel(AnimationChannel.Targets.POSITION, + new Keyframe(0f, KeyframeAnimations.posVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.7083433f, KeyframeAnimations.posVec(-1f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM))) + .addAnimation(PartNames.HEAD, new AnimationChannel(AnimationChannel.Targets.ROTATION, + new Keyframe(0f, KeyframeAnimations.degreeVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.8343334f, KeyframeAnimations.degreeVec(4.990462591650612f, 4.99522900802458f, -20.218651201461853f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.25f, KeyframeAnimations.degreeVec(0f, 0f, 27.5f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.5f, KeyframeAnimations.degreeVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.7083433f, KeyframeAnimations.degreeVec(0f, 0f, -5f), AnimationChannel.Interpolations.CATMULLROM))).build(); - public static final AnimationDefinition SLEEP = AnimationDefinition.Builder.create(4.5f).looping() - .addBoneAnimation(EntityModelPartNames.ROOT, new Transformation(Transformation.Targets.MOVE_ORIGIN, - new Keyframe(0f, AnimationHelper.createTranslationalVector(-12f, -5f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.ROOT, new Transformation(Transformation.Targets.ROTATE, - new Keyframe(0f, AnimationHelper.createRotationalVector(0f, 0f, -90f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.RIGHT_FRONT_LEG, new Transformation(Transformation.Targets.MOVE_ORIGIN, - new Keyframe(0f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(1.25f, AnimationHelper.createTranslationalVector(0.75f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(2.25f, AnimationHelper.createTranslationalVector(0.75f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(3.5f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(4.5f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.RIGHT_FRONT_LEG, new Transformation(Transformation.Targets.ROTATE, - new Keyframe(0f, AnimationHelper.createRotationalVector(-7.5f, 0f, 17.5f), Transformation.Interpolations.CUBIC), - new Keyframe(1.25f, AnimationHelper.createRotationalVector(-7.4086946559950775f, 1.1699920891774127f, 26.424248239231474f), Transformation.Interpolations.CUBIC), - new Keyframe(2.25f, AnimationHelper.createRotationalVector(-7.4086946559950775f, 1.1699920891774127f, 26.424248239231474f), Transformation.Interpolations.CUBIC), - new Keyframe(3.5f, AnimationHelper.createRotationalVector(-7.5f, 0f, 17.5f), Transformation.Interpolations.CUBIC), - new Keyframe(4.5f, AnimationHelper.createRotationalVector(-7.5f, 0f, 17.5f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.LEFT_FRONT_LEG, new Transformation(Transformation.Targets.ROTATE, - new Keyframe(0f, AnimationHelper.createRotationalVector(-20f, 0f, 5f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.RIGHT_HIND_LEG, new Transformation(Transformation.Targets.MOVE_ORIGIN, - new Keyframe(0f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(1.25f, AnimationHelper.createTranslationalVector(1f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(2.25f, AnimationHelper.createTranslationalVector(1f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(3.5f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(4.5f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.RIGHT_HIND_LEG, new Transformation(Transformation.Targets.ROTATE, - new Keyframe(0f, AnimationHelper.createRotationalVector(22.48071702609377f, 0.9564494572955482f, 20.190086556017377f), Transformation.Interpolations.CUBIC), - new Keyframe(1.25f, AnimationHelper.createRotationalVector(22.30257854223737f, -3.0529741491914137f, 29.898054778260757f), Transformation.Interpolations.CUBIC), - new Keyframe(2.25f, AnimationHelper.createRotationalVector(22.30257854223737f, -3.0529741491914137f, 29.898054778260757f), Transformation.Interpolations.CUBIC), - new Keyframe(3.5f, AnimationHelper.createRotationalVector(22.48071702609377f, 0.9564494572955482f, 20.190086556017377f), Transformation.Interpolations.CUBIC), - new Keyframe(4.5f, AnimationHelper.createRotationalVector(22.48071702609377f, 0.9564494572955482f, 20.190086556017377f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.LEFT_HIND_LEG, new Transformation(Transformation.Targets.MOVE_ORIGIN, - new Keyframe(0f, AnimationHelper.createTranslationalVector(-1f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.LEFT_HIND_LEG, new Transformation(Transformation.Targets.ROTATE, - new Keyframe(0f, AnimationHelper.createRotationalVector(27.5f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.HEAD, new Transformation(Transformation.Targets.MOVE_ORIGIN, - new Keyframe(0f, AnimationHelper.createTranslationalVector(-1f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.HEAD, new Transformation(Transformation.Targets.ROTATE, - new Keyframe(0f, AnimationHelper.createRotationalVector(0f, 0f, -5f), Transformation.Interpolations.CUBIC), - new Keyframe(1.5416767f, AnimationHelper.createRotationalVector(-5f, 0f, -5f), Transformation.Interpolations.CUBIC), - new Keyframe(2.5416765f, AnimationHelper.createRotationalVector(-5f, 0f, -5f), Transformation.Interpolations.CUBIC), - new Keyframe(3.7083435f, AnimationHelper.createRotationalVector(0f, 0f, -5f), Transformation.Interpolations.CUBIC), - new Keyframe(4.5f, AnimationHelper.createRotationalVector(0f, 0f, -5f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.BODY, new Transformation(Transformation.Targets.MOVE_ORIGIN, - new Keyframe(0f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(1.25f, AnimationHelper.createTranslationalVector(0.25f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(2.25f, AnimationHelper.createTranslationalVector(0.25f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(3.5f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(4.5f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.BODY, new Transformation(Transformation.Targets.SCALE, - new Keyframe(0f, AnimationHelper.createScalingVector(1f, 1f, 1f), Transformation.Interpolations.CUBIC), - new Keyframe(1.25f, AnimationHelper.createScalingVector(1.1f, 1f, 1f), Transformation.Interpolations.CUBIC), - new Keyframe(2.25f, AnimationHelper.createScalingVector(1.1f, 1f, 1f), Transformation.Interpolations.CUBIC), - new Keyframe(3.5f, AnimationHelper.createScalingVector(1f, 1f, 1f), Transformation.Interpolations.CUBIC), - new Keyframe(4.5f, AnimationHelper.createScalingVector(1f, 1f, 1f), Transformation.Interpolations.CUBIC))).build(); + public static final AnimationDefinition SLEEP = AnimationDefinition.Builder.withLength(4.5f).looping() + .addAnimation(PartNames.ROOT, new AnimationChannel(AnimationChannel.Targets.POSITION, + new Keyframe(0f, KeyframeAnimations.posVec(-12f, -5f, 0f), AnimationChannel.Interpolations.CATMULLROM))) + .addAnimation(PartNames.ROOT, new AnimationChannel(AnimationChannel.Targets.ROTATION, + new Keyframe(0f, KeyframeAnimations.degreeVec(0f, 0f, -90f), AnimationChannel.Interpolations.CATMULLROM))) + .addAnimation(PartNames.RIGHT_FRONT_LEG, new AnimationChannel(AnimationChannel.Targets.POSITION, + new Keyframe(0f, KeyframeAnimations.posVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.25f, KeyframeAnimations.posVec(0.75f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(2.25f, KeyframeAnimations.posVec(0.75f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(3.5f, KeyframeAnimations.posVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(4.5f, KeyframeAnimations.posVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM))) + .addAnimation(PartNames.RIGHT_FRONT_LEG, new AnimationChannel(AnimationChannel.Targets.ROTATION, + new Keyframe(0f, KeyframeAnimations.degreeVec(-7.5f, 0f, 17.5f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.25f, KeyframeAnimations.degreeVec(-7.4086946559950775f, 1.1699920891774127f, 26.424248239231474f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(2.25f, KeyframeAnimations.degreeVec(-7.4086946559950775f, 1.1699920891774127f, 26.424248239231474f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(3.5f, KeyframeAnimations.degreeVec(-7.5f, 0f, 17.5f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(4.5f, KeyframeAnimations.degreeVec(-7.5f, 0f, 17.5f), AnimationChannel.Interpolations.CATMULLROM))) + .addAnimation(PartNames.LEFT_FRONT_LEG, new AnimationChannel(AnimationChannel.Targets.ROTATION, + new Keyframe(0f, KeyframeAnimations.degreeVec(-20f, 0f, 5f), AnimationChannel.Interpolations.CATMULLROM))) + .addAnimation(PartNames.RIGHT_HIND_LEG, new AnimationChannel(AnimationChannel.Targets.POSITION, + new Keyframe(0f, KeyframeAnimations.posVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.25f, KeyframeAnimations.posVec(1f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(2.25f, KeyframeAnimations.posVec(1f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(3.5f, KeyframeAnimations.posVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(4.5f, KeyframeAnimations.posVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM))) + .addAnimation(PartNames.RIGHT_HIND_LEG, new AnimationChannel(AnimationChannel.Targets.ROTATION, + new Keyframe(0f, KeyframeAnimations.degreeVec(22.48071702609377f, 0.9564494572955482f, 20.190086556017377f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.25f, KeyframeAnimations.degreeVec(22.30257854223737f, -3.0529741491914137f, 29.898054778260757f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(2.25f, KeyframeAnimations.degreeVec(22.30257854223737f, -3.0529741491914137f, 29.898054778260757f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(3.5f, KeyframeAnimations.degreeVec(22.48071702609377f, 0.9564494572955482f, 20.190086556017377f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(4.5f, KeyframeAnimations.degreeVec(22.48071702609377f, 0.9564494572955482f, 20.190086556017377f), AnimationChannel.Interpolations.CATMULLROM))) + .addAnimation(PartNames.LEFT_HIND_LEG, new AnimationChannel(AnimationChannel.Targets.POSITION, + new Keyframe(0f, KeyframeAnimations.posVec(-1f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM))) + .addAnimation(PartNames.LEFT_HIND_LEG, new AnimationChannel(AnimationChannel.Targets.ROTATION, + new Keyframe(0f, KeyframeAnimations.degreeVec(27.5f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM))) + .addAnimation(PartNames.HEAD, new AnimationChannel(AnimationChannel.Targets.POSITION, + new Keyframe(0f, KeyframeAnimations.posVec(-1f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM))) + .addAnimation(PartNames.HEAD, new AnimationChannel(AnimationChannel.Targets.ROTATION, + new Keyframe(0f, KeyframeAnimations.degreeVec(0f, 0f, -5f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.5416767f, KeyframeAnimations.degreeVec(-5f, 0f, -5f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(2.5416765f, KeyframeAnimations.degreeVec(-5f, 0f, -5f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(3.7083435f, KeyframeAnimations.degreeVec(0f, 0f, -5f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(4.5f, KeyframeAnimations.degreeVec(0f, 0f, -5f), AnimationChannel.Interpolations.CATMULLROM))) + .addAnimation(PartNames.BODY, new AnimationChannel(AnimationChannel.Targets.POSITION, + new Keyframe(0f, KeyframeAnimations.posVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.25f, KeyframeAnimations.posVec(0.25f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(2.25f, KeyframeAnimations.posVec(0.25f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(3.5f, KeyframeAnimations.posVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(4.5f, KeyframeAnimations.posVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM))) + .addAnimation(PartNames.BODY, new AnimationChannel(AnimationChannel.Targets.SCALE, + new Keyframe(0f, KeyframeAnimations.scaleVec(1f, 1f, 1f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.25f, KeyframeAnimations.scaleVec(1.1f, 1f, 1f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(2.25f, KeyframeAnimations.scaleVec(1.1f, 1f, 1f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(3.5f, KeyframeAnimations.scaleVec(1f, 1f, 1f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(4.5f, KeyframeAnimations.scaleVec(1f, 1f, 1f), AnimationChannel.Interpolations.CATMULLROM))).build(); - public static final AnimationDefinition FART = AnimationDefinition.Builder.create(3.8343335f) - .addBoneAnimation(EntityModelPartNames.ROOT, new Transformation(Transformation.Targets.MOVE_ORIGIN, - new Keyframe(0f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(0.08343333f, AnimationHelper.createTranslationalVector(0f, 5f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(0.16766666f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.ROOT, new Transformation(Transformation.Targets.SCALE, - new Keyframe(0f, AnimationHelper.createScalingVector(1f, 1f, 1f), Transformation.Interpolations.CUBIC), - new Keyframe(0.08343333f, AnimationHelper.createScalingVector(1f, 1.2f, 1f), Transformation.Interpolations.CUBIC), - new Keyframe(0.16766666f, AnimationHelper.createScalingVector(1f, 1f, 1f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.RIGHT_FRONT_LEG, new Transformation(Transformation.Targets.MOVE_ORIGIN, - new Keyframe(0f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(0.16766666f, AnimationHelper.createTranslationalVector(1f, 0f, 0f), Transformation.Interpolations.LINEAR), - new Keyframe(1.75f, AnimationHelper.createTranslationalVector(1f, 0f, 0f), Transformation.Interpolations.LINEAR), - new Keyframe(2.0416765f, AnimationHelper.createTranslationalVector(0.63f, 1f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(2.375f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.RIGHT_FRONT_LEG, new Transformation(Transformation.Targets.ROTATE, - new Keyframe(0f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(0.16766666f, AnimationHelper.createRotationalVector(-7.5f, 0f, -17.5f), Transformation.Interpolations.LINEAR), - new Keyframe(1.75f, AnimationHelper.createRotationalVector(-7.5f, 0f, -17.5f), Transformation.Interpolations.LINEAR), - new Keyframe(2.1676665f, AnimationHelper.createRotationalVector(0.2727354654598457f, 0.4131058282196136f, -6.089277436131233f), Transformation.Interpolations.CUBIC), - new Keyframe(2.5f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.LEFT_FRONT_LEG, new Transformation(Transformation.Targets.MOVE_ORIGIN, - new Keyframe(0f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(0.16766666f, AnimationHelper.createTranslationalVector(-1f, 0f, 0f), Transformation.Interpolations.LINEAR), - new Keyframe(1.75f, AnimationHelper.createTranslationalVector(-1f, 0f, 0f), Transformation.Interpolations.LINEAR), - new Keyframe(2.375f, AnimationHelper.createTranslationalVector(-1f, 0f, 0f), Transformation.Interpolations.LINEAR), - new Keyframe(2.7083435f, AnimationHelper.createTranslationalVector(-0.12f, 1f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(3.0416765f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.LEFT_FRONT_LEG, new Transformation(Transformation.Targets.ROTATE, - new Keyframe(0f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(0.16766666f, AnimationHelper.createRotationalVector(-7.5f, 0f, 17.5f), Transformation.Interpolations.LINEAR), - new Keyframe(1.75f, AnimationHelper.createRotationalVector(-7.5f, 0f, 17.5f), Transformation.Interpolations.LINEAR), - new Keyframe(2.375f, AnimationHelper.createRotationalVector(-7.5f, 0f, 17.5f), Transformation.Interpolations.LINEAR), - new Keyframe(2.7916765f, AnimationHelper.createRotationalVector(-5.111516362223829f, -0.446597721821945f, 6.992121938251076f), Transformation.Interpolations.CUBIC), - new Keyframe(3.0416765f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.RIGHT_HIND_LEG, new Transformation(Transformation.Targets.MOVE_ORIGIN, - new Keyframe(0f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(0.16766666f, AnimationHelper.createTranslationalVector(1f, 0f, 0f), Transformation.Interpolations.LINEAR), - new Keyframe(1.75f, AnimationHelper.createTranslationalVector(1f, 0f, 0f), Transformation.Interpolations.LINEAR), - new Keyframe(2.2083435f, AnimationHelper.createTranslationalVector(1f, 0f, 0f), Transformation.Interpolations.LINEAR), - new Keyframe(2.5f, AnimationHelper.createTranslationalVector(0.63f, 1f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(2.8343335f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.RIGHT_HIND_LEG, new Transformation(Transformation.Targets.ROTATE, - new Keyframe(0f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(0.16766666f, AnimationHelper.createRotationalVector(0f, 0f, -17.5f), Transformation.Interpolations.LINEAR), - new Keyframe(1.75f, AnimationHelper.createRotationalVector(0f, 0f, -17.5f), Transformation.Interpolations.LINEAR), - new Keyframe(2.2083435f, AnimationHelper.createRotationalVector(0f, 0f, -17.5f), Transformation.Interpolations.LINEAR), - new Keyframe(2.625f, AnimationHelper.createRotationalVector(0.2727354654598457f, 0.4131058282196136f, -6.089277436131233f), Transformation.Interpolations.CUBIC), - new Keyframe(2.9583435f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.LEFT_HIND_LEG, new Transformation(Transformation.Targets.MOVE_ORIGIN, - new Keyframe(0f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(0.16766666f, AnimationHelper.createTranslationalVector(-1f, 0f, 0f), Transformation.Interpolations.LINEAR), - new Keyframe(1.75f, AnimationHelper.createTranslationalVector(-1f, 0f, 0f), Transformation.Interpolations.LINEAR), - new Keyframe(2.8343335f, AnimationHelper.createTranslationalVector(-1f, 0f, 0f), Transformation.Interpolations.LINEAR), - new Keyframe(3.1676665f, AnimationHelper.createTranslationalVector(-0.12f, 1f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(3.5f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.LEFT_HIND_LEG, new Transformation(Transformation.Targets.ROTATE, - new Keyframe(0f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(0.16766666f, AnimationHelper.createRotationalVector(0f, 0f, 17.5f), Transformation.Interpolations.LINEAR), - new Keyframe(1.75f, AnimationHelper.createRotationalVector(0f, 0f, 17.5f), Transformation.Interpolations.LINEAR), - new Keyframe(2.8343335f, AnimationHelper.createRotationalVector(0f, 0f, 17.5f), Transformation.Interpolations.LINEAR), - new Keyframe(3.25f, AnimationHelper.createRotationalVector(-5.111516362223829f, -0.446597721821945f, 6.992121938251076f), Transformation.Interpolations.CUBIC), - new Keyframe(3.5f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.BODY, new Transformation(Transformation.Targets.ROTATE, - new Keyframe(0f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(0.16766666f, AnimationHelper.createRotationalVector(10f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(1.75f, AnimationHelper.createRotationalVector(10f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(2.1676665f, AnimationHelper.createRotationalVector(2.2307925039942713f, -0.21576122102964312f, -7.927957140726775f), Transformation.Interpolations.CUBIC), - new Keyframe(2.4167665f, AnimationHelper.createRotationalVector(4.294867444937954f, 2.2606154253199566f, -6.0592613319625706f), Transformation.Interpolations.CUBIC), - new Keyframe(2.625f, AnimationHelper.createRotationalVector(1.7645231481382142f, 1.1309400733304573f, 0.14523321293696423f), Transformation.Interpolations.CUBIC), - new Keyframe(2.875f, AnimationHelper.createRotationalVector(6.178001369910271f, -0.19388043339675276f, 5.467675351455965f), Transformation.Interpolations.CUBIC), - new Keyframe(3.5f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.HEAD, new Transformation(Transformation.Targets.MOVE_ORIGIN, - new Keyframe(0f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(0.16766666f, AnimationHelper.createTranslationalVector(0f, -1f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(1.75f, AnimationHelper.createTranslationalVector(0f, -1f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(2.9167665f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.HEAD, new Transformation(Transformation.Targets.ROTATE, - new Keyframe(0f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(0.16766666f, AnimationHelper.createRotationalVector(2.5f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(1.75f, AnimationHelper.createRotationalVector(2.5f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(2.0834335f, AnimationHelper.createRotationalVector(49.89121214627585f, -3.3756177280956763f, 3.6906601938271706f), Transformation.Interpolations.CUBIC), - new Keyframe(2.375f, AnimationHelper.createRotationalVector(62.26769532549997f, 10.515127085314361f, 31.44641266227063f), Transformation.Interpolations.CUBIC), - new Keyframe(2.7083435f, AnimationHelper.createRotationalVector(62.54663949450434f, -8.432200276274816f, -49.78158893940414f), Transformation.Interpolations.CUBIC), - new Keyframe(3f, AnimationHelper.createRotationalVector(58.19080366360111f, 20.578159182988493f, 18.790040178069503f), Transformation.Interpolations.CUBIC), - new Keyframe(3.2083435f, AnimationHelper.createRotationalVector(34.363668641116874f, 11.307647518170633f, 12.797722379234328f), Transformation.Interpolations.CUBIC), - new Keyframe(3.5f, AnimationHelper.createRotationalVector(-7.379261962134369f, 2.46597558997084f, 2.922121806087871f), Transformation.Interpolations.CUBIC), - new Keyframe(3.7916765f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))).build(); + public static final AnimationDefinition FART = AnimationDefinition.Builder.withLength(3.8343335f) + .addAnimation(PartNames.ROOT, new AnimationChannel(AnimationChannel.Targets.POSITION, + new Keyframe(0f, KeyframeAnimations.posVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.08343333f, KeyframeAnimations.posVec(0f, 5f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.16766666f, KeyframeAnimations.posVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM))) + .addAnimation(PartNames.ROOT, new AnimationChannel(AnimationChannel.Targets.SCALE, + new Keyframe(0f, KeyframeAnimations.scaleVec(1f, 1f, 1f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.08343333f, KeyframeAnimations.scaleVec(1f, 1.2f, 1f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.16766666f, KeyframeAnimations.scaleVec(1f, 1f, 1f), AnimationChannel.Interpolations.CATMULLROM))) + .addAnimation(PartNames.RIGHT_FRONT_LEG, new AnimationChannel(AnimationChannel.Targets.POSITION, + new Keyframe(0f, KeyframeAnimations.posVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.16766666f, KeyframeAnimations.posVec(1f, 0f, 0f), AnimationChannel.Interpolations.LINEAR), + new Keyframe(1.75f, KeyframeAnimations.posVec(1f, 0f, 0f), AnimationChannel.Interpolations.LINEAR), + new Keyframe(2.0416765f, KeyframeAnimations.posVec(0.63f, 1f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(2.375f, KeyframeAnimations.posVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM))) + .addAnimation(PartNames.RIGHT_FRONT_LEG, new AnimationChannel(AnimationChannel.Targets.ROTATION, + new Keyframe(0f, KeyframeAnimations.degreeVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.16766666f, KeyframeAnimations.degreeVec(-7.5f, 0f, -17.5f), AnimationChannel.Interpolations.LINEAR), + new Keyframe(1.75f, KeyframeAnimations.degreeVec(-7.5f, 0f, -17.5f), AnimationChannel.Interpolations.LINEAR), + new Keyframe(2.1676665f, KeyframeAnimations.degreeVec(0.2727354654598457f, 0.4131058282196136f, -6.089277436131233f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(2.5f, KeyframeAnimations.degreeVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM))) + .addAnimation(PartNames.LEFT_FRONT_LEG, new AnimationChannel(AnimationChannel.Targets.POSITION, + new Keyframe(0f, KeyframeAnimations.posVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.16766666f, KeyframeAnimations.posVec(-1f, 0f, 0f), AnimationChannel.Interpolations.LINEAR), + new Keyframe(1.75f, KeyframeAnimations.posVec(-1f, 0f, 0f), AnimationChannel.Interpolations.LINEAR), + new Keyframe(2.375f, KeyframeAnimations.posVec(-1f, 0f, 0f), AnimationChannel.Interpolations.LINEAR), + new Keyframe(2.7083435f, KeyframeAnimations.posVec(-0.12f, 1f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(3.0416765f, KeyframeAnimations.posVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM))) + .addAnimation(PartNames.LEFT_FRONT_LEG, new AnimationChannel(AnimationChannel.Targets.ROTATION, + new Keyframe(0f, KeyframeAnimations.degreeVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.16766666f, KeyframeAnimations.degreeVec(-7.5f, 0f, 17.5f), AnimationChannel.Interpolations.LINEAR), + new Keyframe(1.75f, KeyframeAnimations.degreeVec(-7.5f, 0f, 17.5f), AnimationChannel.Interpolations.LINEAR), + new Keyframe(2.375f, KeyframeAnimations.degreeVec(-7.5f, 0f, 17.5f), AnimationChannel.Interpolations.LINEAR), + new Keyframe(2.7916765f, KeyframeAnimations.degreeVec(-5.111516362223829f, -0.446597721821945f, 6.992121938251076f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(3.0416765f, KeyframeAnimations.degreeVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM))) + .addAnimation(PartNames.RIGHT_HIND_LEG, new AnimationChannel(AnimationChannel.Targets.POSITION, + new Keyframe(0f, KeyframeAnimations.posVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.16766666f, KeyframeAnimations.posVec(1f, 0f, 0f), AnimationChannel.Interpolations.LINEAR), + new Keyframe(1.75f, KeyframeAnimations.posVec(1f, 0f, 0f), AnimationChannel.Interpolations.LINEAR), + new Keyframe(2.2083435f, KeyframeAnimations.posVec(1f, 0f, 0f), AnimationChannel.Interpolations.LINEAR), + new Keyframe(2.5f, KeyframeAnimations.posVec(0.63f, 1f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(2.8343335f, KeyframeAnimations.posVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM))) + .addAnimation(PartNames.RIGHT_HIND_LEG, new AnimationChannel(AnimationChannel.Targets.ROTATION, + new Keyframe(0f, KeyframeAnimations.degreeVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.16766666f, KeyframeAnimations.degreeVec(0f, 0f, -17.5f), AnimationChannel.Interpolations.LINEAR), + new Keyframe(1.75f, KeyframeAnimations.degreeVec(0f, 0f, -17.5f), AnimationChannel.Interpolations.LINEAR), + new Keyframe(2.2083435f, KeyframeAnimations.degreeVec(0f, 0f, -17.5f), AnimationChannel.Interpolations.LINEAR), + new Keyframe(2.625f, KeyframeAnimations.degreeVec(0.2727354654598457f, 0.4131058282196136f, -6.089277436131233f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(2.9583435f, KeyframeAnimations.degreeVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM))) + .addAnimation(PartNames.LEFT_HIND_LEG, new AnimationChannel(AnimationChannel.Targets.POSITION, + new Keyframe(0f, KeyframeAnimations.posVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.16766666f, KeyframeAnimations.posVec(-1f, 0f, 0f), AnimationChannel.Interpolations.LINEAR), + new Keyframe(1.75f, KeyframeAnimations.posVec(-1f, 0f, 0f), AnimationChannel.Interpolations.LINEAR), + new Keyframe(2.8343335f, KeyframeAnimations.posVec(-1f, 0f, 0f), AnimationChannel.Interpolations.LINEAR), + new Keyframe(3.1676665f, KeyframeAnimations.posVec(-0.12f, 1f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(3.5f, KeyframeAnimations.posVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM))) + .addAnimation(PartNames.LEFT_HIND_LEG, new AnimationChannel(AnimationChannel.Targets.ROTATION, + new Keyframe(0f, KeyframeAnimations.degreeVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.16766666f, KeyframeAnimations.degreeVec(0f, 0f, 17.5f), AnimationChannel.Interpolations.LINEAR), + new Keyframe(1.75f, KeyframeAnimations.degreeVec(0f, 0f, 17.5f), AnimationChannel.Interpolations.LINEAR), + new Keyframe(2.8343335f, KeyframeAnimations.degreeVec(0f, 0f, 17.5f), AnimationChannel.Interpolations.LINEAR), + new Keyframe(3.25f, KeyframeAnimations.degreeVec(-5.111516362223829f, -0.446597721821945f, 6.992121938251076f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(3.5f, KeyframeAnimations.degreeVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM))) + .addAnimation(PartNames.BODY, new AnimationChannel(AnimationChannel.Targets.ROTATION, + new Keyframe(0f, KeyframeAnimations.degreeVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.16766666f, KeyframeAnimations.degreeVec(10f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.75f, KeyframeAnimations.degreeVec(10f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(2.1676665f, KeyframeAnimations.degreeVec(2.2307925039942713f, -0.21576122102964312f, -7.927957140726775f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(2.4167665f, KeyframeAnimations.degreeVec(4.294867444937954f, 2.2606154253199566f, -6.0592613319625706f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(2.625f, KeyframeAnimations.degreeVec(1.7645231481382142f, 1.1309400733304573f, 0.14523321293696423f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(2.875f, KeyframeAnimations.degreeVec(6.178001369910271f, -0.19388043339675276f, 5.467675351455965f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(3.5f, KeyframeAnimations.degreeVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM))) + .addAnimation(PartNames.HEAD, new AnimationChannel(AnimationChannel.Targets.POSITION, + new Keyframe(0f, KeyframeAnimations.posVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.16766666f, KeyframeAnimations.posVec(0f, -1f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.75f, KeyframeAnimations.posVec(0f, -1f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(2.9167665f, KeyframeAnimations.posVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM))) + .addAnimation(PartNames.HEAD, new AnimationChannel(AnimationChannel.Targets.ROTATION, + new Keyframe(0f, KeyframeAnimations.degreeVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.16766666f, KeyframeAnimations.degreeVec(2.5f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.75f, KeyframeAnimations.degreeVec(2.5f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(2.0834335f, KeyframeAnimations.degreeVec(49.89121214627585f, -3.3756177280956763f, 3.6906601938271706f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(2.375f, KeyframeAnimations.degreeVec(62.26769532549997f, 10.515127085314361f, 31.44641266227063f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(2.7083435f, KeyframeAnimations.degreeVec(62.54663949450434f, -8.432200276274816f, -49.78158893940414f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(3f, KeyframeAnimations.degreeVec(58.19080366360111f, 20.578159182988493f, 18.790040178069503f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(3.2083435f, KeyframeAnimations.degreeVec(34.363668641116874f, 11.307647518170633f, 12.797722379234328f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(3.5f, KeyframeAnimations.degreeVec(-7.379261962134369f, 2.46597558997084f, 2.922121806087871f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(3.7916765f, KeyframeAnimations.degreeVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM))).build(); - public static final AnimationDefinition WAKE_UP = AnimationDefinition.Builder.create(5.791677f) - .addBoneAnimation(EntityModelPartNames.ROOT, new Transformation(Transformation.Targets.MOVE_ORIGIN, - new Keyframe(0f, AnimationHelper.createTranslationalVector(-12f, -5f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(2.9583435f, AnimationHelper.createTranslationalVector(-12f, -5f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(3.125f, AnimationHelper.createTranslationalVector(-12f, -5f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(3.7083435f, AnimationHelper.createTranslationalVector(-14f, -5f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(4.375f, AnimationHelper.createTranslationalVector(-9f, -3f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(4.75f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(5f, AnimationHelper.createTranslationalVector(1f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(5.291677f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.ROOT, new Transformation(Transformation.Targets.ROTATE, - new Keyframe(0f, AnimationHelper.createRotationalVector(0f, 0f, -90f), Transformation.Interpolations.CUBIC), - new Keyframe(2.9583435f, AnimationHelper.createRotationalVector(0f, 0f, -90f), Transformation.Interpolations.CUBIC), - new Keyframe(3.125f, AnimationHelper.createRotationalVector(0f, 0f, -92.5f), Transformation.Interpolations.CUBIC), - new Keyframe(3.7083435f, AnimationHelper.createRotationalVector(0f, 0f, -117.5f), Transformation.Interpolations.CUBIC), - new Keyframe(4.375f, AnimationHelper.createRotationalVector(0f, 0f, -70f), Transformation.Interpolations.CUBIC), - new Keyframe(4.75f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(5f, AnimationHelper.createRotationalVector(0f, 0f, 7.5f), Transformation.Interpolations.CUBIC), - new Keyframe(5.291677f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.RIGHT_FRONT_LEG, new Transformation(Transformation.Targets.MOVE_ORIGIN, - new Keyframe(0f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(1.25f, AnimationHelper.createTranslationalVector(0.75f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(1.875f, AnimationHelper.createTranslationalVector(0.75f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(5f, AnimationHelper.createTranslationalVector(1f, 0.25f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(5.125f, AnimationHelper.createTranslationalVector(0.75f, 1f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(5.291677f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.RIGHT_FRONT_LEG, new Transformation(Transformation.Targets.ROTATE, - new Keyframe(0f, AnimationHelper.createRotationalVector(-7.5f, 0f, 17.5f), Transformation.Interpolations.CUBIC), - new Keyframe(1.25f, AnimationHelper.createRotationalVector(-7.4086946559950775f, 1.1699920891774127f, 26.424248239231474f), Transformation.Interpolations.CUBIC), - new Keyframe(1.75f, AnimationHelper.createRotationalVector(-7.4086946559950775f, 1.1699920891774127f, 26.424248239231474f), Transformation.Interpolations.CUBIC), - new Keyframe(1.875f, AnimationHelper.createRotationalVector(-7.366127295935403f, -1.4184144280073452f, 6.660634475402492f), Transformation.Interpolations.CUBIC), - new Keyframe(1.9583433f, AnimationHelper.createRotationalVector(-7.408694655995223f, 1.1699920891777946f, 26.424248239231403f), Transformation.Interpolations.CUBIC), - new Keyframe(2.0416765f, AnimationHelper.createRotationalVector(-7.49745918025943f, 0.19576730469809256f, 18.98717307987583f), Transformation.Interpolations.CUBIC), - new Keyframe(2.2083435f, AnimationHelper.createRotationalVector(-7.4086946559950775f, 1.1699920891780493f, 26.42424823923169f), Transformation.Interpolations.CUBIC), - new Keyframe(3.125f, AnimationHelper.createRotationalVector(-7.4086946559950775f, 1.1699920891780493f, 26.42424823923169f), Transformation.Interpolations.CUBIC), - new Keyframe(3.7083435f, AnimationHelper.createRotationalVector(-6.041112393472904f, 4.452922991257692f, 53.76491217464347f), Transformation.Interpolations.CUBIC), - new Keyframe(4.375f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(5f, AnimationHelper.createRotationalVector(0.24117231125816033f, -0.09448572501914895f, -16.85553579291023f), Transformation.Interpolations.CUBIC), - new Keyframe(5.291677f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.LEFT_FRONT_LEG, new Transformation(Transformation.Targets.MOVE_ORIGIN, - new Keyframe(3.125f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(3.5416765f, AnimationHelper.createTranslationalVector(-1f, -0.75f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(4.125f, AnimationHelper.createTranslationalVector(-0.78f, 0.42000000000000004f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(5.291677f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.LEFT_FRONT_LEG, new Transformation(Transformation.Targets.ROTATE, - new Keyframe(0f, AnimationHelper.createRotationalVector(-20f, 0f, 5f), Transformation.Interpolations.CUBIC), - new Keyframe(2.9583435f, AnimationHelper.createRotationalVector(-20f, 0f, 5f), Transformation.Interpolations.CUBIC), - new Keyframe(3.125f, AnimationHelper.createRotationalVector(-20f, 0f, 5f), Transformation.Interpolations.CUBIC), - new Keyframe(3.5416765f, AnimationHelper.createRotationalVector(-12.279770389181849f, 12.007062843212225f, 47.98109178875055f), Transformation.Interpolations.CUBIC), - new Keyframe(5.291677f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.LEFT_FRONT_LEG, new Transformation(Transformation.Targets.SCALE, - new Keyframe(3.5416765f, AnimationHelper.createScalingVector(1f, 1f, 1f), Transformation.Interpolations.CUBIC), - new Keyframe(3.9583435f, AnimationHelper.createScalingVector(1f, 0.6f, 1f), Transformation.Interpolations.CUBIC), - new Keyframe(4.583433f, AnimationHelper.createScalingVector(1f, 0.6f, 1f), Transformation.Interpolations.CUBIC), - new Keyframe(4.75f, AnimationHelper.createScalingVector(1f, 1f, 1f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.RIGHT_HIND_LEG, new Transformation(Transformation.Targets.MOVE_ORIGIN, - new Keyframe(0f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(1.25f, AnimationHelper.createTranslationalVector(1f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(1.875f, AnimationHelper.createTranslationalVector(1f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(4.834333f, AnimationHelper.createTranslationalVector(1f, 0.25f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(4.958343f, AnimationHelper.createTranslationalVector(0.75f, 1f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(5.125f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.RIGHT_HIND_LEG, new Transformation(Transformation.Targets.ROTATE, - new Keyframe(0f, AnimationHelper.createRotationalVector(22.48071702609377f, 0.9564494572955482f, 20.190086556017377f), Transformation.Interpolations.CUBIC), - new Keyframe(1.25f, AnimationHelper.createRotationalVector(22.30257854223737f, -3.0529741491914137f, 29.898054778260757f), Transformation.Interpolations.CUBIC), - new Keyframe(1.75f, AnimationHelper.createRotationalVector(20.091305344004923f, 1.1699920891774127f, 26.424248239231474f), Transformation.Interpolations.CUBIC), - new Keyframe(1.875f, AnimationHelper.createRotationalVector(-4.866127295935403f, -1.4184144280073452f, 6.660634475402492f), Transformation.Interpolations.CUBIC), - new Keyframe(1.9583433f, AnimationHelper.createRotationalVector(-7.408694655995223f, 1.1699920891777946f, 26.424248239231403f), Transformation.Interpolations.CUBIC), - new Keyframe(2.0416765f, AnimationHelper.createRotationalVector(-7.49745918025943f, 0.19576730469809256f, 18.98717307987583f), Transformation.Interpolations.CUBIC), - new Keyframe(2.2083435f, AnimationHelper.createRotationalVector(-7.4086946559950775f, 1.1699920891780493f, 26.42424823923169f), Transformation.Interpolations.CUBIC), - new Keyframe(2.9583435f, AnimationHelper.createRotationalVector(-7.4086946559950775f, 1.1699920891780493f, 26.42424823923169f), Transformation.Interpolations.CUBIC), - new Keyframe(3.5416765f, AnimationHelper.createRotationalVector(-6.041112393472904f, 4.452922991257692f, 53.76491217464347f), Transformation.Interpolations.CUBIC), - new Keyframe(4.208343f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(4.834333f, AnimationHelper.createRotationalVector(0.24117231125816033f, -0.09448572501914895f, -16.85553579291023f), Transformation.Interpolations.CUBIC), - new Keyframe(5.125f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.LEFT_HIND_LEG, new Transformation(Transformation.Targets.MOVE_ORIGIN, - new Keyframe(0f, AnimationHelper.createTranslationalVector(-1f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(2.9583435f, AnimationHelper.createTranslationalVector(-1f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(3.2083435f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(3.625f, AnimationHelper.createTranslationalVector(-1f, -0.75f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(4.208343f, AnimationHelper.createTranslationalVector(-0.78f, 0.42000000000000004f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(5.375f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.LEFT_HIND_LEG, new Transformation(Transformation.Targets.ROTATE, - new Keyframe(0f, AnimationHelper.createRotationalVector(27.5f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(1.75f, AnimationHelper.createRotationalVector(27.5f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(1.875f, AnimationHelper.createRotationalVector(7.14232996078681f, 4.599015978825719f, -8.889268973502567f), Transformation.Interpolations.CUBIC), - new Keyframe(1.9583433f, AnimationHelper.createRotationalVector(-2.475429931501239f, 4.3960867006031545f, -3.8970580610586154f), Transformation.Interpolations.CUBIC), - new Keyframe(2.9583435f, AnimationHelper.createRotationalVector(-2.475429931501239f, 4.3960867006031545f, -3.8970580610586154f), Transformation.Interpolations.CUBIC), - new Keyframe(3.2083435f, AnimationHelper.createRotationalVector(-2.475429931501239f, 4.3960867006031545f, -3.8970580610586154f), Transformation.Interpolations.CUBIC), - new Keyframe(3.625f, AnimationHelper.createRotationalVector(-12.279770389181849f, 12.007062843212225f, 47.98109178875055f), Transformation.Interpolations.CUBIC), - new Keyframe(5.375f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.LEFT_HIND_LEG, new Transformation(Transformation.Targets.SCALE, - new Keyframe(3.625f, AnimationHelper.createScalingVector(1f, 1f, 1f), Transformation.Interpolations.CUBIC), - new Keyframe(4.041677f, AnimationHelper.createScalingVector(1f, 0.6f, 1f), Transformation.Interpolations.CUBIC), - new Keyframe(4.583433f, AnimationHelper.createScalingVector(1f, 0.6f, 1f), Transformation.Interpolations.CUBIC), - new Keyframe(4.75f, AnimationHelper.createScalingVector(1f, 1f, 1f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.BODY, new Transformation(Transformation.Targets.MOVE_ORIGIN, - new Keyframe(0f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(1.25f, AnimationHelper.createTranslationalVector(0.25f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(1.875f, AnimationHelper.createTranslationalVector(0.25f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(3.125f, AnimationHelper.createTranslationalVector(0.25f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(3.5416765f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.BODY, new Transformation(Transformation.Targets.SCALE, - new Keyframe(0f, AnimationHelper.createScalingVector(1f, 1f, 1f), Transformation.Interpolations.CUBIC), - new Keyframe(1.25f, AnimationHelper.createScalingVector(1.1f, 1f, 1f), Transformation.Interpolations.CUBIC), - new Keyframe(1.875f, AnimationHelper.createScalingVector(1f, 1f, 1f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.HEAD, new Transformation(Transformation.Targets.MOVE_ORIGIN, - new Keyframe(0f, AnimationHelper.createTranslationalVector(-1f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(0.5f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(0.9583434f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(1.7083433f, AnimationHelper.createTranslationalVector(-1f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(1.875f, AnimationHelper.createTranslationalVector(1.25f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(3.2916765f, AnimationHelper.createTranslationalVector(1.25f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(3.625f, AnimationHelper.createTranslationalVector(0.25f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.HEAD, new Transformation(Transformation.Targets.ROTATE, - new Keyframe(0f, AnimationHelper.createRotationalVector(0f, 0f, -5f), Transformation.Interpolations.CUBIC), - new Keyframe(0.5f, AnimationHelper.createRotationalVector(0f, 0f, 20f), Transformation.Interpolations.CUBIC), - new Keyframe(0.9583434f, AnimationHelper.createRotationalVector(0f, 0f, 20f), Transformation.Interpolations.CUBIC), - new Keyframe(1.7083433f, AnimationHelper.createRotationalVector(0f, 0f, -5f), Transformation.Interpolations.CUBIC), - new Keyframe(1.875f, AnimationHelper.createRotationalVector(0f, 0f, 57.5f), Transformation.Interpolations.CUBIC), - new Keyframe(3.0834335f, AnimationHelper.createRotationalVector(0f, 0f, 57.5f), Transformation.Interpolations.CUBIC), - new Keyframe(3.2916765f, AnimationHelper.createRotationalVector(17.5f, 0f, 57.5f), Transformation.Interpolations.CUBIC), - new Keyframe(3.625f, AnimationHelper.createRotationalVector(16.14973182841186f, 6.279671924441573f, 33.25231220461228f), Transformation.Interpolations.CUBIC), - new Keyframe(4f, AnimationHelper.createRotationalVector(11.23738518791506f, 12.240295486395354f, 3.4386635769687928f), Transformation.Interpolations.CUBIC), - new Keyframe(4.25f, AnimationHelper.createRotationalVector(7.106591348469683f, 14.290604655089956f, -14.422213143878762f), Transformation.Interpolations.CUBIC), - new Keyframe(4.676667f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(5f, AnimationHelper.createRotationalVector(0f, 0f, 15f), Transformation.Interpolations.CUBIC), - new Keyframe(5.291677f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))).build(); + public static final AnimationDefinition WAKE_UP = AnimationDefinition.Builder.withLength(5.791677f) + .addAnimation(PartNames.ROOT, new AnimationChannel(AnimationChannel.Targets.POSITION, + new Keyframe(0f, KeyframeAnimations.posVec(-12f, -5f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(2.9583435f, KeyframeAnimations.posVec(-12f, -5f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(3.125f, KeyframeAnimations.posVec(-12f, -5f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(3.7083435f, KeyframeAnimations.posVec(-14f, -5f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(4.375f, KeyframeAnimations.posVec(-9f, -3f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(4.75f, KeyframeAnimations.posVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(5f, KeyframeAnimations.posVec(1f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(5.291677f, KeyframeAnimations.posVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM))) + .addAnimation(PartNames.ROOT, new AnimationChannel(AnimationChannel.Targets.ROTATION, + new Keyframe(0f, KeyframeAnimations.degreeVec(0f, 0f, -90f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(2.9583435f, KeyframeAnimations.degreeVec(0f, 0f, -90f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(3.125f, KeyframeAnimations.degreeVec(0f, 0f, -92.5f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(3.7083435f, KeyframeAnimations.degreeVec(0f, 0f, -117.5f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(4.375f, KeyframeAnimations.degreeVec(0f, 0f, -70f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(4.75f, KeyframeAnimations.degreeVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(5f, KeyframeAnimations.degreeVec(0f, 0f, 7.5f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(5.291677f, KeyframeAnimations.degreeVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM))) + .addAnimation(PartNames.RIGHT_FRONT_LEG, new AnimationChannel(AnimationChannel.Targets.POSITION, + new Keyframe(0f, KeyframeAnimations.posVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.25f, KeyframeAnimations.posVec(0.75f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.875f, KeyframeAnimations.posVec(0.75f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(5f, KeyframeAnimations.posVec(1f, 0.25f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(5.125f, KeyframeAnimations.posVec(0.75f, 1f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(5.291677f, KeyframeAnimations.posVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM))) + .addAnimation(PartNames.RIGHT_FRONT_LEG, new AnimationChannel(AnimationChannel.Targets.ROTATION, + new Keyframe(0f, KeyframeAnimations.degreeVec(-7.5f, 0f, 17.5f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.25f, KeyframeAnimations.degreeVec(-7.4086946559950775f, 1.1699920891774127f, 26.424248239231474f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.75f, KeyframeAnimations.degreeVec(-7.4086946559950775f, 1.1699920891774127f, 26.424248239231474f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.875f, KeyframeAnimations.degreeVec(-7.366127295935403f, -1.4184144280073452f, 6.660634475402492f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.9583433f, KeyframeAnimations.degreeVec(-7.408694655995223f, 1.1699920891777946f, 26.424248239231403f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(2.0416765f, KeyframeAnimations.degreeVec(-7.49745918025943f, 0.19576730469809256f, 18.98717307987583f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(2.2083435f, KeyframeAnimations.degreeVec(-7.4086946559950775f, 1.1699920891780493f, 26.42424823923169f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(3.125f, KeyframeAnimations.degreeVec(-7.4086946559950775f, 1.1699920891780493f, 26.42424823923169f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(3.7083435f, KeyframeAnimations.degreeVec(-6.041112393472904f, 4.452922991257692f, 53.76491217464347f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(4.375f, KeyframeAnimations.degreeVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(5f, KeyframeAnimations.degreeVec(0.24117231125816033f, -0.09448572501914895f, -16.85553579291023f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(5.291677f, KeyframeAnimations.degreeVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM))) + .addAnimation(PartNames.LEFT_FRONT_LEG, new AnimationChannel(AnimationChannel.Targets.POSITION, + new Keyframe(3.125f, KeyframeAnimations.posVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(3.5416765f, KeyframeAnimations.posVec(-1f, -0.75f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(4.125f, KeyframeAnimations.posVec(-0.78f, 0.42000000000000004f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(5.291677f, KeyframeAnimations.posVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM))) + .addAnimation(PartNames.LEFT_FRONT_LEG, new AnimationChannel(AnimationChannel.Targets.ROTATION, + new Keyframe(0f, KeyframeAnimations.degreeVec(-20f, 0f, 5f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(2.9583435f, KeyframeAnimations.degreeVec(-20f, 0f, 5f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(3.125f, KeyframeAnimations.degreeVec(-20f, 0f, 5f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(3.5416765f, KeyframeAnimations.degreeVec(-12.279770389181849f, 12.007062843212225f, 47.98109178875055f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(5.291677f, KeyframeAnimations.degreeVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM))) + .addAnimation(PartNames.LEFT_FRONT_LEG, new AnimationChannel(AnimationChannel.Targets.SCALE, + new Keyframe(3.5416765f, KeyframeAnimations.scaleVec(1f, 1f, 1f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(3.9583435f, KeyframeAnimations.scaleVec(1f, 0.6f, 1f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(4.583433f, KeyframeAnimations.scaleVec(1f, 0.6f, 1f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(4.75f, KeyframeAnimations.scaleVec(1f, 1f, 1f), AnimationChannel.Interpolations.CATMULLROM))) + .addAnimation(PartNames.RIGHT_HIND_LEG, new AnimationChannel(AnimationChannel.Targets.POSITION, + new Keyframe(0f, KeyframeAnimations.posVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.25f, KeyframeAnimations.posVec(1f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.875f, KeyframeAnimations.posVec(1f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(4.834333f, KeyframeAnimations.posVec(1f, 0.25f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(4.958343f, KeyframeAnimations.posVec(0.75f, 1f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(5.125f, KeyframeAnimations.posVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM))) + .addAnimation(PartNames.RIGHT_HIND_LEG, new AnimationChannel(AnimationChannel.Targets.ROTATION, + new Keyframe(0f, KeyframeAnimations.degreeVec(22.48071702609377f, 0.9564494572955482f, 20.190086556017377f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.25f, KeyframeAnimations.degreeVec(22.30257854223737f, -3.0529741491914137f, 29.898054778260757f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.75f, KeyframeAnimations.degreeVec(20.091305344004923f, 1.1699920891774127f, 26.424248239231474f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.875f, KeyframeAnimations.degreeVec(-4.866127295935403f, -1.4184144280073452f, 6.660634475402492f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.9583433f, KeyframeAnimations.degreeVec(-7.408694655995223f, 1.1699920891777946f, 26.424248239231403f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(2.0416765f, KeyframeAnimations.degreeVec(-7.49745918025943f, 0.19576730469809256f, 18.98717307987583f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(2.2083435f, KeyframeAnimations.degreeVec(-7.4086946559950775f, 1.1699920891780493f, 26.42424823923169f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(2.9583435f, KeyframeAnimations.degreeVec(-7.4086946559950775f, 1.1699920891780493f, 26.42424823923169f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(3.5416765f, KeyframeAnimations.degreeVec(-6.041112393472904f, 4.452922991257692f, 53.76491217464347f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(4.208343f, KeyframeAnimations.degreeVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(4.834333f, KeyframeAnimations.degreeVec(0.24117231125816033f, -0.09448572501914895f, -16.85553579291023f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(5.125f, KeyframeAnimations.degreeVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM))) + .addAnimation(PartNames.LEFT_HIND_LEG, new AnimationChannel(AnimationChannel.Targets.POSITION, + new Keyframe(0f, KeyframeAnimations.posVec(-1f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(2.9583435f, KeyframeAnimations.posVec(-1f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(3.2083435f, KeyframeAnimations.posVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(3.625f, KeyframeAnimations.posVec(-1f, -0.75f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(4.208343f, KeyframeAnimations.posVec(-0.78f, 0.42000000000000004f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(5.375f, KeyframeAnimations.posVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM))) + .addAnimation(PartNames.LEFT_HIND_LEG, new AnimationChannel(AnimationChannel.Targets.ROTATION, + new Keyframe(0f, KeyframeAnimations.degreeVec(27.5f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.75f, KeyframeAnimations.degreeVec(27.5f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.875f, KeyframeAnimations.degreeVec(7.14232996078681f, 4.599015978825719f, -8.889268973502567f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.9583433f, KeyframeAnimations.degreeVec(-2.475429931501239f, 4.3960867006031545f, -3.8970580610586154f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(2.9583435f, KeyframeAnimations.degreeVec(-2.475429931501239f, 4.3960867006031545f, -3.8970580610586154f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(3.2083435f, KeyframeAnimations.degreeVec(-2.475429931501239f, 4.3960867006031545f, -3.8970580610586154f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(3.625f, KeyframeAnimations.degreeVec(-12.279770389181849f, 12.007062843212225f, 47.98109178875055f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(5.375f, KeyframeAnimations.degreeVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM))) + .addAnimation(PartNames.LEFT_HIND_LEG, new AnimationChannel(AnimationChannel.Targets.SCALE, + new Keyframe(3.625f, KeyframeAnimations.scaleVec(1f, 1f, 1f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(4.041677f, KeyframeAnimations.scaleVec(1f, 0.6f, 1f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(4.583433f, KeyframeAnimations.scaleVec(1f, 0.6f, 1f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(4.75f, KeyframeAnimations.scaleVec(1f, 1f, 1f), AnimationChannel.Interpolations.CATMULLROM))) + .addAnimation(PartNames.BODY, new AnimationChannel(AnimationChannel.Targets.POSITION, + new Keyframe(0f, KeyframeAnimations.posVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.25f, KeyframeAnimations.posVec(0.25f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.875f, KeyframeAnimations.posVec(0.25f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(3.125f, KeyframeAnimations.posVec(0.25f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(3.5416765f, KeyframeAnimations.posVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM))) + .addAnimation(PartNames.BODY, new AnimationChannel(AnimationChannel.Targets.SCALE, + new Keyframe(0f, KeyframeAnimations.scaleVec(1f, 1f, 1f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.25f, KeyframeAnimations.scaleVec(1.1f, 1f, 1f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.875f, KeyframeAnimations.scaleVec(1f, 1f, 1f), AnimationChannel.Interpolations.CATMULLROM))) + .addAnimation(PartNames.HEAD, new AnimationChannel(AnimationChannel.Targets.POSITION, + new Keyframe(0f, KeyframeAnimations.posVec(-1f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.5f, KeyframeAnimations.posVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.9583434f, KeyframeAnimations.posVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.7083433f, KeyframeAnimations.posVec(-1f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.875f, KeyframeAnimations.posVec(1.25f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(3.2916765f, KeyframeAnimations.posVec(1.25f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(3.625f, KeyframeAnimations.posVec(0.25f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM))) + .addAnimation(PartNames.HEAD, new AnimationChannel(AnimationChannel.Targets.ROTATION, + new Keyframe(0f, KeyframeAnimations.degreeVec(0f, 0f, -5f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.5f, KeyframeAnimations.degreeVec(0f, 0f, 20f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(0.9583434f, KeyframeAnimations.degreeVec(0f, 0f, 20f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.7083433f, KeyframeAnimations.degreeVec(0f, 0f, -5f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(1.875f, KeyframeAnimations.degreeVec(0f, 0f, 57.5f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(3.0834335f, KeyframeAnimations.degreeVec(0f, 0f, 57.5f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(3.2916765f, KeyframeAnimations.degreeVec(17.5f, 0f, 57.5f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(3.625f, KeyframeAnimations.degreeVec(16.14973182841186f, 6.279671924441573f, 33.25231220461228f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(4f, KeyframeAnimations.degreeVec(11.23738518791506f, 12.240295486395354f, 3.4386635769687928f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(4.25f, KeyframeAnimations.degreeVec(7.106591348469683f, 14.290604655089956f, -14.422213143878762f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(4.676667f, KeyframeAnimations.degreeVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(5f, KeyframeAnimations.degreeVec(0f, 0f, 15f), AnimationChannel.Interpolations.CATMULLROM), + new Keyframe(5.291677f, KeyframeAnimations.degreeVec(0f, 0f, 0f), AnimationChannel.Interpolations.CATMULLROM))).build(); } diff --git a/src/client/java/fr/hugman/promenade/client/render/entity/model/CapybaraEntityModel.java b/src/client/java/fr/hugman/promenade/client/render/entity/model/CapybaraEntityModel.java deleted file mode 100644 index bf087630..00000000 --- a/src/client/java/fr/hugman/promenade/client/render/entity/model/CapybaraEntityModel.java +++ /dev/null @@ -1,88 +0,0 @@ -package fr.hugman.promenade.client.render.entity.model; - -import fr.hugman.promenade.client.render.entity.animation.CapybaraAnimations; -import fr.hugman.promenade.client.render.entity.state.CapybaraEntityRenderState; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -import net.minecraft.client.model.*; -import net.minecraft.client.render.entity.animation.Animation; -import net.minecraft.client.render.entity.model.BabyModelTransformer; -import net.minecraft.client.render.entity.model.EntityModel; -import net.minecraft.client.render.entity.model.EntityModelPartNames; -import net.minecraft.client.render.entity.model.ModelTransformer; - -import java.util.Set; - -@Environment(EnvType.CLIENT) -public class CapybaraEntityModel extends EntityModel { - private static final String LOWER_TEETH = "lower_teeth"; - private static final String UPPER_TEETH = "upper_teeth"; - - private final ModelPart head; - - private final Animation walkingAnimation; - private final Animation earWiggleAnimation; - private final Animation fallToSleepAnimation; - private final Animation sleepingAnimation; - private final Animation wakeUpAnimation; - private final Animation fartAnimation; - - public static final ModelTransformer BABY_TRANSFORMER = new BabyModelTransformer(false, 1.00F, 0.6F, Set.of(EntityModelPartNames.HEAD)); - - public CapybaraEntityModel(ModelPart part) { - super(part.getChild(EntityModelPartNames.ROOT)); - this.head = this.root.getChild(EntityModelPartNames.HEAD); - this.walkingAnimation = CapybaraAnimations.WALKING.createAnimation(this.root); - this.earWiggleAnimation = CapybaraAnimations.EAR_WIGGLE.createAnimation(this.root); - this.fallToSleepAnimation = CapybaraAnimations.FALL_TO_SLEEP.createAnimation(this.root); - this.sleepingAnimation = CapybaraAnimations.SLEEP.createAnimation(this.root); - this.wakeUpAnimation = CapybaraAnimations.WAKE_UP.createAnimation(this.root); - this.fartAnimation = CapybaraAnimations.FART.createAnimation(this.root); - } - - public static TexturedModelData getTexturedModelData() { - ModelData modelData = new ModelData(); - ModelPartData modelPartData = modelData.getRoot(); - ModelPartData root = modelPartData.addChild(EntityModelPartNames.ROOT, ModelPartBuilder.create(), ModelTransform.origin(0.5F, 14.5F, 0.5F)); - - root.addChild(EntityModelPartNames.RIGHT_HIND_LEG, ModelPartBuilder.create().uv(31, 0).cuboid(-1.5F, 0.0F, -0.5F, 3.0F, 7.0F, 3.0F), ModelTransform.origin(1.5F, 2.5F, 5.5F)); - root.addChild(EntityModelPartNames.LEFT_HIND_LEG, ModelPartBuilder.create().uv(0, 0).cuboid(-1.5F, 0.0F, -0.5F, 3.0F, 7.0F, 3.0F), ModelTransform.origin(-2.5F, 2.5F, 5.5F)); - root.addChild(EntityModelPartNames.RIGHT_FRONT_LEG, ModelPartBuilder.create().uv(0, 36).cuboid(-1.5F, -1.0F, -2.0F, 3.0F, 6.0F, 3.0F), ModelTransform.origin(1.5F, 4.5F, -4.5F)); - root.addChild(EntityModelPartNames.LEFT_FRONT_LEG, ModelPartBuilder.create().uv(12, 36).cuboid(-1.5F, -1.0F, -2.0F, 3.0F, 6.0F, 3.0F), ModelTransform.origin(-2.5F, 4.5F, -4.5F)); - - root.addChild(EntityModelPartNames.BODY, ModelPartBuilder.create().uv(0, 0).cuboid(-4.0F, -4.0F, -7.5F, 8.0F, 8.0F, 15.0F), ModelTransform.origin(-0.5F, 0.5F, 0.0F)); - ModelPartData head = root.addChild(EntityModelPartNames.HEAD, ModelPartBuilder.create() - .uv(20, 23).cuboid(-3.0F, 1.0F, -5.0F, 6.0F, 1.0F, 5.0F) - .uv(0, 23).cuboid(-3.0F, -4.0F, -8.0F, 6.0F, 5.0F, 8.0F), - ModelTransform.of(-0.5F, -2.5F, -6.5F, -0.0436F, 0.0F, 0.0F)); - ModelPartData jaw = head.addChild(EntityModelPartNames.JAW, ModelPartBuilder.create().uv(28, 29).cuboid(-3.0F, 0.0F, -3.0F, 6.0F, 1.0F, 3.0F), ModelTransform.origin(0.0F, 1.0F, -5.0F)); - - head.addChild(EntityModelPartNames.LEFT_EAR, ModelPartBuilder.create().uv(0, 10).cuboid(0.0F, -2.0F, 0.0F, 1.0F, 2.0F, 2.0F), ModelTransform.of(2.0F, -3.0F, -1.0F, -0.2F, 0.2F, 0.0F)); - head.addChild(EntityModelPartNames.RIGHT_EAR, ModelPartBuilder.create().uv(6, 10).cuboid(-1.0F, -2.0F, 0.0F, 1.0F, 2.0F, 2.0F), ModelTransform.of(-2.0F, -3.0F, -1.0F, -0.2F, -0.2F, 0.0F)); - head.addChild(UPPER_TEETH, ModelPartBuilder.create().uv(9, 0).cuboid(-1.0F, -0.25F, 0.0F, 2.0F, 1.0F, 0.0F), ModelTransform.origin(0.0F, 1.0F, -7.0F)); - jaw.addChild(LOWER_TEETH, ModelPartBuilder.create().uv(9, 1).cuboid(-1.0F, -0.75F, 0.0F, 2.0F, 1.0F, 0.0F), ModelTransform.origin(0.0F, 0.0F, -2.0F)); - - return TexturedModelData.of(modelData, 64, 64); - } - - @Override - public void setAngles(CapybaraEntityRenderState state) { - super.setAngles(state); - - // Head - if (state.canAngleHead) { - this.head.pitch = state.pitch * (float) (Math.PI / 180.0); - this.head.yaw = state.relativeHeadYaw * (float) (Math.PI / 180.0); - } - - // Dynamic animations - this.walkingAnimation.applyWalking(state.limbSwingAnimationProgress, state.limbSwingAmplitude, 4.0F, 2.5F); - - // Custom animations - this.earWiggleAnimation.apply(state.earWiggleAnimState, state.age, state.earWiggleSpeed); - this.fallToSleepAnimation.apply(state.fallToSleepAnimState, state.age); - this.sleepingAnimation.apply(state.sleepingAnimState, state.age); - this.wakeUpAnimation.apply(state.wakeUpAnimState, state.age); - this.fartAnimation.apply(state.fartAnimState, state.age); - } -} \ No newline at end of file diff --git a/src/client/java/fr/hugman/promenade/client/render/entity/model/DuckEntityModel.java b/src/client/java/fr/hugman/promenade/client/render/entity/model/DuckEntityModel.java deleted file mode 100644 index 673faffa..00000000 --- a/src/client/java/fr/hugman/promenade/client/render/entity/model/DuckEntityModel.java +++ /dev/null @@ -1,66 +0,0 @@ -package fr.hugman.promenade.client.render.entity.model; - -import fr.hugman.promenade.client.render.entity.state.DuckEntityRenderState; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -import net.minecraft.client.model.*; -import net.minecraft.client.render.entity.model.BabyModelTransformer; -import net.minecraft.client.render.entity.model.EntityModel; -import net.minecraft.client.render.entity.model.EntityModelPartNames; -import net.minecraft.client.render.entity.model.ModelTransformer; -import net.minecraft.util.math.MathHelper; - -import java.util.Set; - -@Environment(EnvType.CLIENT) -public class DuckEntityModel extends EntityModel { - public static final ModelTransformer BABY_TRANSFORMER = new BabyModelTransformer(Set.of(EntityModelPartNames.HEAD, EntityModelPartNames.BEAK)); - - private final ModelPart head; - private final ModelPart rightLeg; - private final ModelPart leftLeg; - private final ModelPart rightWing; - private final ModelPart leftWing; - - public DuckEntityModel(ModelPart root) { - super(root); - this.head = root.getChild(EntityModelPartNames.HEAD); - this.rightLeg = root.getChild(EntityModelPartNames.RIGHT_LEG); - this.leftLeg = root.getChild(EntityModelPartNames.LEFT_LEG); - this.rightWing = root.getChild(EntityModelPartNames.RIGHT_WING); - this.leftWing = root.getChild(EntityModelPartNames.LEFT_WING); - } - - public static TexturedModelData getTexturedModelData() { - ModelData modelData = new ModelData(); - ModelPartData root = modelData.getRoot(); - - var head = root.addChild(EntityModelPartNames.HEAD, ModelPartBuilder.create().uv(0, 0).cuboid(-2.0F, -10.0F, -2.0F, 4.0F, 10.0F, 3.0F), ModelTransform.origin(0.0F, 15.0F, -4.0F)); - head.addChild(EntityModelPartNames.BEAK, ModelPartBuilder.create().uv(14, 0).cuboid(-2.0F, -8.0F, -5.0F, 4.0F, 2.0F, 3.0F), ModelTransform.NONE); - root.addChild(EntityModelPartNames.BODY, ModelPartBuilder.create().uv(0, 13).cuboid(-3.0F, -4.0F, -3.0F, 6.0F, 8.0F, 6.0F), ModelTransform.origin(0.0F, 16.0F, 0.0F)); - root.addChild(EntityModelPartNames.RIGHT_LEG, ModelPartBuilder.create().uv(28, 0).cuboid(-1.0F, 0.0F, -3.0F, 3.0F, 5.0F, 3.0F), ModelTransform.origin(-2.0F, 19.0F, 1.0F)); - root.addChild(EntityModelPartNames.LEFT_LEG, ModelPartBuilder.create().uv(28, 0).cuboid(-1.0F, 0.0F, -3.0F, 3.0F, 5.0F, 3.0F), ModelTransform.origin(1.0F, 19.0F, 1.0F)); - root.addChild(EntityModelPartNames.RIGHT_WING, ModelPartBuilder.create().uv(24, 17).cuboid(0.0F, 0.0F, -3.0F, 1.0F, 4.0F, 6.0F), ModelTransform.origin(-4.0F, 13.0F, 0.0F)); - root.addChild(EntityModelPartNames.LEFT_WING, ModelPartBuilder.create().uv(24, 17).cuboid(-1.0F, 0.0F, -3.0F, 1.0F, 4.0F, 6.0F), ModelTransform.origin(4.0F, 13.0F, 0.0F)); - return TexturedModelData.of(modelData, 64, 32); - } - - public void setAngles(DuckEntityRenderState state) { - super.setAngles(state); - - // Head - this.head.pitch = state.pitch * (float) (Math.PI / 180.0); - this.head.yaw = state.relativeHeadYaw * (float) (Math.PI / 180.0); - - // Legs - float g = state.limbSwingAmplitude; - float h = state.limbSwingAnimationProgress; - this.rightLeg.pitch = MathHelper.cos(h * 0.6662F) * 1.4F * g; - this.leftLeg.pitch = MathHelper.cos(h * 0.6662F + (float) Math.PI) * 1.4F * g; - - // Wings - float f = (MathHelper.sin(state.flapProgress) + 1.0F) * state.maxWingDeviation; - this.rightWing.roll = f; - this.leftWing.roll = -f; - } -} \ No newline at end of file diff --git a/src/client/java/fr/hugman/promenade/client/render/entity/model/PromenadeEntityModelLayers.java b/src/client/java/fr/hugman/promenade/client/render/entity/model/PromenadeEntityModelLayers.java index b704d1fa..ff89ccfa 100644 --- a/src/client/java/fr/hugman/promenade/client/render/entity/model/PromenadeEntityModelLayers.java +++ b/src/client/java/fr/hugman/promenade/client/render/entity/model/PromenadeEntityModelLayers.java @@ -1,80 +1,85 @@ package fr.hugman.promenade.client.render.entity.model; import fr.hugman.promenade.Promenade; +import fr.hugman.promenade.client.render.entity.model.capybara.AdultCapybaraModel; +import fr.hugman.promenade.client.render.entity.model.capybara.BabyCapybaraModel; +import fr.hugman.promenade.client.render.entity.model.duck.AdultDuckModel; +import fr.hugman.promenade.client.render.entity.model.duck.BabyDuckModel; +import fr.hugman.promenade.client.render.entity.model.duck.DuckModel; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.fabricmc.fabric.api.client.rendering.v1.EntityModelLayerRegistry; -import net.minecraft.client.model.Dilation; -import net.minecraft.client.model.TexturedModelData; -import net.minecraft.client.render.entity.model.*; +import net.fabricmc.fabric.api.client.rendering.v1.ModelLayerRegistry; +import net.minecraft.client.model.HumanoidModel; +import net.minecraft.client.model.geom.ModelLayerLocation; +import net.minecraft.client.model.geom.builders.CubeDeformation; +import net.minecraft.client.model.geom.builders.LayerDefinition; +import net.minecraft.client.model.monster.creeper.CreeperModel; +import net.minecraft.client.model.object.boat.BoatModel; +import net.minecraft.client.renderer.entity.ArmorModelSet; -@Environment(EnvType.CLIENT) public class PromenadeEntityModelLayers { - public static final EntityModelLayer SAKURA_BOAT = ofMain("boat/sakura"); - public static final EntityModelLayer SAKURA_CHEST_BOAT = ofMain("chest_boat/sakura"); - public static final EntityModelLayer MAPLE_BOAT = ofMain("boat/maple"); - public static final EntityModelLayer MAPLE_CHEST_BOAT = ofMain("chest_boat/maple"); - public static final EntityModelLayer PALM_BOAT = ofMain("boat/palm"); - public static final EntityModelLayer PALM_CHEST_BOAT = ofMain("chest_boat/palm"); + public static final ModelLayerLocation SAKURA_BOAT = ofMain("boat/sakura"); + public static final ModelLayerLocation SAKURA_CHEST_BOAT = ofMain("chest_boat/sakura"); + public static final ModelLayerLocation MAPLE_BOAT = ofMain("boat/maple"); + public static final ModelLayerLocation MAPLE_CHEST_BOAT = ofMain("chest_boat/maple"); + public static final ModelLayerLocation PALM_BOAT = ofMain("boat/palm"); + public static final ModelLayerLocation PALM_CHEST_BOAT = ofMain("chest_boat/palm"); - public static final EntityModelLayer CAPYBARA = ofMain("capybara"); - public static final EntityModelLayer CAPYBARA_BABY = ofMain("capybara_baby"); + public static final ModelLayerLocation CAPYBARA = ofMain("capybara"); + public static final ModelLayerLocation CAPYBARA_BABY = ofMain("capybara_baby"); - public static final EntityModelLayer DUCK = ofMain("duck"); - public static final EntityModelLayer DUCK_BABY = ofMain("duck_baby"); + public static final ModelLayerLocation DUCK = ofMain("duck"); + public static final ModelLayerLocation DUCK_BABY = ofMain("duck_baby"); - public static final EntityModelLayer LUSH_CREEPER = ofMain("lush_creeper"); - public static final EntityModelLayer LUSH_CREEPER_OUTER = of("lush_creeper", "outer"); + public static final ModelLayerLocation LUSH_CREEPER = ofMain("lush_creeper"); + public static final ModelLayerLocation LUSH_CREEPER_OUTER = of("lush_creeper", "outer"); - public static final EntityModelLayer SUNKEN = ofMain("sunken"); - public static final EquipmentModelData SUNKEN_EQUIPMENT = equipment("stray"); + public static final ModelLayerLocation SUNKEN = ofMain("sunken"); + public static final ArmorModelSet SUNKEN_EQUIPMENT = equipment("stray"); - private static final Dilation ARMOR_DILATION = new Dilation(1.0F); - private static final Dilation HAT_DILATION = new Dilation(0.5F); - private static final TexturedModelData INNER_ARMOR_MODEL_DATA = TexturedModelData.of(BipedEntityModel.getModelData(HAT_DILATION, 0.0F), 64, 32); - private static final TexturedModelData OUTER_ARMOR_MODEL_DATA = TexturedModelData.of(BipedEntityModel.getModelData(ARMOR_DILATION, 0.0F), 64, 32); + private static final CubeDeformation ARMOR_DILATION = new CubeDeformation(1.0F); + private static final CubeDeformation HAT_DILATION = new CubeDeformation(0.5F); + private static final LayerDefinition INNER_ARMOR_MODEL_DATA = LayerDefinition.create(HumanoidModel.createMesh(HAT_DILATION, 0.0F), 64, 32); + private static final LayerDefinition OUTER_ARMOR_MODEL_DATA = LayerDefinition.create(HumanoidModel.createMesh(ARMOR_DILATION, 0.0F), 64, 32); public static void register() { - EquipmentModelData equipmentModelData = BipedEntityModel.createEquipmentModelData(HAT_DILATION, ARMOR_DILATION).map((data) -> TexturedModelData.of(data, 64, 32)); - - var capybaraModelData = CapybaraEntityModel.getTexturedModelData(); - EntityModelLayerRegistry.registerModelLayer(CAPYBARA, () -> capybaraModelData); - EntityModelLayerRegistry.registerModelLayer(CAPYBARA_BABY, () -> capybaraModelData.transform(CapybaraEntityModel.BABY_TRANSFORMER)); - - var duckModelData = DuckEntityModel.getTexturedModelData(); - - EntityModelLayerRegistry.registerModelLayer(DUCK, () -> duckModelData); - EntityModelLayerRegistry.registerModelLayer(DUCK_BABY, () -> duckModelData.transform(DuckEntityModel.BABY_TRANSFORMER)); - - EntityModelLayerRegistry.registerModelLayer(LUSH_CREEPER, () -> CreeperEntityModel.getTexturedModelData(Dilation.NONE)); - EntityModelLayerRegistry.registerModelLayer(LUSH_CREEPER_OUTER, () -> CreeperEntityModel.getTexturedModelData(new Dilation(0.25f))); - - EntityModelLayerRegistry.registerModelLayer(SUNKEN, SunkenEntityModel::getTexturedModelData); - EntityModelLayerRegistry.registerModelLayer(SUNKEN_EQUIPMENT.head(), equipmentModelData::head); - EntityModelLayerRegistry.registerModelLayer(SUNKEN_EQUIPMENT.chest(), equipmentModelData::chest); - EntityModelLayerRegistry.registerModelLayer(SUNKEN_EQUIPMENT.legs(), equipmentModelData::legs); - EntityModelLayerRegistry.registerModelLayer(SUNKEN_EQUIPMENT.feet(), equipmentModelData::feet); - - TexturedModelData boatModel = BoatEntityModel.getTexturedModelData(); - TexturedModelData chestBoatModel = BoatEntityModel.getChestTexturedModelData(); - EntityModelLayerRegistry.registerModelLayer(SAKURA_BOAT, () -> boatModel); - EntityModelLayerRegistry.registerModelLayer(SAKURA_CHEST_BOAT, () -> chestBoatModel); - EntityModelLayerRegistry.registerModelLayer(MAPLE_BOAT, () -> boatModel); - EntityModelLayerRegistry.registerModelLayer(MAPLE_CHEST_BOAT, () -> chestBoatModel); - EntityModelLayerRegistry.registerModelLayer(PALM_BOAT, () -> boatModel); - EntityModelLayerRegistry.registerModelLayer(PALM_CHEST_BOAT, () -> chestBoatModel); + ArmorModelSet equipmentModelData = HumanoidModel.createArmorMeshSet(HAT_DILATION, ARMOR_DILATION).map((data) -> LayerDefinition.create(data, 64, 32)); + + ModelLayerRegistry.registerModelLayer(CAPYBARA, AdultCapybaraModel::getTexturedModelData); + ModelLayerRegistry.registerModelLayer(CAPYBARA_BABY, BabyCapybaraModel::getTexturedModelData); + + ModelLayerRegistry.registerModelLayer(DUCK, AdultDuckModel::getTexturedModelData); + ModelLayerRegistry.registerModelLayer(DUCK_BABY, BabyDuckModel::getTexturedModelData); + + ModelLayerRegistry.registerModelLayer(LUSH_CREEPER, () -> CreeperModel.createBodyLayer(CubeDeformation.NONE)); + ModelLayerRegistry.registerModelLayer(LUSH_CREEPER_OUTER, () -> CreeperModel.createBodyLayer(new CubeDeformation(0.25f))); + + ModelLayerRegistry.registerModelLayer(SUNKEN, SunkenEntityModel::getTexturedModelData); + ModelLayerRegistry.registerModelLayer(SUNKEN_EQUIPMENT.head(), equipmentModelData::head); + ModelLayerRegistry.registerModelLayer(SUNKEN_EQUIPMENT.chest(), equipmentModelData::chest); + ModelLayerRegistry.registerModelLayer(SUNKEN_EQUIPMENT.legs(), equipmentModelData::legs); + ModelLayerRegistry.registerModelLayer(SUNKEN_EQUIPMENT.feet(), equipmentModelData::feet); + + LayerDefinition boatModel = BoatModel.createBoatModel(); + LayerDefinition chestBoatModel = BoatModel.createChestBoatModel(); + ModelLayerRegistry.registerModelLayer(SAKURA_BOAT, () -> boatModel); + ModelLayerRegistry.registerModelLayer(SAKURA_CHEST_BOAT, () -> chestBoatModel); + ModelLayerRegistry.registerModelLayer(MAPLE_BOAT, () -> boatModel); + ModelLayerRegistry.registerModelLayer(MAPLE_CHEST_BOAT, () -> chestBoatModel); + ModelLayerRegistry.registerModelLayer(PALM_BOAT, () -> boatModel); + ModelLayerRegistry.registerModelLayer(PALM_CHEST_BOAT, () -> chestBoatModel); } - private static EntityModelLayer of(String name, String layer) { - return new EntityModelLayer(Promenade.id(name), layer); + private static ModelLayerLocation of(String name, String layer) { + return new ModelLayerLocation(Promenade.id(name), layer); } - private static EntityModelLayer ofMain(String name) { + private static ModelLayerLocation ofMain(String name) { return of(name, "main"); } - private static EquipmentModelData equipment(String id) { - return new EquipmentModelData(of(id, "helmet"), of(id, "chestplate"), of(id, "leggings"), of(id, "boots")); + private static ArmorModelSet equipment(String id) { + return new ArmorModelSet(of(id, "helmet"), of(id, "chestplate"), of(id, "leggings"), of(id, "boots")); } } diff --git a/src/client/java/fr/hugman/promenade/client/render/entity/model/SunkenEntityModel.java b/src/client/java/fr/hugman/promenade/client/render/entity/model/SunkenEntityModel.java index 2d5541e1..12a6b127 100644 --- a/src/client/java/fr/hugman/promenade/client/render/entity/model/SunkenEntityModel.java +++ b/src/client/java/fr/hugman/promenade/client/render/entity/model/SunkenEntityModel.java @@ -1,31 +1,36 @@ package fr.hugman.promenade.client.render.entity.model; -import fr.hugman.promenade.client.render.entity.state.SunkenEntityRenderState; +import fr.hugman.promenade.client.render.entity.state.SunkenRenderState; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.model.*; -import net.minecraft.client.render.entity.model.BipedEntityModel; -import net.minecraft.client.render.entity.model.EntityModelPartNames; -import net.minecraft.client.render.entity.model.SkeletonEntityModel; +import net.minecraft.client.model.geom.ModelPart; +import net.minecraft.client.model.geom.PartNames; +import net.minecraft.client.model.geom.PartPose; +import net.minecraft.client.model.geom.builders.CubeDeformation; +import net.minecraft.client.model.geom.builders.CubeListBuilder; +import net.minecraft.client.model.geom.builders.LayerDefinition; +import net.minecraft.client.model.geom.builders.MeshDefinition; +import net.minecraft.client.model.geom.builders.PartDefinition; +import net.minecraft.client.model.monster.skeleton.SkeletonModel; -@Environment(EnvType.CLIENT) -public class SunkenEntityModel extends SkeletonEntityModel { +public class SunkenEntityModel extends SkeletonModel { public SunkenEntityModel(ModelPart root) { super(root); } - public static TexturedModelData getTexturedModelData() { - ModelData modelData = BipedEntityModel.getModelData(Dilation.NONE, 0.0F); - ModelPartData root = modelData.getRoot(); - SkeletonEntityModel.addLimbs(root); - modelData.getRoot().getChild(EntityModelPartNames.HEAD) - .addChild(EntityModelPartNames.HAT, ModelPartBuilder.create().uv(32, 0).cuboid(-4.0F, -16.0F, -4.0F, 16.0F, 16.0F, 0.0F), ModelTransform.origin(0.0F, 0.0F, 0.0F)); - return TexturedModelData.of(modelData, 64, 32); + public static LayerDefinition getTexturedModelData() { + MeshDefinition modelData = HumanoidModel.createMesh(CubeDeformation.NONE, 0.0F); + PartDefinition root = modelData.getRoot(); + SkeletonModel.createDefaultSkeletonMesh(root); + modelData.getRoot().getChild(PartNames.HEAD) + .addOrReplaceChild(PartNames.HAT, CubeListBuilder.create().texOffs(32, 0).addBox(-4.0F, -16.0F, -4.0F, 16.0F, 16.0F, 0.0F), PartPose.offset(0.0F, 0.0F, 0.0F)); + return LayerDefinition.create(modelData, 64, 32); } @Override - public void setAngles(SunkenEntityRenderState state) { - super.setAngles(state); - this.hat.visible = state.equippedHeadStack.isEmpty(); + public void setupAnim(SunkenRenderState state) { + super.setupAnim(state); + this.hat.visible = state.headEquipment.isEmpty(); } } \ No newline at end of file diff --git a/src/client/java/fr/hugman/promenade/client/render/entity/model/capybara/AdultCapybaraModel.java b/src/client/java/fr/hugman/promenade/client/render/entity/model/capybara/AdultCapybaraModel.java new file mode 100644 index 00000000..03116cea --- /dev/null +++ b/src/client/java/fr/hugman/promenade/client/render/entity/model/capybara/AdultCapybaraModel.java @@ -0,0 +1,41 @@ +package fr.hugman.promenade.client.render.entity.model.capybara; + +import net.minecraft.client.model.*; +import net.minecraft.client.model.geom.ModelPart; +import net.minecraft.client.model.geom.PartNames; +import net.minecraft.client.model.geom.PartPose; +import net.minecraft.client.model.geom.builders.CubeListBuilder; +import net.minecraft.client.model.geom.builders.LayerDefinition; +import net.minecraft.client.model.geom.builders.MeshDefinition; +import net.minecraft.client.model.geom.builders.PartDefinition; + +public class AdultCapybaraModel extends CapybaraModel { + public AdultCapybaraModel(ModelPart part) { + super(part); + } + + public static LayerDefinition getTexturedModelData() { + MeshDefinition modelData = new MeshDefinition(); + PartDefinition modelPartData = modelData.getRoot(); + PartDefinition root = modelPartData.addOrReplaceChild(PartNames.ROOT, CubeListBuilder.create(), PartPose.offset(0.5F, 14.5F, 0.5F)); + + root.addOrReplaceChild(PartNames.RIGHT_HIND_LEG, CubeListBuilder.create().texOffs(31, 0).addBox(-1.5F, 0.0F, -0.5F, 3.0F, 7.0F, 3.0F), PartPose.offset(1.5F, 2.5F, 5.5F)); + root.addOrReplaceChild(PartNames.LEFT_HIND_LEG, CubeListBuilder.create().texOffs(0, 0).addBox(-1.5F, 0.0F, -0.5F, 3.0F, 7.0F, 3.0F), PartPose.offset(-2.5F, 2.5F, 5.5F)); + root.addOrReplaceChild(PartNames.RIGHT_FRONT_LEG, CubeListBuilder.create().texOffs(0, 36).addBox(-1.5F, -1.0F, -2.0F, 3.0F, 6.0F, 3.0F), PartPose.offset(1.5F, 4.5F, -4.5F)); + root.addOrReplaceChild(PartNames.LEFT_FRONT_LEG, CubeListBuilder.create().texOffs(12, 36).addBox(-1.5F, -1.0F, -2.0F, 3.0F, 6.0F, 3.0F), PartPose.offset(-2.5F, 4.5F, -4.5F)); + + root.addOrReplaceChild(PartNames.BODY, CubeListBuilder.create().texOffs(0, 0).addBox(-4.0F, -4.0F, -7.5F, 8.0F, 8.0F, 15.0F), PartPose.offsetAndRotation(-0.5F, 0.5F, 0.0F, 0.0873F, 0.0F, 0.0F)); + PartDefinition head = root.addOrReplaceChild(PartNames.HEAD, CubeListBuilder.create() + .texOffs(20, 23).addBox(-3.0F, 1.0F, -5.0F, 6.0F, 1.0F, 5.0F) + .texOffs(0, 23).addBox(-3.0F, -4.0F, -8.0F, 6.0F, 5.0F, 8.0F), + PartPose.offset(-0.5F, -2.5F, -5.5F)); + PartDefinition jaw = head.addOrReplaceChild(PartNames.JAW, CubeListBuilder.create().texOffs(28, 29).addBox(-3.0F, 0.0F, -3.0F, 6.0F, 1.0F, 3.0F), PartPose.offset(0.0F, 1.0F, -5.0F)); + + head.addOrReplaceChild(PartNames.LEFT_EAR, CubeListBuilder.create().texOffs(0, 10).addBox(0.0F, -2.0F, 0.0F, 1.0F, 2.0F, 2.0F), PartPose.offsetAndRotation(2.0F, -3.0F, -1.0F, -0.2182F, 0.2182F, 0.0F)); + head.addOrReplaceChild(PartNames.RIGHT_EAR, CubeListBuilder.create().texOffs(6, 10).addBox(-1.0F, -2.0F, 0.0F, 1.0F, 2.0F, 2.0F), PartPose.offsetAndRotation(-2.0F, -3.0F, -1.0F, -0.2182F, -0.2182F, 0.0F)); + head.addOrReplaceChild(UPPER_TEETH, CubeListBuilder.create().texOffs(9, 0).addBox(-1.0F, -0.25F, 0.0F, 2.0F, 1.0F, 0.0F), PartPose.offset(0.0F, 1.0F, -7.0F)); + jaw.addOrReplaceChild(LOWER_TEETH, CubeListBuilder.create().texOffs(9, 1).addBox(-1.0F, -0.75F, 0.0F, 2.0F, 1.0F, 0.0F), PartPose.offset(0.0F, 0.0F, -2.0F)); + + return LayerDefinition.create(modelData, 64, 64); + } +} \ No newline at end of file diff --git a/src/client/java/fr/hugman/promenade/client/render/entity/model/capybara/BabyCapybaraModel.java b/src/client/java/fr/hugman/promenade/client/render/entity/model/capybara/BabyCapybaraModel.java new file mode 100644 index 00000000..0ad38b83 --- /dev/null +++ b/src/client/java/fr/hugman/promenade/client/render/entity/model/capybara/BabyCapybaraModel.java @@ -0,0 +1,37 @@ +package fr.hugman.promenade.client.render.entity.model.capybara; + +import net.minecraft.client.model.geom.ModelPart; +import net.minecraft.client.model.geom.PartNames; +import net.minecraft.client.model.geom.PartPose; +import net.minecraft.client.model.geom.builders.*; + +public class BabyCapybaraModel extends CapybaraModel { + public BabyCapybaraModel(ModelPart part) { + super(part); + } + + public static LayerDefinition getTexturedModelData() { + MeshDefinition meshdefinition = new MeshDefinition(); + PartDefinition partdefinition = meshdefinition.getRoot(); + PartDefinition root = partdefinition.addOrReplaceChild("root", CubeListBuilder.create(), PartPose.offset(0.5F, 14.5F, 3.5F)); + + root.addOrReplaceChild(PartNames.RIGHT_FRONT_LEG, CubeListBuilder.create().texOffs(21, 14).addBox(-1.1F, 1.0F, -1.0F, 2.0F, 3.0F, 2.0F, new CubeDeformation(0.0F)), PartPose.offset(1.5F, 5.5F, -5.5F)); + root.addOrReplaceChild(PartNames.LEFT_FRONT_LEG, CubeListBuilder.create().texOffs(1, 14).addBox(-0.9F, 1.0F, -1.0F, 2.0F, 3.0F, 2.0F, new CubeDeformation(0.0F)), PartPose.offset(-2.5F, 5.5F, -5.5F)); + root.addOrReplaceChild(PartNames.RIGHT_HIND_LEG, CubeListBuilder.create().texOffs(8, 23).addBox(-1.2F, 1.0F, -1.0F, 2.0F, 4.0F, 2.0F, new CubeDeformation(0.0F)), PartPose.offset(1.5F, 4.5F, 0.5F)); + root.addOrReplaceChild(PartNames.LEFT_HIND_LEG, CubeListBuilder.create().texOffs(0, 23).addBox(-0.9F, 1.0F, -1.0F, 2.0F, 4.0F, 2.0F, new CubeDeformation(0.0F)), PartPose.offset(-2.5F, 4.5F, 0.5F)); + + root.addOrReplaceChild(PartNames.BODY, CubeListBuilder.create().texOffs(0, 10).addBox(-3.0F, -2.0F, -4.25F, 6.0F, 4.0F, 9.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(-0.5F, 4.5F, -3.0F, 0.0873F, 0.0F, 0.0F)); + PartDefinition head = root.addOrReplaceChild(PartNames.HEAD, CubeListBuilder.create() + .texOffs(22, 0).addBox(-2.0F, 1.0F, -4.0F, 5.0F, 1.0F, 4.0F, new CubeDeformation(0.0F)) + .texOffs(0, 0).addBox(-2.0F, -3.0F, -6.0F, 5.0F, 4.0F, 6.0F, new CubeDeformation(0.0F)), + PartPose.offset(-1.0F, 3.5F, -6.0F)); + PartDefinition jaw = head.addOrReplaceChild(PartNames.JAW, CubeListBuilder.create().texOffs(24, 5).addBox(-2.25F, 0.0F, -2.0F, 5.0F, 1.0F, 2.0F, new CubeDeformation(0.0F)), PartPose.offset(0.25F, 1.0F, -4.0F)); + + head.addOrReplaceChild(PartNames.LEFT_EAR, CubeListBuilder.create().texOffs(16, 2).addBox(-0.5F, -2.0F, 0.0F, 1.0F, 2.0F, 2.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(2.5F, -2.0F, -1.0F, -0.2182F, 0.2182F, 0.0F)); + head.addOrReplaceChild(PartNames.RIGHT_EAR, CubeListBuilder.create().texOffs(0, 2).addBox(-0.5F, -2.0F, 0.0F, 1.0F, 2.0F, 2.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(-1.5F, -2.0F, -1.0F, -0.2182F, -0.2182F, 0.0F)); + head.addOrReplaceChild(UPPER_TEETH, CubeListBuilder.create().texOffs(22, 2).addBox(-0.5F, -0.25F, 0.0F, 2.0F, 1.0F, 0.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 1.0F, -5.0F)); + jaw.addOrReplaceChild(LOWER_TEETH, CubeListBuilder.create().texOffs(22, 3).addBox(-0.5F, -0.75F, 2.0F, 2.0F, 1.0F, 0.0F, new CubeDeformation(0.0F)), PartPose.offset(-0.25F, 0.0F, -3.0F)); + + return LayerDefinition.create(meshdefinition, 64, 64); + } +} \ No newline at end of file diff --git a/src/client/java/fr/hugman/promenade/client/render/entity/model/capybara/CapybaraModel.java b/src/client/java/fr/hugman/promenade/client/render/entity/model/capybara/CapybaraModel.java new file mode 100644 index 00000000..f77f45dd --- /dev/null +++ b/src/client/java/fr/hugman/promenade/client/render/entity/model/capybara/CapybaraModel.java @@ -0,0 +1,54 @@ +package fr.hugman.promenade.client.render.entity.model.capybara; + +import fr.hugman.promenade.client.render.entity.animation.CapybaraAnimations; +import fr.hugman.promenade.client.render.entity.state.CapybaraRenderState; +import net.minecraft.client.animation.KeyframeAnimation; +import net.minecraft.client.model.EntityModel; +import net.minecraft.client.model.geom.ModelPart; +import net.minecraft.client.model.geom.PartNames; + +public abstract class CapybaraModel extends EntityModel { + public static final String LOWER_TEETH = "lower_teeth"; + public static final String UPPER_TEETH = "upper_teeth"; + + private final ModelPart head; + + private final KeyframeAnimation walkingAnimation; + private final KeyframeAnimation earWiggleAnimation; + private final KeyframeAnimation fallToSleepAnimation; + private final KeyframeAnimation sleepingAnimation; + private final KeyframeAnimation wakeUpAnimation; + private final KeyframeAnimation fartAnimation; + + public CapybaraModel(ModelPart part) { + super(part.getChild(PartNames.ROOT)); + this.head = this.root.getChild(PartNames.HEAD); + this.walkingAnimation = CapybaraAnimations.WALKING.bake(this.root); + this.earWiggleAnimation = CapybaraAnimations.EAR_WIGGLE.bake(this.root); + this.fallToSleepAnimation = CapybaraAnimations.FALL_TO_SLEEP.bake(this.root); + this.sleepingAnimation = CapybaraAnimations.SLEEP.bake(this.root); + this.wakeUpAnimation = CapybaraAnimations.WAKE_UP.bake(this.root); + this.fartAnimation = CapybaraAnimations.FART.bake(this.root); + } + + @Override + public void setupAnim(CapybaraRenderState state) { + super.setupAnim(state); + + // Head + if (state.canAngleHead) { + this.head.xRot = state.xRot * (float) (Math.PI / 180.0); + this.head.yRot = state.yRot * (float) (Math.PI / 180.0); + } + + // Dynamic animations + this.walkingAnimation.applyWalk(state.walkAnimationPos, state.walkAnimationSpeed, 4.0F, 2.5F); + + // Custom animations + this.earWiggleAnimation.apply(state.earWiggleAnimationState, state.ageInTicks, state.earWiggleSpeed); + this.fallToSleepAnimation.apply(state.fallToSleepAnimationState, state.ageInTicks); + this.sleepingAnimation.apply(state.sleepingAnimationState, state.ageInTicks); + this.wakeUpAnimation.apply(state.wakeUpAnimationState, state.ageInTicks); + this.fartAnimation.apply(state.fartAnimationState, state.ageInTicks); + } +} \ No newline at end of file diff --git a/src/client/java/fr/hugman/promenade/client/render/entity/model/duck/AdultDuckModel.java b/src/client/java/fr/hugman/promenade/client/render/entity/model/duck/AdultDuckModel.java new file mode 100644 index 00000000..df1b9b88 --- /dev/null +++ b/src/client/java/fr/hugman/promenade/client/render/entity/model/duck/AdultDuckModel.java @@ -0,0 +1,48 @@ +package fr.hugman.promenade.client.render.entity.model.duck; + +import fr.hugman.promenade.client.render.entity.state.DuckRenderState; +import net.minecraft.client.model.geom.ModelPart; +import net.minecraft.client.model.geom.PartNames; +import net.minecraft.client.model.geom.PartPose; +import net.minecraft.client.model.geom.builders.*; +import net.minecraft.util.Mth; + +public class AdultDuckModel extends DuckModel { + private final ModelPart rightWing; + private final ModelPart leftWing; + + public AdultDuckModel(ModelPart root) { + super(root); + ModelPart body = root.getChild(PartNames.BODY); + this.rightWing = body.getChild(PartNames.RIGHT_WING); + this.leftWing = body.getChild(PartNames.LEFT_WING); + } + + public static LayerDefinition getTexturedModelData() { + MeshDefinition modelData = new MeshDefinition(); + PartDefinition root = modelData.getRoot(); + + PartDefinition body = root.addOrReplaceChild(PartNames.BODY, CubeListBuilder.create().texOffs(8, 9).addBox(-3.0F, -1.5F, -5.0F, 6.0F, 3.0F, 10.0F), PartPose.offset(0.0F, 19.5F, 0.0F)); + + body.addOrReplaceChild(PartNames.LEFT_WING, CubeListBuilder.create().texOffs(30, 8).addBox(0.0F, 0.0F, -4.0F, 1.0F, 3.0F, 8.0F), PartPose.offset(3.0F, -1.5F, 0.0F)); + body.addOrReplaceChild(PartNames.RIGHT_WING, CubeListBuilder.create().texOffs(0, 8).addBox(-1.0F, 0.0F, -4.0F, 1.0F, 3.0F, 8.0F), PartPose.offset(-3.0F, -1.5F, 0.0F)); + body.addOrReplaceChild(PartNames.LEFT_LEG, CubeListBuilder.create().texOffs(12, 22).addBox(-1.5F, 0.0F, -3.5F, 3.0F, 3.0F, 3.0F), PartPose.offset(1.5F, 1.5F, 1.0F)); + body.addOrReplaceChild(PartNames.RIGHT_LEG, CubeListBuilder.create().texOffs(0, 22).addBox(-2.0F, 0.0F, -0.5F, 3.0F, 3.0F, 3.0F), PartPose.offset(-1.0F, 1.5F, -2.0F)); + body.addOrReplaceChild(PartNames.HEAD, CubeListBuilder.create() + .texOffs(24, 3).addBox(-2.0F, -4.0F, -5.0F, 4.0F, 2.0F, 3.0F) + .texOffs(0, 0).addBox(-2.0F, -6.0F, -2.0F, 4.0F, 4.0F, 4.0F) + .texOffs(16, 2).addBox(-1.0F, -3.0F, -1.0F, 2.0F, 4.0F, 2.0F), PartPose.offset(0.0F, -1.5F, -2.0F)); + + return LayerDefinition.create(modelData, 64, 64); + } + + @Override + public void setupAnim(DuckRenderState state) { + super.setupAnim(state); + + // Wings + float f = (Mth.sin(state.flapProgress) + 1.0F) * state.maxWingDeviation; + this.rightWing.zRot = f; + this.leftWing.zRot = -f; + } +} \ No newline at end of file diff --git a/src/client/java/fr/hugman/promenade/client/render/entity/model/duck/BabyDuckModel.java b/src/client/java/fr/hugman/promenade/client/render/entity/model/duck/BabyDuckModel.java new file mode 100644 index 00000000..2e8437a8 --- /dev/null +++ b/src/client/java/fr/hugman/promenade/client/render/entity/model/duck/BabyDuckModel.java @@ -0,0 +1,29 @@ +package fr.hugman.promenade.client.render.entity.model.duck; + +import net.minecraft.client.model.geom.ModelPart; +import net.minecraft.client.model.geom.PartNames; +import net.minecraft.client.model.geom.PartPose; +import net.minecraft.client.model.geom.builders.*; + +public class BabyDuckModel extends DuckModel { + public BabyDuckModel(ModelPart root) { + super(root); + } + + public static LayerDefinition getTexturedModelData() { + MeshDefinition modelData = new MeshDefinition(); + PartDefinition root = modelData.getRoot(); + + PartDefinition body = root.addOrReplaceChild(PartNames.BODY, CubeListBuilder.create().texOffs(0, 4).addBox(-1.5F, 0.5F, 0.0F, 3.0F, 2.0F, 4.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 20.5F, -2.0F)); + + body.addOrReplaceChild(PartNames.LEFT_LEG, CubeListBuilder.create().texOffs(4, 10).addBox(-0.5F, 0.0F, -1.0F, 1.0F, 1.0F, 1.0F, new CubeDeformation(0.0F)), PartPose.offset(1.0F, 2.5F, 2.0F)); + body.addOrReplaceChild(PartNames.RIGHT_LEG, CubeListBuilder.create().texOffs(0, 10).addBox(-0.5F, 0.0F, -1.0F, 1.0F, 1.0F, 1.0F, new CubeDeformation(0.0F)), PartPose.offset(-1.0F, 2.5F, 2.0F)); + + body.addOrReplaceChild(PartNames.HEAD, CubeListBuilder.create() + .texOffs(8, 10).addBox(-1.0F, -1.0F, -2.0F, 2.0F, 1.0F, 1.0F, new CubeDeformation(0.0F)) + .texOffs(0, 0).addBox(-1.0F, -2.0F, -1.0F, 2.0F, 2.0F, 2.0F, new CubeDeformation(0.0F)), + PartPose.offset(0.0F, 0.5F, 1.0F)); + + return LayerDefinition.create(modelData, 16, 16); + } +} \ No newline at end of file diff --git a/src/client/java/fr/hugman/promenade/client/render/entity/model/duck/DuckModel.java b/src/client/java/fr/hugman/promenade/client/render/entity/model/duck/DuckModel.java new file mode 100644 index 00000000..17312b54 --- /dev/null +++ b/src/client/java/fr/hugman/promenade/client/render/entity/model/duck/DuckModel.java @@ -0,0 +1,36 @@ +package fr.hugman.promenade.client.render.entity.model.duck; + +import fr.hugman.promenade.client.render.entity.state.DuckRenderState; +import net.minecraft.client.model.*; +import net.minecraft.client.model.geom.ModelPart; +import net.minecraft.client.model.geom.PartNames; +import net.minecraft.util.Mth; + +abstract public class DuckModel extends EntityModel { + private final ModelPart head; + private final ModelPart rightLeg; + private final ModelPart leftLeg; + + public DuckModel(ModelPart root) { + super(root); + ModelPart body = root.getChild(PartNames.BODY); + this.head = body.getChild(PartNames.HEAD); + this.rightLeg = body.getChild(PartNames.RIGHT_LEG); + this.leftLeg = body.getChild(PartNames.LEFT_LEG); + } + + @Override + public void setupAnim(DuckRenderState state) { + super.setupAnim(state); + + // Head + this.head.xRot = state.xRot * (float) (Math.PI / 180.0); + this.head.yRot = state.yRot * (float) (Math.PI / 180.0); + + // Legs + float g = state.walkAnimationSpeed; + float h = state.walkAnimationPos; + this.rightLeg.xRot = Mth.cos(h * 0.6662F) * 1.4F * g; + this.leftLeg.xRot = Mth.cos(h * 0.6662F + (float) Math.PI) * 1.4F * g; + } +} \ No newline at end of file diff --git a/src/client/java/fr/hugman/promenade/client/render/entity/state/CapybaraEntityRenderState.java b/src/client/java/fr/hugman/promenade/client/render/entity/state/CapybaraEntityRenderState.java deleted file mode 100644 index 1fdb9a98..00000000 --- a/src/client/java/fr/hugman/promenade/client/render/entity/state/CapybaraEntityRenderState.java +++ /dev/null @@ -1,25 +0,0 @@ -package fr.hugman.promenade.client.render.entity.state; - -import fr.hugman.promenade.entity.variant.CapybaraVariant; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -import net.minecraft.client.render.entity.state.LivingEntityRenderState; -import net.minecraft.entity.AnimationState; -import org.jetbrains.annotations.Nullable; - -@Environment(EnvType.CLIENT) -public class CapybaraEntityRenderState extends LivingEntityRenderState { - public final AnimationState earWiggleAnimState = new AnimationState(); - public final AnimationState fallToSleepAnimState = new AnimationState(); - public final AnimationState sleepingAnimState = new AnimationState(); - public final AnimationState wakeUpAnimState = new AnimationState(); - public final AnimationState fartAnimState = new AnimationState(); - - @Nullable - public CapybaraVariant variant; - public boolean closedEyes = false; - public boolean largeEyes = false; - public float earWiggleSpeed = 1.0f; - - public boolean canAngleHead = true; -} diff --git a/src/client/java/fr/hugman/promenade/client/render/entity/state/CapybaraRenderState.java b/src/client/java/fr/hugman/promenade/client/render/entity/state/CapybaraRenderState.java new file mode 100644 index 00000000..ba4468ca --- /dev/null +++ b/src/client/java/fr/hugman/promenade/client/render/entity/state/CapybaraRenderState.java @@ -0,0 +1,25 @@ +package fr.hugman.promenade.client.render.entity.state; + +import fr.hugman.promenade.entity.variant.CapybaraVariant; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.client.renderer.entity.state.LivingEntityRenderState; +import net.minecraft.world.entity.AnimationState; +import org.jetbrains.annotations.Nullable; + +@Environment(EnvType.CLIENT) +public class CapybaraRenderState extends LivingEntityRenderState { + public final AnimationState earWiggleAnimationState = new AnimationState(); + public final AnimationState fallToSleepAnimationState = new AnimationState(); + public final AnimationState sleepingAnimationState = new AnimationState(); + public final AnimationState wakeUpAnimationState = new AnimationState(); + public final AnimationState fartAnimationState = new AnimationState(); + + @Nullable + public CapybaraVariant variant; + public boolean sleeping = false; + public boolean surprised = false; + public float earWiggleSpeed = 1.0f; + + public boolean canAngleHead = true; +} diff --git a/src/client/java/fr/hugman/promenade/client/render/entity/state/DuckEntityRenderState.java b/src/client/java/fr/hugman/promenade/client/render/entity/state/DuckRenderState.java similarity index 72% rename from src/client/java/fr/hugman/promenade/client/render/entity/state/DuckEntityRenderState.java rename to src/client/java/fr/hugman/promenade/client/render/entity/state/DuckRenderState.java index 976d9e32..5a616f87 100644 --- a/src/client/java/fr/hugman/promenade/client/render/entity/state/DuckEntityRenderState.java +++ b/src/client/java/fr/hugman/promenade/client/render/entity/state/DuckRenderState.java @@ -3,11 +3,11 @@ import fr.hugman.promenade.entity.variant.DuckVariant; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.client.render.entity.state.LivingEntityRenderState; +import net.minecraft.client.renderer.entity.state.LivingEntityRenderState; import org.jetbrains.annotations.Nullable; @Environment(EnvType.CLIENT) -public class DuckEntityRenderState extends LivingEntityRenderState { +public class DuckRenderState extends LivingEntityRenderState { @Nullable public DuckVariant variant; diff --git a/src/client/java/fr/hugman/promenade/client/render/entity/state/SunkenEntityRenderState.java b/src/client/java/fr/hugman/promenade/client/render/entity/state/SunkenRenderState.java similarity index 67% rename from src/client/java/fr/hugman/promenade/client/render/entity/state/SunkenEntityRenderState.java rename to src/client/java/fr/hugman/promenade/client/render/entity/state/SunkenRenderState.java index c3e1e069..7170566b 100644 --- a/src/client/java/fr/hugman/promenade/client/render/entity/state/SunkenEntityRenderState.java +++ b/src/client/java/fr/hugman/promenade/client/render/entity/state/SunkenRenderState.java @@ -3,11 +3,11 @@ import fr.hugman.promenade.entity.variant.SunkenVariant; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.client.render.entity.state.SkeletonEntityRenderState; +import net.minecraft.client.renderer.entity.state.SkeletonRenderState; import org.jetbrains.annotations.Nullable; @Environment(EnvType.CLIENT) -public class SunkenEntityRenderState extends SkeletonEntityRenderState { +public class SunkenRenderState extends SkeletonRenderState { @Nullable public SunkenVariant variant; } diff --git a/src/client/resources/assets/promenade/textures/entity/capybara/albino/small_eyes.png b/src/client/resources/assets/promenade/textures/entity/capybara/albino/normal.png similarity index 100% rename from src/client/resources/assets/promenade/textures/entity/capybara/albino/small_eyes.png rename to src/client/resources/assets/promenade/textures/entity/capybara/albino/normal.png diff --git a/src/client/resources/assets/promenade/textures/entity/capybara/albino/normal_baby.png b/src/client/resources/assets/promenade/textures/entity/capybara/albino/normal_baby.png new file mode 100644 index 00000000..baa3a002 Binary files /dev/null and b/src/client/resources/assets/promenade/textures/entity/capybara/albino/normal_baby.png differ diff --git a/src/client/resources/assets/promenade/textures/entity/capybara/albino/closed_eyes.png b/src/client/resources/assets/promenade/textures/entity/capybara/albino/sleeping.png similarity index 100% rename from src/client/resources/assets/promenade/textures/entity/capybara/albino/closed_eyes.png rename to src/client/resources/assets/promenade/textures/entity/capybara/albino/sleeping.png diff --git a/src/client/resources/assets/promenade/textures/entity/capybara/albino/sleeping_baby.png b/src/client/resources/assets/promenade/textures/entity/capybara/albino/sleeping_baby.png new file mode 100644 index 00000000..d692295a Binary files /dev/null and b/src/client/resources/assets/promenade/textures/entity/capybara/albino/sleeping_baby.png differ diff --git a/src/client/resources/assets/promenade/textures/entity/capybara/albino/large_eyes.png b/src/client/resources/assets/promenade/textures/entity/capybara/albino/surprised.png similarity index 100% rename from src/client/resources/assets/promenade/textures/entity/capybara/albino/large_eyes.png rename to src/client/resources/assets/promenade/textures/entity/capybara/albino/surprised.png diff --git a/src/client/resources/assets/promenade/textures/entity/capybara/brown/small_eyes.png b/src/client/resources/assets/promenade/textures/entity/capybara/brown/normal.png similarity index 100% rename from src/client/resources/assets/promenade/textures/entity/capybara/brown/small_eyes.png rename to src/client/resources/assets/promenade/textures/entity/capybara/brown/normal.png diff --git a/src/client/resources/assets/promenade/textures/entity/capybara/brown/normal_baby.png b/src/client/resources/assets/promenade/textures/entity/capybara/brown/normal_baby.png new file mode 100644 index 00000000..8bc9647a Binary files /dev/null and b/src/client/resources/assets/promenade/textures/entity/capybara/brown/normal_baby.png differ diff --git a/src/client/resources/assets/promenade/textures/entity/capybara/brown/closed_eyes.png b/src/client/resources/assets/promenade/textures/entity/capybara/brown/sleeping.png similarity index 100% rename from src/client/resources/assets/promenade/textures/entity/capybara/brown/closed_eyes.png rename to src/client/resources/assets/promenade/textures/entity/capybara/brown/sleeping.png diff --git a/src/client/resources/assets/promenade/textures/entity/capybara/brown/sleeping_baby.png b/src/client/resources/assets/promenade/textures/entity/capybara/brown/sleeping_baby.png new file mode 100644 index 00000000..74932dbd Binary files /dev/null and b/src/client/resources/assets/promenade/textures/entity/capybara/brown/sleeping_baby.png differ diff --git a/src/client/resources/assets/promenade/textures/entity/capybara/brown/large_eyes.png b/src/client/resources/assets/promenade/textures/entity/capybara/brown/surprised.png similarity index 100% rename from src/client/resources/assets/promenade/textures/entity/capybara/brown/large_eyes.png rename to src/client/resources/assets/promenade/textures/entity/capybara/brown/surprised.png diff --git a/src/client/resources/assets/promenade/textures/entity/duck/duckling.png b/src/client/resources/assets/promenade/textures/entity/duck/duckling.png index fada8095..267eec88 100644 Binary files a/src/client/resources/assets/promenade/textures/entity/duck/duckling.png and b/src/client/resources/assets/promenade/textures/entity/duck/duckling.png differ diff --git a/src/client/resources/assets/promenade/textures/entity/duck/mallard.png b/src/client/resources/assets/promenade/textures/entity/duck/mallard.png index 5dacd82f..7090448c 100644 Binary files a/src/client/resources/assets/promenade/textures/entity/duck/mallard.png and b/src/client/resources/assets/promenade/textures/entity/duck/mallard.png differ diff --git a/src/client/resources/assets/promenade/textures/entity/duck/pekin.png b/src/client/resources/assets/promenade/textures/entity/duck/pekin.png index cf9a5383..0896510b 100644 Binary files a/src/client/resources/assets/promenade/textures/entity/duck/pekin.png and b/src/client/resources/assets/promenade/textures/entity/duck/pekin.png differ diff --git a/src/client/resources/assets/promenade/textures/entity/wolf/shiba_inu/angry.png b/src/client/resources/assets/promenade/textures/entity/wolf/shiba_inu/angry.png index 34a1c4b8..c781fd4f 100644 Binary files a/src/client/resources/assets/promenade/textures/entity/wolf/shiba_inu/angry.png and b/src/client/resources/assets/promenade/textures/entity/wolf/shiba_inu/angry.png differ diff --git a/src/client/resources/assets/promenade/textures/entity/wolf/shiba_inu/angry_baby.png b/src/client/resources/assets/promenade/textures/entity/wolf/shiba_inu/angry_baby.png new file mode 100644 index 00000000..bd358148 Binary files /dev/null and b/src/client/resources/assets/promenade/textures/entity/wolf/shiba_inu/angry_baby.png differ diff --git a/src/client/resources/assets/promenade/textures/entity/wolf/shiba_inu/tame.png b/src/client/resources/assets/promenade/textures/entity/wolf/shiba_inu/tame.png index 0bed57e6..8aec5b33 100644 Binary files a/src/client/resources/assets/promenade/textures/entity/wolf/shiba_inu/tame.png and b/src/client/resources/assets/promenade/textures/entity/wolf/shiba_inu/tame.png differ diff --git a/src/client/resources/assets/promenade/textures/entity/wolf/shiba_inu/tame_baby.png b/src/client/resources/assets/promenade/textures/entity/wolf/shiba_inu/tame_baby.png new file mode 100644 index 00000000..8e833879 Binary files /dev/null and b/src/client/resources/assets/promenade/textures/entity/wolf/shiba_inu/tame_baby.png differ diff --git a/src/client/resources/assets/promenade/textures/entity/wolf/shiba_inu/wild.png b/src/client/resources/assets/promenade/textures/entity/wolf/shiba_inu/wild.png index 825c87ad..b0870ed8 100644 Binary files a/src/client/resources/assets/promenade/textures/entity/wolf/shiba_inu/wild.png and b/src/client/resources/assets/promenade/textures/entity/wolf/shiba_inu/wild.png differ diff --git a/src/client/resources/assets/promenade/textures/entity/wolf/shiba_inu/wild_baby.png b/src/client/resources/assets/promenade/textures/entity/wolf/shiba_inu/wild_baby.png new file mode 100644 index 00000000..f836aa84 Binary files /dev/null and b/src/client/resources/assets/promenade/textures/entity/wolf/shiba_inu/wild_baby.png differ diff --git a/src/datagen/java/fr/hugman/promenade/data/PromenadeBlockFamilies.java b/src/datagen/java/fr/hugman/promenade/data/PromenadeBlockFamilies.java index fa8e5bc0..aa7a95fd 100644 --- a/src/datagen/java/fr/hugman/promenade/data/PromenadeBlockFamilies.java +++ b/src/datagen/java/fr/hugman/promenade/data/PromenadeBlockFamilies.java @@ -2,9 +2,9 @@ import com.google.common.collect.Maps; import fr.hugman.promenade.block.PromenadeBlocks; -import net.minecraft.block.Block; -import net.minecraft.data.family.BlockFamily; -import net.minecraft.registry.Registries; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.data.BlockFamily; +import net.minecraft.world.level.block.Block; import java.util.Map; import java.util.stream.Stream; @@ -13,7 +13,7 @@ public class PromenadeBlockFamilies { private static final Map BASE_BLOCKS_TO_FAMILIES = Maps.newHashMap(); /** - * The group used for the recipes of wooden block families. + * The recipeGroupPrefix used for the recipes of wooden block families. */ private static final String WOODEN_GROUP = "wooden"; /** @@ -26,23 +26,23 @@ public class PromenadeBlockFamilies { .stairs(PromenadeBlocks.ASPHALT_STAIRS) .slab(PromenadeBlocks.ASPHALT_SLAB) .polished(PromenadeBlocks.POLISHED_ASPHALT) - .build(); + .getFamily(); public static final BlockFamily POLISHED_ASPHALT = register(PromenadeBlocks.POLISHED_ASPHALT) .stairs(PromenadeBlocks.POLISHED_ASPHALT_STAIRS) .slab(PromenadeBlocks.POLISHED_ASPHALT_SLAB) - .build(); + .getFamily(); public static final BlockFamily BLUNITE = register(PromenadeBlocks.BLUNITE) .wall(PromenadeBlocks.BLUNITE_WALL) .stairs(PromenadeBlocks.BLUNITE_STAIRS) .slab(PromenadeBlocks.BLUNITE_SLAB) .polished(PromenadeBlocks.POLISHED_BLUNITE) - .build(); + .getFamily(); public static final BlockFamily POLISHED_BLUNITE = register(PromenadeBlocks.POLISHED_BLUNITE) .stairs(PromenadeBlocks.POLISHED_BLUNITE_STAIRS) .slab(PromenadeBlocks.POLISHED_BLUNITE_SLAB) - .build(); + .getFamily(); public static final BlockFamily SAKURA = register(PromenadeBlocks.SAKURA_PLANKS) .button(PromenadeBlocks.SAKURA_BUTTON) @@ -54,9 +54,9 @@ public class PromenadeBlockFamilies { .stairs(PromenadeBlocks.SAKURA_STAIRS) .door(PromenadeBlocks.SAKURA_DOOR) .trapdoor(PromenadeBlocks.SAKURA_TRAPDOOR) - .group(WOODEN_GROUP) - .unlockCriterionName(WOODEN_UNLOCK_CRITERION_NAME) - .build(); + .recipeGroupPrefix(WOODEN_GROUP) + .recipeUnlockedBy(WOODEN_UNLOCK_CRITERION_NAME) + .getFamily(); public static final BlockFamily MAPLE = register(PromenadeBlocks.MAPLE_PLANKS) .button(PromenadeBlocks.MAPLE_BUTTON) @@ -68,9 +68,9 @@ public class PromenadeBlockFamilies { .stairs(PromenadeBlocks.MAPLE_STAIRS) .door(PromenadeBlocks.MAPLE_DOOR) .trapdoor(PromenadeBlocks.MAPLE_TRAPDOOR) - .group(WOODEN_GROUP) - .unlockCriterionName(WOODEN_UNLOCK_CRITERION_NAME) - .build(); + .recipeGroupPrefix(WOODEN_GROUP) + .recipeUnlockedBy(WOODEN_UNLOCK_CRITERION_NAME) + .getFamily(); public static final BlockFamily PALM = register(PromenadeBlocks.PALM_PLANKS) .button(PromenadeBlocks.PALM_BUTTON) @@ -82,9 +82,9 @@ public class PromenadeBlockFamilies { .stairs(PromenadeBlocks.PALM_STAIRS) .door(PromenadeBlocks.PALM_DOOR) .trapdoor(PromenadeBlocks.PALM_TRAPDOOR) - .group(WOODEN_GROUP) - .unlockCriterionName(WOODEN_UNLOCK_CRITERION_NAME) - .build(); + .recipeGroupPrefix(WOODEN_GROUP) + .recipeUnlockedBy(WOODEN_UNLOCK_CRITERION_NAME) + .getFamily(); public static final BlockFamily DARK_AMARANTH = register(PromenadeBlocks.DARK_AMARANTH_PLANKS) .button(PromenadeBlocks.DARK_AMARANTH_BUTTON) @@ -96,16 +96,16 @@ public class PromenadeBlockFamilies { .stairs(PromenadeBlocks.DARK_AMARANTH_STAIRS) .door(PromenadeBlocks.DARK_AMARANTH_DOOR) .trapdoor(PromenadeBlocks.DARK_AMARANTH_TRAPDOOR) - .group(WOODEN_GROUP) - .unlockCriterionName(WOODEN_UNLOCK_CRITERION_NAME) - .build(); + .recipeGroupPrefix(WOODEN_GROUP) + .recipeUnlockedBy(WOODEN_UNLOCK_CRITERION_NAME) + .getFamily(); public static BlockFamily.Builder register(Block baseBlock) { BlockFamily.Builder builder = new BlockFamily.Builder(baseBlock); - BlockFamily blockFamily = BASE_BLOCKS_TO_FAMILIES.put(baseBlock, builder.build()); + BlockFamily blockFamily = BASE_BLOCKS_TO_FAMILIES.put(baseBlock, builder.getFamily()); if (blockFamily != null) { - throw new IllegalStateException("Duplicate family definition for " + Registries.BLOCK.getId(baseBlock)); + throw new IllegalStateException("Duplicate family definition for " + BuiltInRegistries.BLOCK.getKey(baseBlock)); } else { return builder; } diff --git a/src/datagen/java/fr/hugman/promenade/data/PromenadeDataGenerator.java b/src/datagen/java/fr/hugman/promenade/data/PromenadeDataGenerator.java index 462777e7..ec035309 100644 --- a/src/datagen/java/fr/hugman/promenade/data/PromenadeDataGenerator.java +++ b/src/datagen/java/fr/hugman/promenade/data/PromenadeDataGenerator.java @@ -6,8 +6,8 @@ import fr.hugman.promenade.registry.PromenadeRegistryKeys; import net.fabricmc.fabric.api.datagen.v1.DataGeneratorEntrypoint; import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator; -import net.minecraft.registry.RegistryBuilder; -import net.minecraft.registry.RegistryKeys; +import net.minecraft.core.RegistrySetBuilder; +import net.minecraft.core.registries.Registries; import org.jetbrains.annotations.Nullable; public class PromenadeDataGenerator implements DataGeneratorEntrypoint { @@ -20,7 +20,7 @@ public void onInitializeDataGenerator(FabricDataGenerator fabricDataGenerator) { // Resource Pack pack.addProvider(PromenadeModelProvider::new); pack.addProvider(PromenadeSoundsProvider::new); - pack.addProvider(PromenadeEnglishLangProvider::new); + pack.addProvider(PromenadeEnglishLangProvider::new); // Data Pack @@ -51,6 +51,9 @@ public void onInitializeDataGenerator(FabricDataGenerator fabricDataGenerator) { // - Banner Patterns pack.addProvider(PromenadeBannerPatternProvider::new); + // - Villager Trades + pack.addProvider(PromenadeVillagerTradeProvider::new); + // - Tags var blockTagProvider = pack.addProvider(PromenadeBlockTagProvider::new); pack.addProvider((output, lookup) -> new PromenadeItemTagProvider(output, lookup, blockTagProvider)); @@ -58,6 +61,7 @@ public void onInitializeDataGenerator(FabricDataGenerator fabricDataGenerator) { pack.addProvider(PromenadeEntityTypeTagProvider::new); pack.addProvider(PromenadeBannerPatternTagProvider::new); pack.addProvider(PromenadePaintingVariantTagProvider::new); + pack.addProvider(PromenadeVillagerTradeTagsProvider::new); // - Recipes pack.addProvider(PromenadeRecipeGenerator::create); @@ -67,24 +71,26 @@ public void onInitializeDataGenerator(FabricDataGenerator fabricDataGenerator) { } @Override - public void buildRegistry(RegistryBuilder registryBuilder) { - registryBuilder.addRegistry(PromenadeRegistryKeys.SNOWY_BLOCK_TRANSFORMATION, PromenadeSnowyBlockTransformationProvider::register); + public void buildRegistry(RegistrySetBuilder registryBuilder) { + registryBuilder.add(PromenadeRegistryKeys.SNOWY_BLOCK_TRANSFORMATION, PromenadeSnowyBlockTransformationProvider::register); + + registryBuilder.add(Registries.WOLF_VARIANT, PromenadeWolfVariantProvider::register); + registryBuilder.add(PromenadeRegistryKeys.CAPYBARA_VARIANT, PromenadeCapybaraVariantProvider::register); + registryBuilder.add(PromenadeRegistryKeys.DUCK_VARIANT, PromenadeDuckVariantProvider::register); + registryBuilder.add(PromenadeRegistryKeys.SUNKEN_VARIANT, PromenadeSunkenVariantProvider::register); + registryBuilder.add(Registries.PAINTING_VARIANT, PromenadePaintingVariantProvider::register); - registryBuilder.addRegistry(RegistryKeys.WOLF_VARIANT, PromenadeWolfVariantProvider::register); - registryBuilder.addRegistry(PromenadeRegistryKeys.CAPYBARA_VARIANT, PromenadeCapybaraVariantProvider::register); - registryBuilder.addRegistry(PromenadeRegistryKeys.DUCK_VARIANT, PromenadeDuckVariantProvider::register); - registryBuilder.addRegistry(PromenadeRegistryKeys.SUNKEN_VARIANT, PromenadeSunkenVariantProvider::register); - registryBuilder.addRegistry(RegistryKeys.PAINTING_VARIANT, PromenadePaintingVariantProvider::register); + registryBuilder.add(Registries.TEMPLATE_POOL, PromenadeTemplatePoolProvider::register); + registryBuilder.add(Registries.STRUCTURE, PromenadeStructureProvider::register); + registryBuilder.add(Registries.STRUCTURE_SET, PromenadeStructureSetProvider::register); - registryBuilder.addRegistry(RegistryKeys.TEMPLATE_POOL, PromenadeTemplatePoolProvider::register); - registryBuilder.addRegistry(RegistryKeys.STRUCTURE, PromenadeStructureProvider::register); - registryBuilder.addRegistry(RegistryKeys.STRUCTURE_SET, PromenadeStructureSetProvider::register); + registryBuilder.add(Registries.CONFIGURED_FEATURE, PromenadeConfiguredFeatureProvider::register); + registryBuilder.add(Registries.PLACED_FEATURE, PromenadePlacedFeatureProvider::register); + registryBuilder.add(Registries.BIOME, PromenadeBiomeProvider::register); - registryBuilder.addRegistry(RegistryKeys.CONFIGURED_FEATURE, PromenadeConfiguredFeatureProvider::register); - registryBuilder.addRegistry(RegistryKeys.PLACED_FEATURE, PromenadePlacedFeatureProvider::register); - registryBuilder.addRegistry(RegistryKeys.BIOME, PromenadeBiomeProvider::register); + registryBuilder.add(Registries.BANNER_PATTERN, PromenadeBannerPatternProvider::register); - registryBuilder.addRegistry(RegistryKeys.BANNER_PATTERN, PromenadeBannerPatternProvider::register); + registryBuilder.add(Registries.VILLAGER_TRADE, PromenadeVillagerTradeProvider::register); } @Override diff --git a/src/datagen/java/fr/hugman/promenade/data/model/PromenadeModels.java b/src/datagen/java/fr/hugman/promenade/data/model/PromenadeModels.java index d701533a..f3aa30d2 100644 --- a/src/datagen/java/fr/hugman/promenade/data/model/PromenadeModels.java +++ b/src/datagen/java/fr/hugman/promenade/data/model/PromenadeModels.java @@ -1,33 +1,33 @@ package fr.hugman.promenade.data.model; import fr.hugman.promenade.Promenade; -import net.minecraft.client.data.Model; -import net.minecraft.client.data.TextureKey; +import net.minecraft.client.data.models.model.ModelTemplate; +import net.minecraft.client.data.models.model.TextureSlot; import java.util.Optional; public class PromenadeModels { - public static final Model PILE = block("pile", TextureKey.ALL); - public static final Model FALLEN_LEAVES = block("fallen_leaves", TextureKey.ALL); - public static final Model BOTTOM_SNOWY_LEAVES = block("bottom_snowy_leaves", TextureKey.ALL, TextureKey.TOP, TextureKey.SIDE); + public static final ModelTemplate PILE = block("pile", TextureSlot.ALL); + public static final ModelTemplate FALLEN_LEAVES = block("fallen_leaves", TextureSlot.ALL); + public static final ModelTemplate BOTTOM_SNOWY_LEAVES = block("bottom_snowy_leaves", TextureSlot.ALL, TextureSlot.TOP, TextureSlot.SIDE); - private static Model make(TextureKey... requiredTextureKeys) { - return new Model(Optional.empty(), Optional.empty(), requiredTextureKeys); + private static ModelTemplate make(TextureSlot... requiredTextureKeys) { + return new ModelTemplate(Optional.empty(), Optional.empty(), requiredTextureKeys); } - private static Model block(String parent, TextureKey... requiredTextureKeys) { - return new Model(Optional.of(Promenade.id("block/" + parent)), Optional.empty(), requiredTextureKeys); + private static ModelTemplate block(String parent, TextureSlot... requiredTextureKeys) { + return new ModelTemplate(Optional.of(Promenade.id("block/" + parent)), Optional.empty(), requiredTextureKeys); } - private static Model item(String parent, TextureKey... requiredTextureKeys) { - return new Model(Optional.of(Promenade.id("item/" + parent)), Optional.empty(), requiredTextureKeys); + private static ModelTemplate item(String parent, TextureSlot... requiredTextureKeys) { + return new ModelTemplate(Optional.of(Promenade.id("item/" + parent)), Optional.empty(), requiredTextureKeys); } - private static Model openBundle(String parent, String variant, TextureKey... requiredTextureKeys) { - return new Model(Optional.of(Promenade.id("item/" + parent)), Optional.of(variant), requiredTextureKeys); + private static ModelTemplate openBundle(String parent, String variant, TextureSlot... requiredTextureKeys) { + return new ModelTemplate(Optional.of(Promenade.id("item/" + parent)), Optional.of(variant), requiredTextureKeys); } - private static Model block(String parent, String variant, TextureKey... requiredTextureKeys) { - return new Model(Optional.of(Promenade.id("block/" + parent)), Optional.of(variant), requiredTextureKeys); + private static ModelTemplate block(String parent, String variant, TextureSlot... requiredTextureKeys) { + return new ModelTemplate(Optional.of(Promenade.id("block/" + parent)), Optional.of(variant), requiredTextureKeys); } } diff --git a/src/datagen/java/fr/hugman/promenade/data/model/PromenadeTextureMaps.java b/src/datagen/java/fr/hugman/promenade/data/model/PromenadeTextureMaps.java index ff91932b..3d20aa77 100644 --- a/src/datagen/java/fr/hugman/promenade/data/model/PromenadeTextureMaps.java +++ b/src/datagen/java/fr/hugman/promenade/data/model/PromenadeTextureMaps.java @@ -1,24 +1,25 @@ package fr.hugman.promenade.data.model; -import net.minecraft.block.Block; -import net.minecraft.client.data.TextureKey; -import net.minecraft.client.data.TextureMap; -import net.minecraft.util.Identifier; +import net.minecraft.client.data.models.model.TextureMapping; +import net.minecraft.client.data.models.model.TextureSlot; +import net.minecraft.client.resources.model.sprite.Material; +import net.minecraft.resources.Identifier; +import net.minecraft.world.level.block.Block; public class PromenadeTextureMaps { - public static TextureMap snowyLeaves(Block snowyLeaves, Block baseLeaves) { - return new TextureMap() - .put(TextureKey.ALL, TextureMap.getId(baseLeaves)) - .put(TextureKey.TOP, TextureMap.getId(snowyLeaves)) - .put(TextureKey.SIDE, TextureMap.getSubId(snowyLeaves, "_bottom")); + public static TextureMapping snowyLeaves(Block snowyLeaves, Block baseLeaves) { + return new TextureMapping() + .put(TextureSlot.ALL, TextureMapping.getBlockTexture(baseLeaves)) + .put(TextureSlot.TOP, TextureMapping.getBlockTexture(snowyLeaves)) + .put(TextureSlot.SIDE, TextureMapping.getBlockTexture(snowyLeaves, "_bottom")); } - public static TextureMap snowyLeaves(Identifier snowyLeavesTexture, Block baseLeaves) { + public static TextureMapping snowyLeaves(Identifier snowyLeavesTexture, Block baseLeaves) { - return new TextureMap() - .put(TextureKey.ALL, TextureMap.getId(baseLeaves)) - .put(TextureKey.TOP, snowyLeavesTexture) - .put(TextureKey.SIDE, snowyLeavesTexture.withSuffixedPath("_bottom")); + return new TextureMapping() + .put(TextureSlot.ALL, TextureMapping.getBlockTexture(baseLeaves)) + .put(TextureSlot.TOP, new Material(snowyLeavesTexture)) + .put(TextureSlot.SIDE, new Material(snowyLeavesTexture.withSuffix("_bottom"))); } } diff --git a/src/datagen/java/fr/hugman/promenade/data/model/PromenadeTexturedModels.java b/src/datagen/java/fr/hugman/promenade/data/model/PromenadeTexturedModels.java index cf8e869a..11622a22 100644 --- a/src/datagen/java/fr/hugman/promenade/data/model/PromenadeTexturedModels.java +++ b/src/datagen/java/fr/hugman/promenade/data/model/PromenadeTexturedModels.java @@ -1,18 +1,18 @@ package fr.hugman.promenade.data.model; -import net.minecraft.block.Block; -import net.minecraft.client.data.TextureMap; -import net.minecraft.client.data.TexturedModel; +import net.minecraft.client.data.models.model.TextureMapping; +import net.minecraft.client.data.models.model.TexturedModel; +import net.minecraft.world.level.block.Block; public class PromenadeTexturedModels { - public static final TexturedModel.Factory PILE = TexturedModel.makeFactory(TextureMap::all, PromenadeModels.PILE); - public static final TexturedModel.Factory FALLEN_LEAVES = TexturedModel.makeFactory(TextureMap::all, PromenadeModels.FALLEN_LEAVES); + public static final TexturedModel.Provider PILE = TexturedModel.createDefault(TextureMapping::cube, PromenadeModels.PILE); + public static final TexturedModel.Provider FALLEN_LEAVES = TexturedModel.createDefault(TextureMapping::cube, PromenadeModels.FALLEN_LEAVES); - public static TexturedModel.Factory pile(Block block) { - return TexturedModel.makeFactory(b -> TextureMap.all(block), PromenadeModels.PILE); + public static TexturedModel.Provider pile(Block block) { + return TexturedModel.createDefault(b -> TextureMapping.cube(block), PromenadeModels.PILE); } - public static TexturedModel.Factory fallenLeaves(Block block) { - return TexturedModel.makeFactory(b -> TextureMap.all(block), PromenadeModels.FALLEN_LEAVES); + public static TexturedModel.Provider fallenLeaves(Block block) { + return TexturedModel.createDefault(b -> TextureMapping.cube(block), PromenadeModels.FALLEN_LEAVES); } } diff --git a/src/datagen/java/fr/hugman/promenade/data/provider/DataProviderUtil.java b/src/datagen/java/fr/hugman/promenade/data/provider/DataProviderUtil.java index 11f6a1b5..b918b77b 100644 --- a/src/datagen/java/fr/hugman/promenade/data/provider/DataProviderUtil.java +++ b/src/datagen/java/fr/hugman/promenade/data/provider/DataProviderUtil.java @@ -1,12 +1,12 @@ package fr.hugman.promenade.data.provider; -import net.minecraft.entity.spawn.BiomeSpawnCondition; -import net.minecraft.entity.spawn.SpawnConditionSelectors; -import net.minecraft.registry.entry.RegistryEntryList; -import net.minecraft.world.biome.Biome; +import net.minecraft.core.HolderSet; +import net.minecraft.world.entity.variant.BiomeCheck; +import net.minecraft.world.entity.variant.SpawnPrioritySelectors; +import net.minecraft.world.level.biome.Biome; public final class DataProviderUtil { - public static SpawnConditionSelectors createSpawnConditions(RegistryEntryList requiredBiomes) { - return SpawnConditionSelectors.createSingle(new BiomeSpawnCondition(requiredBiomes), 1); + public static SpawnPrioritySelectors createSpawnConditions(HolderSet requiredBiomes) { + return SpawnPrioritySelectors.single(new BiomeCheck(requiredBiomes), 1); } } diff --git a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeAdvancementProvider.java b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeAdvancementProvider.java index 11610a58..a4d98e3e 100644 --- a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeAdvancementProvider.java +++ b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeAdvancementProvider.java @@ -4,36 +4,27 @@ import fr.hugman.promenade.block.PromenadeBlocks; import fr.hugman.promenade.entity.PromenadeEntityTypes; import fr.hugman.promenade.item.PromenadeItems; -import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; +import net.fabricmc.fabric.api.datagen.v1.FabricPackOutput; import net.fabricmc.fabric.api.datagen.v1.provider.FabricAdvancementProvider; -import net.minecraft.advancement.*; -import net.minecraft.advancement.criterion.Criteria; -import net.minecraft.advancement.criterion.ItemCriterion; -import net.minecraft.advancement.criterion.KilledByArrowCriterion; -import net.minecraft.block.Block; -import net.minecraft.entity.EntityType; -import net.minecraft.fluid.Fluid; -import net.minecraft.item.Item; -import net.minecraft.item.Items; -import net.minecraft.loot.condition.EntityPropertiesLootCondition; -import net.minecraft.loot.condition.InvertedLootCondition; -import net.minecraft.loot.condition.LocationCheckLootCondition; -import net.minecraft.loot.condition.MatchToolLootCondition; -import net.minecraft.loot.context.LootContext; -import net.minecraft.predicate.BlockPredicate; -import net.minecraft.predicate.FluidPredicate; -import net.minecraft.predicate.NumberRange; -import net.minecraft.predicate.entity.EntityPredicate; -import net.minecraft.predicate.entity.LocationPredicate; -import net.minecraft.predicate.entity.LootContextPredicate; -import net.minecraft.predicate.item.ItemPredicate; -import net.minecraft.registry.RegistryEntryLookup; -import net.minecraft.registry.RegistryKeys; -import net.minecraft.registry.RegistryWrapper; -import net.minecraft.registry.tag.FluidTags; -import net.minecraft.text.Text; -import net.minecraft.util.Identifier; -import net.minecraft.util.math.BlockPos; +import net.minecraft.advancements.*; +import net.minecraft.advancements.criterion.*; +import net.minecraft.core.BlockPos; +import net.minecraft.core.HolderGetter; +import net.minecraft.core.HolderLookup; +import net.minecraft.core.registries.Registries; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.Identifier; +import net.minecraft.tags.FluidTags; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.Items; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.world.level.storage.loot.predicates.InvertedLootItemCondition; +import net.minecraft.world.level.storage.loot.predicates.LocationCheck; +import net.minecraft.world.level.storage.loot.predicates.LootItemEntityPropertyCondition; +import net.minecraft.world.level.storage.loot.predicates.MatchTool; import java.util.List; import java.util.Optional; @@ -41,76 +32,76 @@ import java.util.function.Consumer; public class PromenadeAdvancementProvider extends FabricAdvancementProvider { - public PromenadeAdvancementProvider(FabricDataOutput output, CompletableFuture registryLookup) { + public PromenadeAdvancementProvider(FabricPackOutput output, CompletableFuture registryLookup) { super(output, registryLookup); } @Override - public void generateAdvancement(RegistryWrapper.WrapperLookup wrapperLookup, Consumer consumer) { - final var entities = wrapperLookup.getOrThrow(RegistryKeys.ENTITY_TYPE); - final var fluids = wrapperLookup.getOrThrow(RegistryKeys.FLUID); - final var blocks = wrapperLookup.getOrThrow(RegistryKeys.BLOCK); - final var items = wrapperLookup.getOrThrow(RegistryKeys.ITEM); + public void generateAdvancement(HolderLookup.Provider wrapperLookup, Consumer consumer) { + final var entities = wrapperLookup.lookupOrThrow(Registries.ENTITY_TYPE); + final var fluids = wrapperLookup.lookupOrThrow(Registries.FLUID); + final var blocks = wrapperLookup.lookupOrThrow(Registries.BLOCK); + final var items = wrapperLookup.lookupOrThrow(Registries.ITEM); - Advancement.Builder.create() + Advancement.Builder.advancement() .display( PromenadeItems.MAPLE_SYRUP_BOTTLE, - Text.translatable("advancements.promenade.husbandry.harvest_maple_syrup.title"), - Text.translatable("advancements.promenade.husbandry.harvest_maple_syrup.description"), + Component.translatable("advancements.promenade.husbandry.harvest_maple_syrup.title"), + Component.translatable("advancements.promenade.husbandry.harvest_maple_syrup.description"), null, - AdvancementFrame.TASK, + AdvancementType.TASK, true, true, false ) - .parent(Identifier.of("husbandry/safely_harvest_honey")) - .criterion("harvest_maple_syrup", createPickMapleSyrup(blocks, items)) - .build(consumer, Promenade.MOD_ID + ":husbandry/harvest_maple_syrup"); - Advancement.Builder.create() + .parent(Identifier.parse("husbandry/safely_harvest_honey")) + .addCriterion("harvest_maple_syrup", createPickMapleSyrup(blocks, items)) + .save(consumer, Promenade.MOD_ID + ":husbandry/harvest_maple_syrup"); + Advancement.Builder.advancement() .display( Items.FIRE_CORAL, - Text.translatable("advancements.promenade.adventure.kill_sunken_outside_water.title"), - Text.translatable("advancements.promenade.adventure.kill_sunken_outside_water.description"), + Component.translatable("advancements.promenade.adventure.kill_sunken_outside_water.title"), + Component.translatable("advancements.promenade.adventure.kill_sunken_outside_water.description"), null, - AdvancementFrame.CHALLENGE, + AdvancementType.CHALLENGE, true, true, false ) - .parent(Identifier.of("adventure/whos_the_pillager_now")) - .criterion("kill_sunken_outside_water", createCrossbowSunkenOutsideWaterFromWater(fluids, entities)) + .parent(Identifier.parse("adventure/whos_the_pillager_now")) + .addCriterion("kill_sunken_outside_water", createCrossbowSunkenOutsideWaterFromWater(fluids, entities)) .rewards(AdvancementRewards.Builder.experience(65)) - .build(consumer, Promenade.MOD_ID + ":adventure/kill_sunken_outside_water"); + .save(consumer, Promenade.MOD_ID + ":adventure/kill_sunken_outside_water"); } - public static AdvancementCriterion createCrossbowSunkenOutsideWaterFromWater(RegistryEntryLookup fluids, RegistryEntryLookup> entities) { - return Criteria.KILLED_BY_ARROW.create( - new KilledByArrowCriterion.Conditions( + public static Criterion createCrossbowSunkenOutsideWaterFromWater(HolderGetter fluids, HolderGetter> entities) { + return CriteriaTriggers.KILLED_BY_ARROW.createCriterion( + new KilledByArrowTrigger.TriggerInstance( // player is in water - Optional.of(LootContextPredicate.create(LocationCheckLootCondition.builder(LocationPredicate.Builder.create().fluid(FluidPredicate.Builder.create().tag(fluids.getOrThrow(FluidTags.WATER))), new BlockPos(0, 1, 0)).build())), + Optional.of(ContextAwarePredicate.create(LocationCheck.checkLocation(LocationPredicate.Builder.location().setFluid(FluidPredicate.Builder.fluid().of(fluids.getOrThrow(FluidTags.WATER))), new BlockPos(0, 1, 0)).build())), // entity is a sunken and is outside water - List.of(LootContextPredicate.create( - EntityPropertiesLootCondition.builder(LootContext.EntityReference.THIS, EntityPredicate.Builder.create().type(entities, PromenadeEntityTypes.SUNKEN)).build(), - InvertedLootCondition.builder(EntityPropertiesLootCondition.builder(LootContext.EntityReference.THIS, - EntityPredicate.Builder.create().location(LocationPredicate.Builder.create().fluid(FluidPredicate.Builder.create().tag(fluids.getOrThrow(FluidTags.WATER)))) + List.of(ContextAwarePredicate.create( + LootItemEntityPropertyCondition.hasProperties(LootContext.EntityTarget.THIS, EntityPredicate.Builder.entity().of(entities, PromenadeEntityTypes.SUNKEN)).build(), + InvertedLootItemCondition.invert(LootItemEntityPropertyCondition.hasProperties(LootContext.EntityTarget.THIS, + EntityPredicate.Builder.entity().located(LocationPredicate.Builder.location().setFluid(FluidPredicate.Builder.fluid().of(fluids.getOrThrow(FluidTags.WATER)))) )).build() )), - NumberRange.IntRange.ANY, + MinMaxBounds.Ints.ANY, Optional.empty() ) ); } - public static AdvancementCriterion createPickMapleSyrup(RegistryEntryLookup blocks, RegistryEntryLookup items) { - return Criteria.ITEM_USED_ON_BLOCK.create( - new ItemCriterion.Conditions( + public static Criterion createPickMapleSyrup(HolderGetter blocks, HolderGetter items) { + return CriteriaTriggers.ITEM_USED_ON_BLOCK.createCriterion( + new ItemUsedOnLocationTrigger.TriggerInstance( Optional.empty(), - Optional.of(LootContextPredicate.create( - LocationCheckLootCondition.builder(LocationPredicate.Builder.create().block(BlockPredicate.Builder.create().blocks(blocks, PromenadeBlocks.STRIPPED_MAPLE_LOG))).build(), - MatchToolLootCondition.builder(ItemPredicate.Builder.create().items(items, Items.GLASS_BOTTLE)).build() + Optional.of(ContextAwarePredicate.create( + LocationCheck.checkLocation(LocationPredicate.Builder.location().setBlock(BlockPredicate.Builder.block().of(blocks, PromenadeBlocks.STRIPPED_MAPLE_LOG))).build(), + MatchTool.toolMatches(ItemPredicate.Builder.item().of(items, Items.GLASS_BOTTLE)).build() )) ) ); diff --git a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeBannerPatternProvider.java b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeBannerPatternProvider.java index ab51eb4b..7b95750a 100644 --- a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeBannerPatternProvider.java +++ b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeBannerPatternProvider.java @@ -1,24 +1,24 @@ package fr.hugman.promenade.data.provider; import fr.hugman.promenade.banner.PromenadeBannerPatterns; -import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; +import net.fabricmc.fabric.api.datagen.v1.FabricPackOutput; import net.fabricmc.fabric.api.datagen.v1.provider.FabricDynamicRegistryProvider; -import net.minecraft.block.entity.BannerPattern; -import net.minecraft.registry.Registerable; -import net.minecraft.registry.RegistryKey; -import net.minecraft.registry.RegistryKeys; -import net.minecraft.registry.RegistryWrapper; +import net.minecraft.core.HolderLookup; +import net.minecraft.core.registries.Registries; +import net.minecraft.data.worldgen.BootstrapContext; +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.level.block.entity.BannerPattern; import java.util.concurrent.CompletableFuture; public class PromenadeBannerPatternProvider extends FabricDynamicRegistryProvider { - public PromenadeBannerPatternProvider(FabricDataOutput output, CompletableFuture registriesFuture) { + public PromenadeBannerPatternProvider(FabricPackOutput output, CompletableFuture registriesFuture) { super(output, registriesFuture); } @Override - protected void configure(RegistryWrapper.WrapperLookup registries, Entries entries) { - entries.addAll(registries.getOrThrow(RegistryKeys.BANNER_PATTERN)); + protected void configure(HolderLookup.Provider registries, Entries entries) { + entries.addAll(registries.lookupOrThrow(Registries.BANNER_PATTERN)); } @Override @@ -26,12 +26,12 @@ public String getName() { return "Banner Patterns"; } - public static void register(Registerable registerable) { + public static void register(BootstrapContext registerable) { of(registerable, PromenadeBannerPatterns.BOVINE); } - public static void of(Registerable registerable, RegistryKey key) { - registerable.register(key, new BannerPattern(key.getValue(), "block.promenade.banner." + key.getValue().getPath())); + public static void of(BootstrapContext registerable, ResourceKey key) { + registerable.register(key, new BannerPattern(key.identifier(), "block.promenade.banner." + key.identifier().getPath())); } } \ No newline at end of file diff --git a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeBannerPatternTagProvider.java b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeBannerPatternTagProvider.java index 91fa07fc..3a76fb91 100644 --- a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeBannerPatternTagProvider.java +++ b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeBannerPatternTagProvider.java @@ -2,21 +2,21 @@ import fr.hugman.promenade.banner.PromenadeBannerPatternTags; import fr.hugman.promenade.banner.PromenadeBannerPatterns; -import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; -import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider; -import net.minecraft.block.entity.BannerPattern; -import net.minecraft.registry.RegistryKeys; -import net.minecraft.registry.RegistryWrapper; +import net.fabricmc.fabric.api.datagen.v1.FabricPackOutput; +import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagsProvider; +import net.minecraft.core.HolderLookup; +import net.minecraft.core.registries.Registries; +import net.minecraft.world.level.block.entity.BannerPattern; import java.util.concurrent.CompletableFuture; -public class PromenadeBannerPatternTagProvider extends FabricTagProvider { - public PromenadeBannerPatternTagProvider(FabricDataOutput output, CompletableFuture registriesFuture) { - super(output, RegistryKeys.BANNER_PATTERN, registriesFuture); +public class PromenadeBannerPatternTagProvider extends FabricTagsProvider { + public PromenadeBannerPatternTagProvider(FabricPackOutput output, CompletableFuture registriesFuture) { + super(output, Registries.BANNER_PATTERN, registriesFuture); } @Override - protected void configure(RegistryWrapper.WrapperLookup wrapperLookup) { + protected void addTags(HolderLookup.Provider wrapperLookup) { // Promenade builder(PromenadeBannerPatternTags.BOVINE_PATTERN_ITEM).add(PromenadeBannerPatterns.BOVINE); } diff --git a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeBiomeProvider.java b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeBiomeProvider.java index b215bf62..fe29220e 100644 --- a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeBiomeProvider.java +++ b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeBiomeProvider.java @@ -4,38 +4,43 @@ import fr.hugman.promenade.sound.PromenadeSoundEvents; import fr.hugman.promenade.world.biome.PromenadeBiomes; import fr.hugman.promenade.world.gen.feature.PromenadePlacedFeatures; -import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; +import net.fabricmc.fabric.api.datagen.v1.FabricPackOutput; import net.fabricmc.fabric.api.datagen.v1.provider.FabricDynamicRegistryProvider; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.SpawnGroup; -import net.minecraft.particle.ParticleTypes; -import net.minecraft.registry.*; -import net.minecraft.sound.BiomeAdditionsSound; -import net.minecraft.sound.BiomeMoodSound; -import net.minecraft.sound.MusicType; -import net.minecraft.sound.SoundEvents; -import net.minecraft.world.attribute.AmbientParticle; -import net.minecraft.world.attribute.AmbientSounds; -import net.minecraft.world.attribute.BackgroundMusic; -import net.minecraft.world.attribute.EnvironmentAttributes; -import net.minecraft.world.biome.*; -import net.minecraft.world.gen.GenerationStep; -import net.minecraft.world.gen.carver.ConfiguredCarver; -import net.minecraft.world.gen.carver.ConfiguredCarvers; -import net.minecraft.world.gen.feature.*; +import net.minecraft.core.HolderGetter; +import net.minecraft.core.HolderLookup; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.core.registries.Registries; +import net.minecraft.data.worldgen.BiomeDefaultFeatures; +import net.minecraft.data.worldgen.BootstrapContext; +import net.minecraft.data.worldgen.Carvers; +import net.minecraft.data.worldgen.biome.OverworldBiomes; +import net.minecraft.data.worldgen.placement.*; +import net.minecraft.resources.ResourceKey; +import net.minecraft.sounds.Musics; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.world.attribute.*; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.MobCategory; +import net.minecraft.world.level.biome.Biome; +import net.minecraft.world.level.biome.BiomeGenerationSettings; +import net.minecraft.world.level.biome.BiomeSpecialEffects; +import net.minecraft.world.level.biome.MobSpawnSettings; +import net.minecraft.world.level.levelgen.GenerationStep; +import net.minecraft.world.level.levelgen.carver.ConfiguredWorldCarver; +import net.minecraft.world.level.levelgen.placement.PlacedFeature; import java.util.List; import java.util.Optional; import java.util.concurrent.CompletableFuture; public class PromenadeBiomeProvider extends FabricDynamicRegistryProvider { - public PromenadeBiomeProvider(FabricDataOutput output, CompletableFuture registriesFuture) { + public PromenadeBiomeProvider(FabricPackOutput output, CompletableFuture registriesFuture) { super(output, registriesFuture); } @Override - protected void configure(RegistryWrapper.WrapperLookup registries, Entries entries) { - entries.addAll(registries.getOrThrow(RegistryKeys.BIOME)); + protected void configure(HolderLookup.Provider registries, Entries entries) { + entries.addAll(registries.lookupOrThrow(Registries.BIOME)); } @Override @@ -43,9 +48,9 @@ public String getName() { return "Biomes"; } - public static void register(Registerable registerable) { - final var features = registerable.getRegistryLookup(RegistryKeys.PLACED_FEATURE); - final var carvers = registerable.getRegistryLookup(RegistryKeys.CONFIGURED_CARVER); + public static void register(BootstrapContext registerable) { + final var features = registerable.lookup(Registries.PLACED_FEATURE); + final var carvers = registerable.lookup(Registries.CONFIGURED_CARVER); registerable.register(PromenadeBiomes.BLUSH_SAKURA_GROVE, createSakuraGroves(features, carvers, PromenadePlacedFeatures.BLUSH_SAKURA_GROVE_TREES)); registerable.register(PromenadeBiomes.COTTON_SAKURA_GROVE, createSakuraGroves(features, carvers, PromenadePlacedFeatures.COTTON_SAKURA_GROVE_TREES)); @@ -56,199 +61,199 @@ public static void register(Registerable registerable) { registerable.register(PromenadeBiomes.DARK_AMARANTH_FOREST, createDarkAmaranthForest(features, carvers)); } - public static Biome createSakuraGroves(RegistryEntryLookup features, RegistryEntryLookup> carvers, RegistryKey trees) { - GenerationSettings.LookupBackedBuilder generation = new GenerationSettings.LookupBackedBuilder(features, carvers); + public static Biome createSakuraGroves(HolderGetter features, HolderGetter> carvers, ResourceKey trees) { + BiomeGenerationSettings.Builder generation = new BiomeGenerationSettings.Builder(features, carvers); addBasicFeatures(generation); - generation.feature(GenerationStep.Feature.VEGETAL_DECORATION, PromenadePlacedFeatures.WATER_POOLS_GRAVEL_DECORATED); - generation.feature(GenerationStep.Feature.LOCAL_MODIFICATIONS, PromenadePlacedFeatures.CUTE_LITTLE_ROCKS); + generation.addFeature(GenerationStep.Decoration.VEGETAL_DECORATION, PromenadePlacedFeatures.WATER_POOLS_GRAVEL_DECORATED); + generation.addFeature(GenerationStep.Decoration.LOCAL_MODIFICATIONS, PromenadePlacedFeatures.CUTE_LITTLE_ROCKS); - DefaultBiomeFeatures.addForestFlowers(generation); + BiomeDefaultFeatures.addForestFlowers(generation); - DefaultBiomeFeatures.addDefaultOres(generation); - DefaultBiomeFeatures.addDefaultDisks(generation); + BiomeDefaultFeatures.addDefaultOres(generation); + BiomeDefaultFeatures.addDefaultSoftDisks(generation); - generation.feature(GenerationStep.Feature.VEGETAL_DECORATION, PromenadePlacedFeatures.SAKURA_GROVE_BAMBOO); + generation.addFeature(GenerationStep.Decoration.VEGETAL_DECORATION, PromenadePlacedFeatures.SAKURA_GROVE_BAMBOO); - DefaultBiomeFeatures.addDefaultFlowers(generation); - DefaultBiomeFeatures.addForestGrass(generation); + BiomeDefaultFeatures.addDefaultFlowers(generation); + BiomeDefaultFeatures.addForestGrass(generation); - generation.feature(GenerationStep.Feature.VEGETAL_DECORATION, VegetationPlacedFeatures.PATCH_WATERLILY); + generation.addFeature(GenerationStep.Decoration.VEGETAL_DECORATION, VegetationPlacements.PATCH_WATERLILY); - DefaultBiomeFeatures.addDefaultMushrooms(generation); - DefaultBiomeFeatures.addDefaultVegetation(generation, true); + BiomeDefaultFeatures.addDefaultMushrooms(generation); + BiomeDefaultFeatures.addDefaultExtraVegetation(generation, true); - generation.feature(GenerationStep.Feature.VEGETAL_DECORATION, trees); + generation.addFeature(GenerationStep.Decoration.VEGETAL_DECORATION, trees); - SpawnSettings.Builder spawns = new SpawnSettings.Builder(); + MobSpawnSettings.Builder spawns = new MobSpawnSettings.Builder(); - DefaultBiomeFeatures.addFarmAnimals(spawns); - DefaultBiomeFeatures.addCaveAndMonsters(spawns); - spawns.spawn(SpawnGroup.CREATURE, 5, new SpawnSettings.SpawnEntry(EntityType.WOLF, 4, 4)); - spawns.spawn(SpawnGroup.CREATURE, 16, new SpawnSettings.SpawnEntry(EntityType.FOX, 1, 3)); - spawns.spawn(SpawnGroup.CREATURE, 2, new SpawnSettings.SpawnEntry(EntityType.PANDA, 4, 5)); + BiomeDefaultFeatures.farmAnimals(spawns); + BiomeDefaultFeatures.commonSpawns(spawns); + spawns.addSpawn(MobCategory.CREATURE, 5, new MobSpawnSettings.SpawnerData(EntityType.WOLF, 4, 4)); + spawns.addSpawn(MobCategory.CREATURE, 16, new MobSpawnSettings.SpawnerData(EntityType.FOX, 1, 3)); + spawns.addSpawn(MobCategory.CREATURE, 2, new MobSpawnSettings.SpawnerData(EntityType.PANDA, 4, 5)); - return biome(0.6F, 0.4F) - .spawnSettings(spawns.build()) - .generationSettings(generation.build()) - .effects(new BiomeEffects.Builder() - .waterColor(6459391) - .grassColor(6484135) - .build()) - .setEnvironmentAttribute(EnvironmentAttributes.BACKGROUND_MUSIC_AUDIO, new BackgroundMusic(MusicType.createIngameMusic(PromenadeSoundEvents.MUSIC_OVERWORLD_SAKURA_GROVES))) - .build(); + return biome(0.6F, 0.4F) + .mobSpawnSettings(spawns.build()) + .generationSettings(generation.build()) + .specialEffects(new BiomeSpecialEffects.Builder() + .waterColor(6459391) + .grassColorOverride(6484135) + .build()) + .setAttribute(EnvironmentAttributes.BACKGROUND_MUSIC, new BackgroundMusic(Musics.createGameMusic(PromenadeSoundEvents.MUSIC_OVERWORLD_SAKURA_GROVES))) + .build(); } - public static Biome createCarnelianTreeway(RegistryEntryLookup features, RegistryEntryLookup> carvers) { - GenerationSettings.LookupBackedBuilder generation = new GenerationSettings.LookupBackedBuilder(features, carvers); + public static Biome createCarnelianTreeway(HolderGetter features, HolderGetter> carvers) { + BiomeGenerationSettings.Builder generation = new BiomeGenerationSettings.Builder(features, carvers); addBasicFeatures(generation); - DefaultBiomeFeatures.addForestFlowers(generation); + BiomeDefaultFeatures.addForestFlowers(generation); - DefaultBiomeFeatures.addDefaultOres(generation); - DefaultBiomeFeatures.addDefaultDisks(generation); + BiomeDefaultFeatures.addDefaultOres(generation); + BiomeDefaultFeatures.addDefaultSoftDisks(generation); - DefaultBiomeFeatures.addDefaultFlowers(generation); - DefaultBiomeFeatures.addForestGrass(generation); + BiomeDefaultFeatures.addDefaultFlowers(generation); + BiomeDefaultFeatures.addForestGrass(generation); - DefaultBiomeFeatures.addDefaultMushrooms(generation); - DefaultBiomeFeatures.addDefaultVegetation(generation, true); + BiomeDefaultFeatures.addDefaultMushrooms(generation); + BiomeDefaultFeatures.addDefaultExtraVegetation(generation, true); - generation.feature(GenerationStep.Feature.VEGETAL_DECORATION, PromenadePlacedFeatures.CARNELIAN_TREEWAY_TREES); - generation.feature(GenerationStep.Feature.VEGETAL_DECORATION, PromenadePlacedFeatures.CARNELIAN_TREEWAY_FALLEN_LEAVES); + generation.addFeature(GenerationStep.Decoration.VEGETAL_DECORATION, PromenadePlacedFeatures.CARNELIAN_TREEWAY_TREES); + generation.addFeature(GenerationStep.Decoration.VEGETAL_DECORATION, PromenadePlacedFeatures.CARNELIAN_TREEWAY_FALLEN_LEAVES); - SpawnSettings.Builder spawns = new SpawnSettings.Builder(); + MobSpawnSettings.Builder spawns = new MobSpawnSettings.Builder(); - DefaultBiomeFeatures.addFarmAnimals(spawns); - DefaultBiomeFeatures.addCaveAndMonsters(spawns); - spawns.spawn(SpawnGroup.CREATURE, 5, new SpawnSettings.SpawnEntry(EntityType.WOLF, 4, 4)); - spawns.spawn(SpawnGroup.CREATURE, 7, new SpawnSettings.SpawnEntry(EntityType.FOX, 2, 3)); + BiomeDefaultFeatures.farmAnimals(spawns); + BiomeDefaultFeatures.commonSpawns(spawns); + spawns.addSpawn(MobCategory.CREATURE, 5, new MobSpawnSettings.SpawnerData(EntityType.WOLF, 4, 4)); + spawns.addSpawn(MobCategory.CREATURE, 7, new MobSpawnSettings.SpawnerData(EntityType.FOX, 2, 3)); - return biome(1.2F, 0.9F) - .spawnSettings(spawns.build()) - .generationSettings(generation.build()) - .effects(new BiomeEffects.Builder() - .waterColor(155336) - .grassColor(9090320) - .foliageColor(10931465) - .build()) - .setEnvironmentAttribute(EnvironmentAttributes.WATER_FOG_COLOR_VISUAL, 541) - .build(); + return biome(1.2F, 0.9F) + .mobSpawnSettings(spawns.build()) + .generationSettings(generation.build()) + .specialEffects(new BiomeSpecialEffects.Builder() + .waterColor(155336) + .grassColorOverride(9090320) + .foliageColorOverride(10931465) + .build()) + .setAttribute(EnvironmentAttributes.WATER_FOG_COLOR, 541) + .build(); } - public static Biome createGlacarianTaiga(RegistryEntryLookup featureLookup, RegistryEntryLookup> carverLookup) { - GenerationSettings.LookupBackedBuilder generation = new GenerationSettings.LookupBackedBuilder(featureLookup, carverLookup); - - generation.carver(ConfiguredCarvers.CAVE); - generation.carver(ConfiguredCarvers.CAVE_EXTRA_UNDERGROUND); - generation.carver(ConfiguredCarvers.CANYON); - generation.feature(GenerationStep.Feature.LAKES, MiscPlacedFeatures.LAKE_LAVA_UNDERGROUND); - - DefaultBiomeFeatures.addAmethystGeodes(generation); - DefaultBiomeFeatures.addDungeons(generation); - - generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_DIRT); - generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_GRAVEL); - generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_GRANITE_LOWER); - generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_DIORITE_LOWER); - generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_ANDESITE_LOWER); - generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_TUFF); - generation.feature(GenerationStep.Feature.VEGETAL_DECORATION, UndergroundPlacedFeatures.GLOW_LICHEN); - - generation.feature(GenerationStep.Feature.FLUID_SPRINGS, MiscPlacedFeatures.SPRING_WATER); - - generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_COAL_UPPER); - generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_COAL_LOWER); - generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_IRON_UPPER); - generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_IRON_MIDDLE); - generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_IRON_SMALL); - generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_GOLD); - generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_GOLD_LOWER); - generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_REDSTONE); - generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_REDSTONE_LOWER); - generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_DIAMOND); - generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_DIAMOND_MEDIUM); - generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_DIAMOND_LARGE); - generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_DIAMOND_BURIED); - generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_LAPIS); - generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_LAPIS_BURIED); - generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_COPPER); - generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, PromenadePlacedFeatures.PACKED_ICE_ORE); - generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, PromenadePlacedFeatures.BLUE_ICE_ORE); - generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, MiscPlacedFeatures.DISK_CLAY); - generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, MiscPlacedFeatures.DISK_GRAVEL); - - DefaultBiomeFeatures.addInfestedStone(generation); - - generation.feature(GenerationStep.Feature.VEGETAL_DECORATION, PromenadePlacedFeatures.GLACARIAN_TAIGA_TREES); - generation.feature(GenerationStep.Feature.TOP_LAYER_MODIFICATION, PromenadePlacedFeatures.FREEZE_TOP_LAYER); - - SpawnSettings.Builder spawns = new SpawnSettings.Builder() - .spawn(SpawnGroup.CREATURE, 4, new SpawnSettings.SpawnEntry(PromenadeEntityTypes.DUCK, 4, 4)) - .spawn(SpawnGroup.CREATURE, 8, new SpawnSettings.SpawnEntry(EntityType.WOLF, 4, 4)) - .spawn(SpawnGroup.CREATURE, 8, new SpawnSettings.SpawnEntry(EntityType.FOX, 2, 4)); - DefaultBiomeFeatures.addCaveAndMonsters(spawns); - - return biome(- 0.7F, 0.8f) - .spawnSettings(spawns.build()) - .generationSettings(generation.build()) - .effects(new BiomeEffects.Builder() - .waterColor(1724346) - .build()) - .setEnvironmentAttribute(EnvironmentAttributes.FOG_COLOR_VISUAL, 12638463) - .setEnvironmentAttribute(EnvironmentAttributes.WATER_FOG_COLOR_VISUAL, 197394) - .build(); + public static Biome createGlacarianTaiga(HolderGetter featureLookup, HolderGetter> carverLookup) { + BiomeGenerationSettings.Builder generation = new BiomeGenerationSettings.Builder(featureLookup, carverLookup); + + generation.addCarver(Carvers.CAVE); + generation.addCarver(Carvers.CAVE_EXTRA_UNDERGROUND); + generation.addCarver(Carvers.CANYON); + generation.addFeature(GenerationStep.Decoration.LAKES, MiscOverworldPlacements.LAKE_LAVA_UNDERGROUND); + + BiomeDefaultFeatures.addDefaultCrystalFormations(generation); + BiomeDefaultFeatures.addDefaultMonsterRoom(generation); + + generation.addFeature(GenerationStep.Decoration.UNDERGROUND_ORES, OrePlacements.ORE_DIRT); + generation.addFeature(GenerationStep.Decoration.UNDERGROUND_ORES, OrePlacements.ORE_GRAVEL); + generation.addFeature(GenerationStep.Decoration.UNDERGROUND_ORES, OrePlacements.ORE_GRANITE_LOWER); + generation.addFeature(GenerationStep.Decoration.UNDERGROUND_ORES, OrePlacements.ORE_DIORITE_LOWER); + generation.addFeature(GenerationStep.Decoration.UNDERGROUND_ORES, OrePlacements.ORE_ANDESITE_LOWER); + generation.addFeature(GenerationStep.Decoration.UNDERGROUND_ORES, OrePlacements.ORE_TUFF); + generation.addFeature(GenerationStep.Decoration.VEGETAL_DECORATION, CavePlacements.GLOW_LICHEN); + + generation.addFeature(GenerationStep.Decoration.FLUID_SPRINGS, MiscOverworldPlacements.SPRING_WATER); + + generation.addFeature(GenerationStep.Decoration.UNDERGROUND_ORES, OrePlacements.ORE_COAL_UPPER); + generation.addFeature(GenerationStep.Decoration.UNDERGROUND_ORES, OrePlacements.ORE_COAL_LOWER); + generation.addFeature(GenerationStep.Decoration.UNDERGROUND_ORES, OrePlacements.ORE_IRON_UPPER); + generation.addFeature(GenerationStep.Decoration.UNDERGROUND_ORES, OrePlacements.ORE_IRON_MIDDLE); + generation.addFeature(GenerationStep.Decoration.UNDERGROUND_ORES, OrePlacements.ORE_IRON_SMALL); + generation.addFeature(GenerationStep.Decoration.UNDERGROUND_ORES, OrePlacements.ORE_GOLD); + generation.addFeature(GenerationStep.Decoration.UNDERGROUND_ORES, OrePlacements.ORE_GOLD_LOWER); + generation.addFeature(GenerationStep.Decoration.UNDERGROUND_ORES, OrePlacements.ORE_REDSTONE); + generation.addFeature(GenerationStep.Decoration.UNDERGROUND_ORES, OrePlacements.ORE_REDSTONE_LOWER); + generation.addFeature(GenerationStep.Decoration.UNDERGROUND_ORES, OrePlacements.ORE_DIAMOND); + generation.addFeature(GenerationStep.Decoration.UNDERGROUND_ORES, OrePlacements.ORE_DIAMOND_MEDIUM); + generation.addFeature(GenerationStep.Decoration.UNDERGROUND_ORES, OrePlacements.ORE_DIAMOND_LARGE); + generation.addFeature(GenerationStep.Decoration.UNDERGROUND_ORES, OrePlacements.ORE_DIAMOND_BURIED); + generation.addFeature(GenerationStep.Decoration.UNDERGROUND_ORES, OrePlacements.ORE_LAPIS); + generation.addFeature(GenerationStep.Decoration.UNDERGROUND_ORES, OrePlacements.ORE_LAPIS_BURIED); + generation.addFeature(GenerationStep.Decoration.UNDERGROUND_ORES, OrePlacements.ORE_COPPER); + generation.addFeature(GenerationStep.Decoration.UNDERGROUND_ORES, PromenadePlacedFeatures.PACKED_ICE_ORE); + generation.addFeature(GenerationStep.Decoration.UNDERGROUND_ORES, PromenadePlacedFeatures.BLUE_ICE_ORE); + generation.addFeature(GenerationStep.Decoration.UNDERGROUND_ORES, MiscOverworldPlacements.DISK_CLAY); + generation.addFeature(GenerationStep.Decoration.UNDERGROUND_ORES, MiscOverworldPlacements.DISK_GRAVEL); + + BiomeDefaultFeatures.addInfestedStone(generation); + + generation.addFeature(GenerationStep.Decoration.VEGETAL_DECORATION, PromenadePlacedFeatures.GLACARIAN_TAIGA_TREES); + generation.addFeature(GenerationStep.Decoration.TOP_LAYER_MODIFICATION, PromenadePlacedFeatures.FREEZE_TOP_LAYER); + + MobSpawnSettings.Builder spawns = new MobSpawnSettings.Builder() + .addSpawn(MobCategory.CREATURE, 4, new MobSpawnSettings.SpawnerData(PromenadeEntityTypes.DUCK, 4, 4)) + .addSpawn(MobCategory.CREATURE, 8, new MobSpawnSettings.SpawnerData(EntityType.WOLF, 4, 4)) + .addSpawn(MobCategory.CREATURE, 8, new MobSpawnSettings.SpawnerData(EntityType.FOX, 2, 4)); + BiomeDefaultFeatures.commonSpawns(spawns); + + return biome(-0.7F, 0.8f) + .mobSpawnSettings(spawns.build()) + .generationSettings(generation.build()) + .specialEffects(new BiomeSpecialEffects.Builder() + .waterColor(1724346) + .build()) + .setAttribute(EnvironmentAttributes.FOG_COLOR, 12638463) + .setAttribute(EnvironmentAttributes.WATER_FOG_COLOR, 197394) + .build(); } - public static Biome createDarkAmaranthForest(RegistryEntryLookup featureLookup, RegistryEntryLookup> carverLookup) { - SpawnSettings spawnSettings = new SpawnSettings.Builder() - .spawn(SpawnGroup.MONSTER, 1, new SpawnSettings.SpawnEntry(EntityType.ENDERMAN, 4, 4)) - .spawn(SpawnGroup.CREATURE, 60, new SpawnSettings.SpawnEntry(EntityType.STRIDER, 1, 2)) - .spawnCost(EntityType.ENDERMAN, 1.0, 0.12) + public static Biome createDarkAmaranthForest(HolderGetter featureLookup, HolderGetter> carverLookup) { + MobSpawnSettings spawnSettings = new MobSpawnSettings.Builder() + .addSpawn(MobCategory.MONSTER, 1, new MobSpawnSettings.SpawnerData(EntityType.ENDERMAN, 4, 4)) + .addSpawn(MobCategory.CREATURE, 60, new MobSpawnSettings.SpawnerData(EntityType.STRIDER, 1, 2)) + .addMobCharge(EntityType.ENDERMAN, 1.0, 0.12) .build(); - GenerationSettings.LookupBackedBuilder lookupBackedBuilder = new GenerationSettings.LookupBackedBuilder(featureLookup, carverLookup) - .carver(ConfiguredCarvers.NETHER_CAVE) - .feature(GenerationStep.Feature.VEGETAL_DECORATION, MiscPlacedFeatures.SPRING_LAVA); - DefaultBiomeFeatures.addDefaultMushrooms(lookupBackedBuilder); - lookupBackedBuilder.feature(GenerationStep.Feature.UNDERGROUND_DECORATION, NetherPlacedFeatures.SPRING_OPEN) - .feature(GenerationStep.Feature.UNDERGROUND_DECORATION, NetherPlacedFeatures.PATCH_FIRE) - .feature(GenerationStep.Feature.UNDERGROUND_DECORATION, NetherPlacedFeatures.PATCH_SOUL_FIRE) - .feature(GenerationStep.Feature.UNDERGROUND_DECORATION, OrePlacedFeatures.ORE_MAGMA) - .feature(GenerationStep.Feature.UNDERGROUND_DECORATION, NetherPlacedFeatures.SPRING_CLOSED) - .feature(GenerationStep.Feature.VEGETAL_DECORATION, PromenadePlacedFeatures.DARK_AMARANTH_FUNGI) - .feature(GenerationStep.Feature.VEGETAL_DECORATION, PromenadePlacedFeatures.DARK_AMARANTH_FOREST_VEGETATION) - .feature(GenerationStep.Feature.VEGETAL_DECORATION, NetherPlacedFeatures.NETHER_SPROUTS) - .feature(GenerationStep.Feature.VEGETAL_DECORATION, PromenadePlacedFeatures.COILED_VINES); - DefaultBiomeFeatures.addNetherMineables(lookupBackedBuilder); - return new Biome.Builder() - .precipitation(false) + BiomeGenerationSettings.Builder lookupBackedBuilder = new BiomeGenerationSettings.Builder(featureLookup, carverLookup) + .addCarver(Carvers.NETHER_CAVE) + .addFeature(GenerationStep.Decoration.VEGETAL_DECORATION, MiscOverworldPlacements.SPRING_LAVA); + BiomeDefaultFeatures.addDefaultMushrooms(lookupBackedBuilder); + lookupBackedBuilder.addFeature(GenerationStep.Decoration.UNDERGROUND_DECORATION, NetherPlacements.SPRING_OPEN) + .addFeature(GenerationStep.Decoration.UNDERGROUND_DECORATION, NetherPlacements.PATCH_FIRE) + .addFeature(GenerationStep.Decoration.UNDERGROUND_DECORATION, NetherPlacements.PATCH_SOUL_FIRE) + .addFeature(GenerationStep.Decoration.UNDERGROUND_DECORATION, OrePlacements.ORE_MAGMA) + .addFeature(GenerationStep.Decoration.UNDERGROUND_DECORATION, NetherPlacements.SPRING_CLOSED) + .addFeature(GenerationStep.Decoration.VEGETAL_DECORATION, PromenadePlacedFeatures.DARK_AMARANTH_FUNGI) + .addFeature(GenerationStep.Decoration.VEGETAL_DECORATION, PromenadePlacedFeatures.DARK_AMARANTH_FOREST_VEGETATION) + .addFeature(GenerationStep.Decoration.VEGETAL_DECORATION, NetherPlacements.NETHER_SPROUTS) + .addFeature(GenerationStep.Decoration.VEGETAL_DECORATION, PromenadePlacedFeatures.COILED_VINES); + BiomeDefaultFeatures.addNetherDefaultOres(lookupBackedBuilder); + return new Biome.BiomeBuilder() + .hasPrecipitation(false) .temperature(2.0F) .downfall(0.0F) - .effects(new BiomeEffects.Builder().waterColor(4159204).build()) - .setEnvironmentAttribute(EnvironmentAttributes.AMBIENT_PARTICLES_VISUAL, List.of(new AmbientParticle(ParticleTypes.WARPED_SPORE, 0.01428F))) //TODO - .setEnvironmentAttribute(EnvironmentAttributes.FOG_COLOR_VISUAL, 524562) - .setEnvironmentAttribute(EnvironmentAttributes.AMBIENT_SOUNDS_AUDIO, new AmbientSounds( - Optional.of(SoundEvents.AMBIENT_WARPED_FOREST_LOOP), - Optional.of(new BiomeMoodSound(SoundEvents.AMBIENT_WARPED_FOREST_MOOD, 6000, 8, 2.0)), - List.of(new BiomeAdditionsSound(SoundEvents.AMBIENT_WARPED_FOREST_ADDITIONS, 0.0111)) - )) - .setEnvironmentAttribute(EnvironmentAttributes.BACKGROUND_MUSIC_AUDIO, new BackgroundMusic(MusicType.createIngameMusic(SoundEvents.MUSIC_NETHER_WARPED_FOREST))) - .spawnSettings(spawnSettings) + .specialEffects(new BiomeSpecialEffects.Builder().waterColor(4159204).build()) + .setAttribute(EnvironmentAttributes.AMBIENT_PARTICLES, List.of(new AmbientParticle(ParticleTypes.WARPED_SPORE, 0.01428F))) //TODO + .setAttribute(EnvironmentAttributes.FOG_COLOR, 524562) + .setAttribute(EnvironmentAttributes.AMBIENT_SOUNDS, new AmbientSounds( + Optional.of(SoundEvents.AMBIENT_WARPED_FOREST_LOOP), + Optional.of(new AmbientMoodSettings(SoundEvents.AMBIENT_WARPED_FOREST_MOOD, 6000, 8, 2.0)), + List.of(new AmbientAdditionsSettings(SoundEvents.AMBIENT_WARPED_FOREST_ADDITIONS, 0.0111)) + )) + .setAttribute(EnvironmentAttributes.BACKGROUND_MUSIC, new BackgroundMusic(Musics.createGameMusic(SoundEvents.MUSIC_BIOME_WARPED_FOREST))) + .mobSpawnSettings(spawnSettings) .generationSettings(lookupBackedBuilder.build()) .build(); } - private static void addBasicFeatures(GenerationSettings.LookupBackedBuilder generationSettings) { - DefaultBiomeFeatures.addLandCarvers(generationSettings); - DefaultBiomeFeatures.addAmethystGeodes(generationSettings); - DefaultBiomeFeatures.addDungeons(generationSettings); - DefaultBiomeFeatures.addMineables(generationSettings); - DefaultBiomeFeatures.addSprings(generationSettings); - DefaultBiomeFeatures.addFrozenTopLayer(generationSettings); + private static void addBasicFeatures(BiomeGenerationSettings.Builder generationSettings) { + BiomeDefaultFeatures.addDefaultCarversAndLakes(generationSettings); + BiomeDefaultFeatures.addDefaultCrystalFormations(generationSettings); + BiomeDefaultFeatures.addDefaultMonsterRoom(generationSettings); + BiomeDefaultFeatures.addDefaultUndergroundVariety(generationSettings); + BiomeDefaultFeatures.addDefaultSprings(generationSettings); + BiomeDefaultFeatures.addSurfaceFreezing(generationSettings); } - public static Biome.Builder biome(float temperature, float downfall) { - return (new Biome.Builder()).precipitation(true).temperature(temperature).downfall(downfall).setEnvironmentAttribute(EnvironmentAttributes.SKY_COLOR_VISUAL, OverworldBiomeCreator.getSkyColor(temperature)).effects((new BiomeEffects.Builder()).waterColor(4159204).build()); - } + public static Biome.BiomeBuilder biome(float temperature, float downfall) { + return (new Biome.BiomeBuilder()).hasPrecipitation(true).temperature(temperature).downfall(downfall).setAttribute(EnvironmentAttributes.SKY_COLOR, OverworldBiomes.calculateSkyColor(temperature)).specialEffects((new BiomeSpecialEffects.Builder()).waterColor(4159204).build()); + } } \ No newline at end of file diff --git a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeBiomeTagProvider.java b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeBiomeTagProvider.java index ddbb8ea6..dd3efe61 100644 --- a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeBiomeTagProvider.java +++ b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeBiomeTagProvider.java @@ -1,26 +1,26 @@ package fr.hugman.promenade.data.provider; -import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; -import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider; +import net.fabricmc.fabric.api.datagen.v1.FabricPackOutput; +import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagsProvider; import net.fabricmc.fabric.api.tag.convention.v2.ConventionalBiomeTags; -import net.minecraft.registry.RegistryKeys; -import net.minecraft.registry.RegistryWrapper; -import net.minecraft.registry.tag.BiomeTags; -import net.minecraft.world.biome.Biome; +import net.minecraft.core.HolderLookup; +import net.minecraft.core.registries.Registries; +import net.minecraft.tags.BiomeTags; +import net.minecraft.world.level.biome.Biome; import java.util.concurrent.CompletableFuture; import static fr.hugman.promenade.tag.PromenadeBiomeTags.*; import static fr.hugman.promenade.world.biome.PromenadeBiomes.*; -import static net.minecraft.world.biome.BiomeKeys.*; +import static net.minecraft.world.level.biome.Biomes.*; -public class PromenadeBiomeTagProvider extends FabricTagProvider { - public PromenadeBiomeTagProvider(FabricDataOutput output, CompletableFuture completableFuture) { - super(output, RegistryKeys.BIOME, completableFuture); +public class PromenadeBiomeTagProvider extends FabricTagsProvider { + public PromenadeBiomeTagProvider(FabricPackOutput output, CompletableFuture completableFuture) { + super(output, Registries.BIOME, completableFuture); } @Override - protected void configure(RegistryWrapper.WrapperLookup wrapperLookup) { + protected void addTags(HolderLookup.Provider wrapperLookup) { // Promenade builder(SAKURA_GROVES).add(BLUSH_SAKURA_GROVE, COTTON_SAKURA_GROVE); @@ -56,21 +56,21 @@ protected void configure(RegistryWrapper.WrapperLookup wrapperLookup) { builder(BiomeTags.IS_TAIGA).add(GLACARIAN_TAIGA); builder(BiomeTags.STRONGHOLD_BIASED_TO).addTag(SAKURA_GROVES).add(CARNELIAN_TREEWAY, GLACARIAN_TAIGA); - builder(BiomeTags.TRIAL_CHAMBERS_HAS_STRUCTURE).addTag(SAKURA_GROVES).add(CARNELIAN_TREEWAY, GLACARIAN_TAIGA); - builder(BiomeTags.BASTION_REMNANT_HAS_STRUCTURE).add(DARK_AMARANTH_FOREST); + builder(BiomeTags.HAS_TRIAL_CHAMBERS).addTag(SAKURA_GROVES).add(CARNELIAN_TREEWAY, GLACARIAN_TAIGA); + builder(BiomeTags.HAS_BASTION_REMNANT).add(DARK_AMARANTH_FOREST); builder(BiomeTags.SPAWNS_COLD_VARIANT_FROGS).add(GLACARIAN_TAIGA); builder(BiomeTags.SPAWNS_SNOW_FOXES).add(GLACARIAN_TAIGA); builder(BiomeTags.SPAWNS_WHITE_RABBITS).add(GLACARIAN_TAIGA); - // Conventional - builder(PRIMARY_WOOD_TYPE_SAKURA).addTag(SAKURA_GROVES); - builder(PRIMARY_WOOD_TYPE_PALM).addTag(HAS_PALMS); - builder(PRIMARY_WOOD_TYPE_MAPLE).add(CARNELIAN_TREEWAY); - builder(PRIMARY_WOOD_TYPE_DARK_AMARANTH).add(DARK_AMARANTH_FOREST); - builder(ConventionalBiomeTags.IS_CONIFEROUS_TREE).add(CARNELIAN_TREEWAY); - builder(ConventionalBiomeTags.IS_SNOWY).add(GLACARIAN_TAIGA); - builder(ConventionalBiomeTags.IS_ICY).add(GLACARIAN_TAIGA); - builder(ConventionalBiomeTags.IS_NETHER_FOREST).add(DARK_AMARANTH_FOREST); + // Conventional + builder(PRIMARY_WOOD_TYPE_SAKURA).addTag(SAKURA_GROVES); + builder(PRIMARY_WOOD_TYPE_PALM).addTag(HAS_PALMS); + builder(PRIMARY_WOOD_TYPE_MAPLE).add(CARNELIAN_TREEWAY); + builder(PRIMARY_WOOD_TYPE_DARK_AMARANTH).add(DARK_AMARANTH_FOREST); + builder(ConventionalBiomeTags.IS_CONIFEROUS_TREE).add(CARNELIAN_TREEWAY); + builder(ConventionalBiomeTags.IS_SNOWY).add(GLACARIAN_TAIGA); + builder(ConventionalBiomeTags.IS_ICY).add(GLACARIAN_TAIGA); + builder(ConventionalBiomeTags.IS_NETHER_FOREST).add(DARK_AMARANTH_FOREST); } } \ No newline at end of file diff --git a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeBlockLootTableProvider.java b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeBlockLootTableProvider.java index 5b99583f..b1ac3666 100644 --- a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeBlockLootTableProvider.java +++ b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeBlockLootTableProvider.java @@ -3,299 +3,295 @@ import fr.hugman.promenade.block.BerryBushBlock; import fr.hugman.promenade.block.PromenadeBlocks; import fr.hugman.promenade.item.PromenadeItems; -import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; -import net.fabricmc.fabric.api.datagen.v1.provider.FabricBlockLootTableProvider; -import net.minecraft.block.Block; -import net.minecraft.block.Blocks; -import net.minecraft.enchantment.Enchantment; -import net.minecraft.enchantment.Enchantments; -import net.minecraft.item.Item; -import net.minecraft.item.Items; -import net.minecraft.loot.LootPool; -import net.minecraft.loot.LootTable; -import net.minecraft.loot.condition.BlockStatePropertyLootCondition; -import net.minecraft.loot.condition.TableBonusLootCondition; -import net.minecraft.loot.entry.ItemEntry; -import net.minecraft.loot.function.ApplyBonusLootFunction; -import net.minecraft.loot.function.SetCountLootFunction; -import net.minecraft.loot.provider.number.UniformLootNumberProvider; -import net.minecraft.predicate.StatePredicate; -import net.minecraft.registry.RegistryKeys; -import net.minecraft.registry.RegistryWrapper; +import net.fabricmc.fabric.api.datagen.v1.FabricPackOutput; +import net.fabricmc.fabric.api.datagen.v1.provider.FabricBlockLootSubProvider; +import net.minecraft.advancements.criterion.StatePropertiesPredicate; +import net.minecraft.core.HolderLookup; +import net.minecraft.core.registries.Registries; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.Items; +import net.minecraft.world.item.enchantment.Enchantment; +import net.minecraft.world.item.enchantment.Enchantments; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.storage.loot.LootPool; +import net.minecraft.world.level.storage.loot.LootTable; +import net.minecraft.world.level.storage.loot.entries.LootItem; +import net.minecraft.world.level.storage.loot.functions.ApplyBonusCount; +import net.minecraft.world.level.storage.loot.functions.SetItemCountFunction; +import net.minecraft.world.level.storage.loot.predicates.BonusLevelTableCondition; +import net.minecraft.world.level.storage.loot.predicates.LootItemBlockStatePropertyCondition; +import net.minecraft.world.level.storage.loot.providers.number.UniformGenerator; import java.util.concurrent.CompletableFuture; import java.util.function.Function; -public class PromenadeBlockLootTableProvider extends FabricBlockLootTableProvider { +public class PromenadeBlockLootTableProvider extends FabricBlockLootSubProvider { private static final float[] JUNGLE_SAPLING_DROP_CHANCE = new float[]{0.025F, 0.027777778F, 0.03125F, 0.041666668F, 0.1F}; protected static final float[] SAPLING_DROP_CHANCE = new float[]{0.05F, 0.0625F, 0.083333336F, 0.1F}; private static final float[] LEAVES_STICK_DROP_CHANCE = new float[]{0.02F, 0.022222223F, 0.025F, 0.033333335F, 0.1F}; - public PromenadeBlockLootTableProvider(FabricDataOutput dataOutput, CompletableFuture registryLookup) { + public PromenadeBlockLootTableProvider(FabricPackOutput dataOutput, CompletableFuture registryLookup) { super(dataOutput, registryLookup); } @Override public void generate() { - final var enchantments = this.registries.getOrThrow(RegistryKeys.ENCHANTMENT); - - addDrop(PromenadeBlocks.ASPHALT); - addDrop(PromenadeBlocks.ASPHALT_SLAB, this::slabDrops); - addDrop(PromenadeBlocks.ASPHALT_STAIRS); - addDrop(PromenadeBlocks.ASPHALT_WALL); - addDrop(PromenadeBlocks.POLISHED_ASPHALT); - addDrop(PromenadeBlocks.POLISHED_ASPHALT_SLAB, this::slabDrops); - addDrop(PromenadeBlocks.POLISHED_ASPHALT_STAIRS); - - addDrop(PromenadeBlocks.BLUNITE); - addDrop(PromenadeBlocks.BLUNITE_SLAB, this::slabDrops); - addDrop(PromenadeBlocks.BLUNITE_STAIRS); - addDrop(PromenadeBlocks.BLUNITE_WALL); - addDrop(PromenadeBlocks.POLISHED_BLUNITE); - addDrop(PromenadeBlocks.POLISHED_BLUNITE_SLAB, this::slabDrops); - addDrop(PromenadeBlocks.POLISHED_BLUNITE_STAIRS); - - addDrop(PromenadeBlocks.OAK_LEAF_PILE, this::dropsWithSilkTouchOrShears); - addDrop(PromenadeBlocks.SPRUCE_LEAF_PILE, this::dropsWithSilkTouchOrShears); - addDrop(PromenadeBlocks.BIRCH_LEAF_PILE, this::dropsWithSilkTouchOrShears); - addDrop(PromenadeBlocks.JUNGLE_LEAF_PILE, this::dropsWithSilkTouchOrShears); - addDrop(PromenadeBlocks.ACACIA_LEAF_PILE, this::dropsWithSilkTouchOrShears); - addDrop(PromenadeBlocks.CHERRY_LEAF_PILE, this::dropsWithSilkTouchOrShears); - addDrop(PromenadeBlocks.DARK_OAK_LEAF_PILE, this::dropsWithSilkTouchOrShears); - addDrop(PromenadeBlocks.PALE_OAK_LEAF_PILE, this::dropsWithSilkTouchOrShears); - addDrop(PromenadeBlocks.MANGROVE_LEAF_PILE, this::dropsWithSilkTouchOrShears); - addDrop(PromenadeBlocks.AZALEA_LEAF_PILE, this::dropsWithSilkTouchOrShears); - addDrop(PromenadeBlocks.FLOWERING_AZALEA_LEAF_PILE, this::dropsWithSilkTouchOrShears); - - addDrop(PromenadeBlocks.DANDELION_PILE, flowerPile(Items.DANDELION)); - addDrop(PromenadeBlocks.POPPY_PILE, flowerPile(Items.POPPY)); - addDrop(PromenadeBlocks.BLUE_ORCHID_PILE, flowerPile(Items.BLUE_ORCHID)); - addDrop(PromenadeBlocks.ALLIUM_PILE, flowerPile(Items.ALLIUM)); - addDrop(PromenadeBlocks.AZURE_BLUET_PILE, flowerPile(Items.AZURE_BLUET)); - addDrop(PromenadeBlocks.RED_TULIP_PILE, flowerPile(Items.RED_TULIP)); - addDrop(PromenadeBlocks.ORANGE_TULIP_PILE, flowerPile(Items.ORANGE_TULIP)); - addDrop(PromenadeBlocks.WHITE_TULIP_PILE, flowerPile(Items.WHITE_TULIP)); - addDrop(PromenadeBlocks.PINK_TULIP_PILE, flowerPile(Items.PINK_TULIP)); - addDrop(PromenadeBlocks.OXEYE_DAISY_PILE, flowerPile(Items.OXEYE_DAISY)); - addDrop(PromenadeBlocks.CORNFLOWER_PILE, flowerPile(Items.CORNFLOWER)); - addDrop(PromenadeBlocks.LILY_OF_THE_VALLEY_PILE, flowerPile(Items.LILY_OF_THE_VALLEY)); - addDrop(PromenadeBlocks.WITHER_ROSE_PILE, flowerPile(Items.WITHER_ROSE)); - - addDrop(PromenadeBlocks.SNOWY_OAK_LEAVES, block -> this.snowyFruitLeavesDrop(block, Blocks.OAK_SAPLING, Items.APPLE, SAPLING_DROP_CHANCE)); - addDrop(PromenadeBlocks.SNOWY_SPRUCE_LEAVES, block -> this.snowyLeavesDrops(block, Blocks.SPRUCE_SAPLING, SAPLING_DROP_CHANCE)); - addDrop(PromenadeBlocks.SNOWY_BIRCH_LEAVES, block -> this.snowyLeavesDrops(block, Blocks.BIRCH_SAPLING, SAPLING_DROP_CHANCE)); - addDrop(PromenadeBlocks.SNOWY_JUNGLE_LEAVES, block -> this.snowyLeavesDrops(block, Blocks.JUNGLE_SAPLING, JUNGLE_SAPLING_DROP_CHANCE)); - addDrop(PromenadeBlocks.SNOWY_ACACIA_LEAVES, block -> this.snowyLeavesDrops(block, Blocks.ACACIA_SAPLING, SAPLING_DROP_CHANCE)); - addDrop(PromenadeBlocks.SNOWY_CHERRY_LEAVES, block -> this.snowyLeavesDrops(block, Blocks.CHERRY_SAPLING, SAPLING_DROP_CHANCE)); - addDrop(PromenadeBlocks.SNOWY_DARK_OAK_LEAVES, block -> this.snowyFruitLeavesDrop(block, Blocks.DARK_OAK_SAPLING, Items.APPLE, SAPLING_DROP_CHANCE)); - addDrop(PromenadeBlocks.SNOWY_PALE_OAK_LEAVES, block -> this.snowyLeavesDrops(block, Blocks.PALE_OAK_SAPLING, SAPLING_DROP_CHANCE)); - addDrop(PromenadeBlocks.SNOWY_MANGROVE_LEAVES, this::snowyMangroveLeavesDrops); - addDrop(PromenadeBlocks.SNOWY_AZALEA_LEAVES, block -> this.snowyLeavesDrops(block, Blocks.AZALEA, SAPLING_DROP_CHANCE)); - addDrop(PromenadeBlocks.SNOWY_FLOWERING_AZALEA_LEAVES, block -> this.snowyLeavesDrops(block, Blocks.FLOWERING_AZALEA, SAPLING_DROP_CHANCE)); - - addDrop(PromenadeBlocks.STRIPPED_SAKURA_LOG); - addDrop(PromenadeBlocks.SAKURA_LOG); - addDrop(PromenadeBlocks.STRIPPED_SAKURA_WOOD); - addDrop(PromenadeBlocks.SAKURA_WOOD); - addDrop(PromenadeBlocks.SAKURA_PLANKS); - addDrop(PromenadeBlocks.SAKURA_STAIRS); - addDrop(PromenadeBlocks.SAKURA_SLAB, this::slabDrops); - addDrop(PromenadeBlocks.SAKURA_FENCE); - addDrop(PromenadeBlocks.SAKURA_FENCE_GATE); - addDrop(PromenadeBlocks.SAKURA_DOOR, this::doorDrops); - addDrop(PromenadeBlocks.SAKURA_TRAPDOOR); - addDrop(PromenadeBlocks.SAKURA_BUTTON); - addDrop(PromenadeBlocks.SAKURA_PRESSURE_PLATE); - addDrop(PromenadeBlocks.SAKURA_SIGN); - addDrop(PromenadeBlocks.SAKURA_HANGING_SIGN); - addDrop(PromenadeBlocks.SAKURA_SHELF); - - addDrop(PromenadeBlocks.BLUSH_SAKURA_SAPLING); - addPottedPlantDrops(PromenadeBlocks.POTTED_BLUSH_SAKURA_SAPLING); - addDrop(PromenadeBlocks.BLUSH_SAKURA_BLOSSOMS, block -> this.leavesDrops(block, PromenadeBlocks.BLUSH_SAKURA_SAPLING, SAPLING_DROP_CHANCE)); - addDrop(PromenadeBlocks.SNOWY_BLUSH_SAKURA_BLOSSOMS, block -> this.snowyLeavesDrops(block, PromenadeBlocks.BLUSH_SAKURA_SAPLING, SAPLING_DROP_CHANCE)); - addDrop(PromenadeBlocks.BLUSH_SAKURA_BLOSSOM_PILE, this::dropsWithSilkTouchOrShears); - - addDrop(PromenadeBlocks.COTTON_SAKURA_SAPLING); - addPottedPlantDrops(PromenadeBlocks.POTTED_COTTON_SAKURA_SAPLING); - addDrop(PromenadeBlocks.COTTON_SAKURA_BLOSSOMS, block -> this.leavesDrops(block, PromenadeBlocks.COTTON_SAKURA_SAPLING, SAPLING_DROP_CHANCE)); - addDrop(PromenadeBlocks.SNOWY_COTTON_SAKURA_BLOSSOMS, block -> this.snowyLeavesDrops(block, PromenadeBlocks.COTTON_SAKURA_SAPLING, SAPLING_DROP_CHANCE)); - addDrop(PromenadeBlocks.COTTON_SAKURA_BLOSSOM_PILE, this::dropsWithSilkTouchOrShears); - - addDrop(PromenadeBlocks.STRIPPED_MAPLE_LOG); - addDrop(PromenadeBlocks.MAPLE_LOG); - addDrop(PromenadeBlocks.STRIPPED_MAPLE_WOOD); - addDrop(PromenadeBlocks.MAPLE_WOOD); - addDrop(PromenadeBlocks.MAPLE_PLANKS); - addDrop(PromenadeBlocks.MAPLE_STAIRS); - addDrop(PromenadeBlocks.MAPLE_SLAB, this::slabDrops); - addDrop(PromenadeBlocks.MAPLE_FENCE); - addDrop(PromenadeBlocks.MAPLE_FENCE_GATE); - addDrop(PromenadeBlocks.MAPLE_DOOR, this::doorDrops); - addDrop(PromenadeBlocks.MAPLE_TRAPDOOR); - addDrop(PromenadeBlocks.MAPLE_BUTTON); - addDrop(PromenadeBlocks.MAPLE_PRESSURE_PLATE); - addDrop(PromenadeBlocks.MAPLE_SIGN); - addDrop(PromenadeBlocks.MAPLE_HANGING_SIGN); - addDrop(PromenadeBlocks.MAPLE_SHELF); - - addDrop(PromenadeBlocks.SAP_MAPLE_SAPLING); - addPottedPlantDrops(PromenadeBlocks.POTTED_SAP_MAPLE_SAPLING); - addDrop(PromenadeBlocks.SAP_MAPLE_LEAVES, block -> this.leavesDrops(block, PromenadeBlocks.SAP_MAPLE_SAPLING, SAPLING_DROP_CHANCE)); - addDrop(PromenadeBlocks.SNOWY_SAP_MAPLE_LEAVES, block -> this.snowyLeavesDrops(block, PromenadeBlocks.SAP_MAPLE_SAPLING, SAPLING_DROP_CHANCE)); - addDrop(PromenadeBlocks.FALLEN_SAP_MAPLE_LEAVES, this::dropsWithSilkTouchOrShears); - addDrop(PromenadeBlocks.SAP_MAPLE_LEAF_PILE, this::dropsWithSilkTouchOrShears); - - addDrop(PromenadeBlocks.VERMILION_MAPLE_SAPLING); - addPottedPlantDrops(PromenadeBlocks.POTTED_VERMILION_MAPLE_SAPLING); - addDrop(PromenadeBlocks.VERMILION_MAPLE_LEAVES, block -> this.leavesDrops(block, PromenadeBlocks.VERMILION_MAPLE_SAPLING, SAPLING_DROP_CHANCE)); - addDrop(PromenadeBlocks.SNOWY_VERMILION_MAPLE_LEAVES, block -> this.snowyLeavesDrops(block, PromenadeBlocks.VERMILION_MAPLE_SAPLING, SAPLING_DROP_CHANCE)); - addDrop(PromenadeBlocks.FALLEN_VERMILION_MAPLE_LEAVES, this::dropsWithSilkTouchOrShears); - addDrop(PromenadeBlocks.VERMILION_MAPLE_LEAF_PILE, this::dropsWithSilkTouchOrShears); - - addDrop(PromenadeBlocks.FULVOUS_MAPLE_SAPLING); - addPottedPlantDrops(PromenadeBlocks.POTTED_FULVOUS_MAPLE_SAPLING); - addDrop(PromenadeBlocks.FULVOUS_MAPLE_LEAVES, block -> this.leavesDrops(block, PromenadeBlocks.FULVOUS_MAPLE_SAPLING, SAPLING_DROP_CHANCE)); - addDrop(PromenadeBlocks.SNOWY_FULVOUS_MAPLE_LEAVES, block -> this.snowyLeavesDrops(block, PromenadeBlocks.FULVOUS_MAPLE_SAPLING, SAPLING_DROP_CHANCE)); - addDrop(PromenadeBlocks.FALLEN_FULVOUS_MAPLE_LEAVES, this::dropsWithSilkTouchOrShears); - addDrop(PromenadeBlocks.FULVOUS_MAPLE_LEAF_PILE, this::dropsWithSilkTouchOrShears); - - addDrop(PromenadeBlocks.MIKADO_MAPLE_SAPLING); - addPottedPlantDrops(PromenadeBlocks.POTTED_MIKADO_MAPLE_SAPLING); - addDrop(PromenadeBlocks.MIKADO_MAPLE_LEAVES, block -> this.leavesDrops(block, PromenadeBlocks.MIKADO_MAPLE_SAPLING, SAPLING_DROP_CHANCE)); - addDrop(PromenadeBlocks.SNOWY_MIKADO_MAPLE_LEAVES, block -> this.snowyLeavesDrops(block, PromenadeBlocks.MIKADO_MAPLE_SAPLING, SAPLING_DROP_CHANCE)); - addDrop(PromenadeBlocks.FALLEN_MIKADO_MAPLE_LEAVES, this::dropsWithSilkTouchOrShears); - addDrop(PromenadeBlocks.MIKADO_MAPLE_LEAF_PILE, this::dropsWithSilkTouchOrShears); - - addDrop(PromenadeBlocks.STRIPPED_PALM_LOG); - addDrop(PromenadeBlocks.PALM_LOG); - addDrop(PromenadeBlocks.STRIPPED_PALM_WOOD); - addDrop(PromenadeBlocks.PALM_WOOD); - addDrop(PromenadeBlocks.PALM_PLANKS); - addDrop(PromenadeBlocks.PALM_STAIRS); - addDrop(PromenadeBlocks.PALM_SLAB, this::slabDrops); - addDrop(PromenadeBlocks.PALM_FENCE); - addDrop(PromenadeBlocks.PALM_FENCE_GATE); - addDrop(PromenadeBlocks.PALM_DOOR, this::doorDrops); - addDrop(PromenadeBlocks.PALM_TRAPDOOR); - addDrop(PromenadeBlocks.PALM_BUTTON); - addDrop(PromenadeBlocks.PALM_PRESSURE_PLATE); - addDrop(PromenadeBlocks.PALM_SIGN); - addDrop(PromenadeBlocks.PALM_HANGING_SIGN); - addDrop(PromenadeBlocks.PALM_SHELF); - - addDrop(PromenadeBlocks.PALM_SAPLING); - addPottedPlantDrops(PromenadeBlocks.POTTED_PALM_SAPLING); - addDrop(PromenadeBlocks.PALM_LEAVES, block -> this.leavesDrops(block, PromenadeBlocks.PALM_SAPLING, SAPLING_DROP_CHANCE)); - addDrop(PromenadeBlocks.SNOWY_PALM_LEAVES, block -> this.snowyLeavesDrops(block, PromenadeBlocks.PALM_SAPLING, SAPLING_DROP_CHANCE)); - addDrop(PromenadeBlocks.PALM_HANGING_LEAVES, this::dropsWithSilkTouchOrShears); - addDrop(PromenadeBlocks.PALM_LEAF_PILE, this::dropsWithSilkTouchOrShears); - - addDrop(PromenadeBlocks.DARK_AMARANTH_NYLIUM, block -> this.drops(block, Blocks.NETHERRACK)); - addDrop(PromenadeBlocks.DARK_AMARANTH_WART_BLOCK); - addDrop(PromenadeBlocks.DARK_AMARANTH_ROOTS); - addPottedPlantDrops(PromenadeBlocks.POTTED_DARK_AMARANTH_ROOTS); - - addDrop(PromenadeBlocks.STRIPPED_DARK_AMARANTH_STEM); - addDrop(PromenadeBlocks.DARK_AMARANTH_STEM); - addDrop(PromenadeBlocks.STRIPPED_DARK_AMARANTH_HYPHAE); - addDrop(PromenadeBlocks.DARK_AMARANTH_HYPHAE); - addDrop(PromenadeBlocks.DARK_AMARANTH_PLANKS); - addDrop(PromenadeBlocks.DARK_AMARANTH_STAIRS); - addDrop(PromenadeBlocks.DARK_AMARANTH_SLAB, this::slabDrops); - addDrop(PromenadeBlocks.DARK_AMARANTH_FENCE); - addDrop(PromenadeBlocks.DARK_AMARANTH_FENCE_GATE); - addDrop(PromenadeBlocks.DARK_AMARANTH_DOOR, this::doorDrops); - addDrop(PromenadeBlocks.DARK_AMARANTH_TRAPDOOR); - addDrop(PromenadeBlocks.DARK_AMARANTH_BUTTON); - addDrop(PromenadeBlocks.DARK_AMARANTH_PRESSURE_PLATE); - addDrop(PromenadeBlocks.DARK_AMARANTH_SIGN); - addDrop(PromenadeBlocks.DARK_AMARANTH_HANGING_SIGN); - addDrop(PromenadeBlocks.DARK_AMARANTH_SHELF); - - addDrop(PromenadeBlocks.DARK_AMARANTH_FUNGUS); - addPottedPlantDrops(PromenadeBlocks.POTTED_DARK_AMARANTH_FUNGUS); - - addDrop(PromenadeBlocks.SOUL_SHROOMLIGHT); - - addVinePlantDrop(PromenadeBlocks.COILED_VINES, PromenadeBlocks.COILED_VINES_PLANT); - - addDrop(PromenadeBlocks.MOAI); + final var enchantments = this.registries.lookupOrThrow(Registries.ENCHANTMENT); + + dropSelf(PromenadeBlocks.ASPHALT); + add(PromenadeBlocks.ASPHALT_SLAB, this::createSlabItemTable); + dropSelf(PromenadeBlocks.ASPHALT_STAIRS); + dropSelf(PromenadeBlocks.ASPHALT_WALL); + dropSelf(PromenadeBlocks.POLISHED_ASPHALT); + add(PromenadeBlocks.POLISHED_ASPHALT_SLAB, this::createSlabItemTable); + dropSelf(PromenadeBlocks.POLISHED_ASPHALT_STAIRS); + + dropSelf(PromenadeBlocks.BLUNITE); + add(PromenadeBlocks.BLUNITE_SLAB, this::createSlabItemTable); + dropSelf(PromenadeBlocks.BLUNITE_STAIRS); + dropSelf(PromenadeBlocks.BLUNITE_WALL); + dropSelf(PromenadeBlocks.POLISHED_BLUNITE); + add(PromenadeBlocks.POLISHED_BLUNITE_SLAB, this::createSlabItemTable); + dropSelf(PromenadeBlocks.POLISHED_BLUNITE_STAIRS); + + add(PromenadeBlocks.OAK_LEAF_PILE, this::createShearsOrSilkTouchOnlyDrop); + add(PromenadeBlocks.SPRUCE_LEAF_PILE, this::createShearsOrSilkTouchOnlyDrop); + add(PromenadeBlocks.BIRCH_LEAF_PILE, this::createShearsOrSilkTouchOnlyDrop); + add(PromenadeBlocks.JUNGLE_LEAF_PILE, this::createShearsOrSilkTouchOnlyDrop); + add(PromenadeBlocks.ACACIA_LEAF_PILE, this::createShearsOrSilkTouchOnlyDrop); + add(PromenadeBlocks.CHERRY_LEAF_PILE, this::createShearsOrSilkTouchOnlyDrop); + add(PromenadeBlocks.DARK_OAK_LEAF_PILE, this::createShearsOrSilkTouchOnlyDrop); + add(PromenadeBlocks.PALE_OAK_LEAF_PILE, this::createShearsOrSilkTouchOnlyDrop); + add(PromenadeBlocks.MANGROVE_LEAF_PILE, this::createShearsOrSilkTouchOnlyDrop); + add(PromenadeBlocks.AZALEA_LEAF_PILE, this::createShearsOrSilkTouchOnlyDrop); + add(PromenadeBlocks.FLOWERING_AZALEA_LEAF_PILE, this::createShearsOrSilkTouchOnlyDrop); + + add(PromenadeBlocks.DANDELION_PILE, flowerPile(Items.DANDELION)); + add(PromenadeBlocks.POPPY_PILE, flowerPile(Items.POPPY)); + add(PromenadeBlocks.BLUE_ORCHID_PILE, flowerPile(Items.BLUE_ORCHID)); + add(PromenadeBlocks.ALLIUM_PILE, flowerPile(Items.ALLIUM)); + add(PromenadeBlocks.AZURE_BLUET_PILE, flowerPile(Items.AZURE_BLUET)); + add(PromenadeBlocks.RED_TULIP_PILE, flowerPile(Items.RED_TULIP)); + add(PromenadeBlocks.ORANGE_TULIP_PILE, flowerPile(Items.ORANGE_TULIP)); + add(PromenadeBlocks.WHITE_TULIP_PILE, flowerPile(Items.WHITE_TULIP)); + add(PromenadeBlocks.PINK_TULIP_PILE, flowerPile(Items.PINK_TULIP)); + add(PromenadeBlocks.OXEYE_DAISY_PILE, flowerPile(Items.OXEYE_DAISY)); + add(PromenadeBlocks.CORNFLOWER_PILE, flowerPile(Items.CORNFLOWER)); + add(PromenadeBlocks.LILY_OF_THE_VALLEY_PILE, flowerPile(Items.LILY_OF_THE_VALLEY)); + add(PromenadeBlocks.WITHER_ROSE_PILE, flowerPile(Items.WITHER_ROSE)); + + add(PromenadeBlocks.SNOWY_OAK_LEAVES, block -> this.snowyFruitLeavesDrop(block, Blocks.OAK_SAPLING, Items.APPLE, SAPLING_DROP_CHANCE)); + add(PromenadeBlocks.SNOWY_SPRUCE_LEAVES, block -> this.snowyLeavesDrops(block, Blocks.SPRUCE_SAPLING, SAPLING_DROP_CHANCE)); + add(PromenadeBlocks.SNOWY_BIRCH_LEAVES, block -> this.snowyLeavesDrops(block, Blocks.BIRCH_SAPLING, SAPLING_DROP_CHANCE)); + add(PromenadeBlocks.SNOWY_JUNGLE_LEAVES, block -> this.snowyLeavesDrops(block, Blocks.JUNGLE_SAPLING, JUNGLE_SAPLING_DROP_CHANCE)); + add(PromenadeBlocks.SNOWY_ACACIA_LEAVES, block -> this.snowyLeavesDrops(block, Blocks.ACACIA_SAPLING, SAPLING_DROP_CHANCE)); + add(PromenadeBlocks.SNOWY_CHERRY_LEAVES, block -> this.snowyLeavesDrops(block, Blocks.CHERRY_SAPLING, SAPLING_DROP_CHANCE)); + add(PromenadeBlocks.SNOWY_DARK_OAK_LEAVES, block -> this.snowyFruitLeavesDrop(block, Blocks.DARK_OAK_SAPLING, Items.APPLE, SAPLING_DROP_CHANCE)); + add(PromenadeBlocks.SNOWY_PALE_OAK_LEAVES, block -> this.snowyLeavesDrops(block, Blocks.PALE_OAK_SAPLING, SAPLING_DROP_CHANCE)); + add(PromenadeBlocks.SNOWY_MANGROVE_LEAVES, this::snowyMangroveLeavesDrops); + add(PromenadeBlocks.SNOWY_AZALEA_LEAVES, block -> this.snowyLeavesDrops(block, Blocks.AZALEA, SAPLING_DROP_CHANCE)); + add(PromenadeBlocks.SNOWY_FLOWERING_AZALEA_LEAVES, block -> this.snowyLeavesDrops(block, Blocks.FLOWERING_AZALEA, SAPLING_DROP_CHANCE)); + + dropSelf(PromenadeBlocks.STRIPPED_SAKURA_LOG); + dropSelf(PromenadeBlocks.SAKURA_LOG); + dropSelf(PromenadeBlocks.STRIPPED_SAKURA_WOOD); + dropSelf(PromenadeBlocks.SAKURA_WOOD); + dropSelf(PromenadeBlocks.SAKURA_PLANKS); + dropSelf(PromenadeBlocks.SAKURA_STAIRS); + add(PromenadeBlocks.SAKURA_SLAB, this::createSlabItemTable); + dropSelf(PromenadeBlocks.SAKURA_FENCE); + dropSelf(PromenadeBlocks.SAKURA_FENCE_GATE); + add(PromenadeBlocks.SAKURA_DOOR, this::createDoorTable); + dropSelf(PromenadeBlocks.SAKURA_TRAPDOOR); + dropSelf(PromenadeBlocks.SAKURA_BUTTON); + dropSelf(PromenadeBlocks.SAKURA_PRESSURE_PLATE); + dropSelf(PromenadeBlocks.SAKURA_SIGN); + dropSelf(PromenadeBlocks.SAKURA_HANGING_SIGN); + dropSelf(PromenadeBlocks.SAKURA_SHELF); + + dropSelf(PromenadeBlocks.BLUSH_SAKURA_SAPLING); + dropPottedContents(PromenadeBlocks.POTTED_BLUSH_SAKURA_SAPLING); + add(PromenadeBlocks.BLUSH_SAKURA_BLOSSOMS, block -> this.createLeavesDrops(block, PromenadeBlocks.BLUSH_SAKURA_SAPLING, SAPLING_DROP_CHANCE)); + add(PromenadeBlocks.SNOWY_BLUSH_SAKURA_BLOSSOMS, block -> this.snowyLeavesDrops(block, PromenadeBlocks.BLUSH_SAKURA_SAPLING, SAPLING_DROP_CHANCE)); + add(PromenadeBlocks.BLUSH_SAKURA_BLOSSOM_PILE, this::createShearsOrSilkTouchOnlyDrop); + + dropSelf(PromenadeBlocks.COTTON_SAKURA_SAPLING); + dropPottedContents(PromenadeBlocks.POTTED_COTTON_SAKURA_SAPLING); + add(PromenadeBlocks.COTTON_SAKURA_BLOSSOMS, block -> this.createLeavesDrops(block, PromenadeBlocks.COTTON_SAKURA_SAPLING, SAPLING_DROP_CHANCE)); + add(PromenadeBlocks.SNOWY_COTTON_SAKURA_BLOSSOMS, block -> this.snowyLeavesDrops(block, PromenadeBlocks.COTTON_SAKURA_SAPLING, SAPLING_DROP_CHANCE)); + add(PromenadeBlocks.COTTON_SAKURA_BLOSSOM_PILE, this::createShearsOrSilkTouchOnlyDrop); + + dropSelf(PromenadeBlocks.STRIPPED_MAPLE_LOG); + dropSelf(PromenadeBlocks.MAPLE_LOG); + dropSelf(PromenadeBlocks.STRIPPED_MAPLE_WOOD); + dropSelf(PromenadeBlocks.MAPLE_WOOD); + dropSelf(PromenadeBlocks.MAPLE_PLANKS); + dropSelf(PromenadeBlocks.MAPLE_STAIRS); + add(PromenadeBlocks.MAPLE_SLAB, this::createSlabItemTable); + dropSelf(PromenadeBlocks.MAPLE_FENCE); + dropSelf(PromenadeBlocks.MAPLE_FENCE_GATE); + add(PromenadeBlocks.MAPLE_DOOR, this::createDoorTable); + dropSelf(PromenadeBlocks.MAPLE_TRAPDOOR); + dropSelf(PromenadeBlocks.MAPLE_BUTTON); + dropSelf(PromenadeBlocks.MAPLE_PRESSURE_PLATE); + dropSelf(PromenadeBlocks.MAPLE_SIGN); + dropSelf(PromenadeBlocks.MAPLE_HANGING_SIGN); + dropSelf(PromenadeBlocks.MAPLE_SHELF); + + dropSelf(PromenadeBlocks.SAP_MAPLE_SAPLING); + dropPottedContents(PromenadeBlocks.POTTED_SAP_MAPLE_SAPLING); + add(PromenadeBlocks.SAP_MAPLE_LEAVES, block -> this.createLeavesDrops(block, PromenadeBlocks.SAP_MAPLE_SAPLING, SAPLING_DROP_CHANCE)); + add(PromenadeBlocks.SNOWY_SAP_MAPLE_LEAVES, block -> this.snowyLeavesDrops(block, PromenadeBlocks.SAP_MAPLE_SAPLING, SAPLING_DROP_CHANCE)); + add(PromenadeBlocks.FALLEN_SAP_MAPLE_LEAVES, this::createShearsOrSilkTouchOnlyDrop); + add(PromenadeBlocks.SAP_MAPLE_LEAF_PILE, this::createShearsOrSilkTouchOnlyDrop); + + dropSelf(PromenadeBlocks.VERMILION_MAPLE_SAPLING); + dropPottedContents(PromenadeBlocks.POTTED_VERMILION_MAPLE_SAPLING); + add(PromenadeBlocks.VERMILION_MAPLE_LEAVES, block -> this.createLeavesDrops(block, PromenadeBlocks.VERMILION_MAPLE_SAPLING, SAPLING_DROP_CHANCE)); + add(PromenadeBlocks.SNOWY_VERMILION_MAPLE_LEAVES, block -> this.snowyLeavesDrops(block, PromenadeBlocks.VERMILION_MAPLE_SAPLING, SAPLING_DROP_CHANCE)); + add(PromenadeBlocks.FALLEN_VERMILION_MAPLE_LEAVES, this::createShearsOrSilkTouchOnlyDrop); + add(PromenadeBlocks.VERMILION_MAPLE_LEAF_PILE, this::createShearsOrSilkTouchOnlyDrop); + + dropSelf(PromenadeBlocks.FULVOUS_MAPLE_SAPLING); + dropPottedContents(PromenadeBlocks.POTTED_FULVOUS_MAPLE_SAPLING); + add(PromenadeBlocks.FULVOUS_MAPLE_LEAVES, block -> this.createLeavesDrops(block, PromenadeBlocks.FULVOUS_MAPLE_SAPLING, SAPLING_DROP_CHANCE)); + add(PromenadeBlocks.SNOWY_FULVOUS_MAPLE_LEAVES, block -> this.snowyLeavesDrops(block, PromenadeBlocks.FULVOUS_MAPLE_SAPLING, SAPLING_DROP_CHANCE)); + add(PromenadeBlocks.FALLEN_FULVOUS_MAPLE_LEAVES, this::createShearsOrSilkTouchOnlyDrop); + add(PromenadeBlocks.FULVOUS_MAPLE_LEAF_PILE, this::createShearsOrSilkTouchOnlyDrop); + + dropSelf(PromenadeBlocks.MIKADO_MAPLE_SAPLING); + dropPottedContents(PromenadeBlocks.POTTED_MIKADO_MAPLE_SAPLING); + add(PromenadeBlocks.MIKADO_MAPLE_LEAVES, block -> this.createLeavesDrops(block, PromenadeBlocks.MIKADO_MAPLE_SAPLING, SAPLING_DROP_CHANCE)); + add(PromenadeBlocks.SNOWY_MIKADO_MAPLE_LEAVES, block -> this.snowyLeavesDrops(block, PromenadeBlocks.MIKADO_MAPLE_SAPLING, SAPLING_DROP_CHANCE)); + add(PromenadeBlocks.FALLEN_MIKADO_MAPLE_LEAVES, this::createShearsOrSilkTouchOnlyDrop); + add(PromenadeBlocks.MIKADO_MAPLE_LEAF_PILE, this::createShearsOrSilkTouchOnlyDrop); + + dropSelf(PromenadeBlocks.STRIPPED_PALM_LOG); + dropSelf(PromenadeBlocks.PALM_LOG); + dropSelf(PromenadeBlocks.STRIPPED_PALM_WOOD); + dropSelf(PromenadeBlocks.PALM_WOOD); + dropSelf(PromenadeBlocks.PALM_PLANKS); + dropSelf(PromenadeBlocks.PALM_STAIRS); + add(PromenadeBlocks.PALM_SLAB, this::createSlabItemTable); + dropSelf(PromenadeBlocks.PALM_FENCE); + dropSelf(PromenadeBlocks.PALM_FENCE_GATE); + add(PromenadeBlocks.PALM_DOOR, this::createDoorTable); + dropSelf(PromenadeBlocks.PALM_TRAPDOOR); + dropSelf(PromenadeBlocks.PALM_BUTTON); + dropSelf(PromenadeBlocks.PALM_PRESSURE_PLATE); + dropSelf(PromenadeBlocks.PALM_SIGN); + dropSelf(PromenadeBlocks.PALM_HANGING_SIGN); + dropSelf(PromenadeBlocks.PALM_SHELF); + + dropSelf(PromenadeBlocks.PALM_SAPLING); + dropPottedContents(PromenadeBlocks.POTTED_PALM_SAPLING); + add(PromenadeBlocks.PALM_LEAVES, block -> this.createLeavesDrops(block, PromenadeBlocks.PALM_SAPLING, SAPLING_DROP_CHANCE)); + add(PromenadeBlocks.SNOWY_PALM_LEAVES, block -> this.snowyLeavesDrops(block, PromenadeBlocks.PALM_SAPLING, SAPLING_DROP_CHANCE)); + add(PromenadeBlocks.PALM_HANGING_LEAVES, this::createShearsOrSilkTouchOnlyDrop); + add(PromenadeBlocks.PALM_LEAF_PILE, this::createShearsOrSilkTouchOnlyDrop); + + add(PromenadeBlocks.DARK_AMARANTH_NYLIUM, block -> this.createSingleItemTableWithSilkTouch(block, Blocks.NETHERRACK)); + dropSelf(PromenadeBlocks.DARK_AMARANTH_WART_BLOCK); + dropSelf(PromenadeBlocks.DARK_AMARANTH_ROOTS); + dropPottedContents(PromenadeBlocks.POTTED_DARK_AMARANTH_ROOTS); + + dropSelf(PromenadeBlocks.STRIPPED_DARK_AMARANTH_STEM); + dropSelf(PromenadeBlocks.DARK_AMARANTH_STEM); + dropSelf(PromenadeBlocks.STRIPPED_DARK_AMARANTH_HYPHAE); + dropSelf(PromenadeBlocks.DARK_AMARANTH_HYPHAE); + dropSelf(PromenadeBlocks.DARK_AMARANTH_PLANKS); + dropSelf(PromenadeBlocks.DARK_AMARANTH_STAIRS); + add(PromenadeBlocks.DARK_AMARANTH_SLAB, this::createSlabItemTable); + dropSelf(PromenadeBlocks.DARK_AMARANTH_FENCE); + dropSelf(PromenadeBlocks.DARK_AMARANTH_FENCE_GATE); + add(PromenadeBlocks.DARK_AMARANTH_DOOR, this::createDoorTable); + dropSelf(PromenadeBlocks.DARK_AMARANTH_TRAPDOOR); + dropSelf(PromenadeBlocks.DARK_AMARANTH_BUTTON); + dropSelf(PromenadeBlocks.DARK_AMARANTH_PRESSURE_PLATE); + dropSelf(PromenadeBlocks.DARK_AMARANTH_SIGN); + dropSelf(PromenadeBlocks.DARK_AMARANTH_HANGING_SIGN); + dropSelf(PromenadeBlocks.DARK_AMARANTH_SHELF); + + dropSelf(PromenadeBlocks.DARK_AMARANTH_FUNGUS); + dropPottedContents(PromenadeBlocks.POTTED_DARK_AMARANTH_FUNGUS); + + dropSelf(PromenadeBlocks.SOUL_SHROOMLIGHT); + + addNetherVinesDropTable(PromenadeBlocks.COILED_VINES, PromenadeBlocks.COILED_VINES_PLANT); + + dropSelf(PromenadeBlocks.MOAI); //TODO: generify this fat block of code - this.addDrop( + this.add( PromenadeBlocks.BLUEBERRY_BUSH, block -> this.applyExplosionDecay( block, - LootTable.builder() - .pool( - LootPool.builder() - .conditionally( - BlockStatePropertyLootCondition.builder(PromenadeBlocks.BLUEBERRY_BUSH).properties(StatePredicate.Builder.create().exactMatch(BerryBushBlock.AGE, 3)) - ) - .with(ItemEntry.builder(PromenadeItems.BLUEBERRIES)) - .apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(2.0F, 3.0F))) - .apply(ApplyBonusLootFunction.uniformBonusCount(enchantments.getOrThrow(Enchantments.FORTUNE))) + LootTable.lootTable() + .withPool( + LootPool.lootPool() + .when(LootItemBlockStatePropertyCondition.hasBlockStateProperties(PromenadeBlocks.BLUEBERRY_BUSH) + .setProperties(StatePropertiesPredicate.Builder.properties().hasProperty(BerryBushBlock.AGE, 3))) + .add(LootItem.lootTableItem(PromenadeItems.BLUEBERRIES)) + .apply(SetItemCountFunction.setCount(UniformGenerator.between(2.0F, 3.0F))) + .apply(ApplyBonusCount.addUniformBonusCount(enchantments.getOrThrow(Enchantments.FORTUNE))) ) - .pool( - LootPool.builder() - .conditionally( - BlockStatePropertyLootCondition.builder(PromenadeBlocks.BLUEBERRY_BUSH).properties(StatePredicate.Builder.create().exactMatch(BerryBushBlock.AGE, 2)) - ) - .with(ItemEntry.builder(PromenadeItems.BLUEBERRIES)) - .apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(1.0F, 2.0F))) - .apply(ApplyBonusLootFunction.uniformBonusCount(enchantments.getOrThrow(Enchantments.FORTUNE))) + .withPool( + LootPool.lootPool() + .when(LootItemBlockStatePropertyCondition.hasBlockStateProperties(PromenadeBlocks.BLUEBERRY_BUSH) + .setProperties(StatePropertiesPredicate.Builder.properties().hasProperty(BerryBushBlock.AGE, 2))) + .add(LootItem.lootTableItem(PromenadeItems.BLUEBERRIES)) + .apply(SetItemCountFunction.setCount(UniformGenerator.between(1.0F, 2.0F))) + .apply(ApplyBonusCount.addUniformBonusCount(enchantments.getOrThrow(Enchantments.FORTUNE))) ) ) ); - - this.lootTables.forEach((id, lootTable) -> lootTable.randomSequenceId(id.getValue())); } public LootTable.Builder snowyLeavesDrops(Block leaves, Block sapling, float... saplingChance) { - return this.leavesDrops(leaves, sapling, saplingChance) - .pool( - LootPool.builder() - .conditionally(this.createWithoutShearsOrSilkTouchCondition()) - .with( - this.addSurvivesExplosionCondition(leaves, - ItemEntry.builder(Items.SNOWBALL) - .apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(2.0F, 4.0F))) + return this.createLeavesDrops(leaves, sapling, saplingChance) + .withPool( + LootPool.lootPool() + .when(this.doesNotHaveShearsOrSilkTouch()) + .add( + this.applyExplosionCondition(leaves, + LootItem.lootTableItem(Items.SNOWBALL) + .apply(SetItemCountFunction.setCount(UniformGenerator.between(2.0F, 4.0F))) ) )); } public LootTable.Builder snowyMangroveLeavesDrops(Block leaves) { - return this.mangroveLeavesDrops(leaves) - .pool( - LootPool.builder() - .conditionally(this.createWithoutShearsOrSilkTouchCondition()) - .with( - this.addSurvivesExplosionCondition(leaves, - ItemEntry.builder(Items.SNOWBALL).apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(2.0F, 4.0F))) + return this.createMangroveLeavesDrops(leaves) + .withPool( + LootPool.lootPool() + .when(this.doesNotHaveShearsOrSilkTouch()) + .add( + this.applyExplosionCondition(leaves, + LootItem.lootTableItem(Items.SNOWBALL).apply(SetItemCountFunction.setCount(UniformGenerator.between(2.0F, 4.0F))) ) )); } public LootTable.Builder fruitLeavesDrops(Block leaves, Block sapling, Item fruit, float... saplingChance) { - RegistryWrapper.Impl impl = this.registries.getOrThrow(RegistryKeys.ENCHANTMENT); - return this.leavesDrops(leaves, sapling, saplingChance) - .pool(LootPool.builder() - .conditionally(this.createWithoutSilkTouchCondition()) - .with( - this.addSurvivesExplosionCondition(leaves, ItemEntry.builder(fruit)) - .conditionally(TableBonusLootCondition.builder(impl.getOrThrow(Enchantments.FORTUNE), 0.005F, 0.0055555557F, 0.00625F, 0.008333334F, 0.025F)) + HolderLookup.RegistryLookup impl = this.registries.lookupOrThrow(Registries.ENCHANTMENT); + return this.createLeavesDrops(leaves, sapling, saplingChance) + .withPool(LootPool.lootPool() + .when(this.doesNotHaveSilkTouch()) + .add( + this.applyExplosionCondition(leaves, LootItem.lootTableItem(fruit)) + .when(BonusLevelTableCondition.bonusLevelFlatChance(impl.getOrThrow(Enchantments.FORTUNE), 0.005F, 0.0055555557F, 0.00625F, 0.008333334F, 0.025F)) ) ); } public LootTable.Builder snowyFruitLeavesDrop(Block leaves, Block sapling, Item fruit, float... saplingChance) { return this.fruitLeavesDrops(leaves, sapling, fruit, saplingChance) - .pool(LootPool.builder() - .conditionally(this.createWithoutShearsOrSilkTouchCondition()) - .with( - this.addSurvivesExplosionCondition(leaves, - ItemEntry.builder(Items.SNOWBALL).apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(2.0F, 4.0F))) + .withPool(LootPool.lootPool() + .when(this.doesNotHaveShearsOrSilkTouch()) + .add( + this.applyExplosionCondition(leaves, + LootItem.lootTableItem(Items.SNOWBALL).apply(SetItemCountFunction.setCount(UniformGenerator.between(2.0F, 4.0F))) ) ) ); @@ -306,9 +302,9 @@ public Function flowerPile(Item flower) { } public LootTable.Builder flowerPile(Block pile, Item flower) { - return this.dropsWithSilkTouchOrShears( + return this.createSilkTouchOrShearsDispatchTable( pile, - this.applyExplosionDecay(pile, ItemEntry.builder(flower).apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(2.0F, 3.0F)))) + this.applyExplosionDecay(pile, LootItem.lootTableItem(flower).apply(SetItemCountFunction.setCount(UniformGenerator.between(2.0F, 3.0F)))) ); } } \ No newline at end of file diff --git a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeBlockTagProvider.java b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeBlockTagProvider.java index 50fcceb9..f1bf3e6d 100644 --- a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeBlockTagProvider.java +++ b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeBlockTagProvider.java @@ -1,26 +1,24 @@ package fr.hugman.promenade.data.provider; -import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; -import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider; +import net.fabricmc.fabric.api.datagen.v1.FabricPackOutput; +import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagsProvider; import net.fabricmc.fabric.api.tag.convention.v2.ConventionalBlockTags; -import net.fabricmc.fabric.api.tag.convention.v2.ConventionalItemTags; -import net.minecraft.block.Blocks; -import net.minecraft.registry.RegistryWrapper; -import net.minecraft.registry.tag.BlockTags; +import net.minecraft.core.HolderLookup; +import net.minecraft.tags.BlockTags; +import net.minecraft.world.level.block.Blocks; import java.util.concurrent.CompletableFuture; import static fr.hugman.promenade.block.PromenadeBlocks.*; -import static fr.hugman.promenade.item.PromenadeItems.MAPLE_SYRUP_BOTTLE; import static fr.hugman.promenade.tag.PromenadeBlockTags.*; -public class PromenadeBlockTagProvider extends FabricTagProvider.BlockTagProvider { - public PromenadeBlockTagProvider(FabricDataOutput output, CompletableFuture registriesFuture) { +public class PromenadeBlockTagProvider extends FabricTagsProvider.BlockTagsProvider { + public PromenadeBlockTagProvider(FabricPackOutput output, CompletableFuture registriesFuture) { super(output, registriesFuture); } @Override - protected void configure(RegistryWrapper.WrapperLookup wrapperLookup) { + protected void addTags(HolderLookup.Provider wrapperLookup) { // Promenade valueLookupBuilder(SAKURA_LOGS).add(SAKURA_LOG, STRIPPED_SAKURA_LOG, SAKURA_WOOD, STRIPPED_SAKURA_WOOD); valueLookupBuilder(MAPLE_LOGS).add(MAPLE_LOG, STRIPPED_MAPLE_LOG, MAPLE_WOOD, STRIPPED_MAPLE_WOOD); @@ -161,7 +159,9 @@ protected void configure(RegistryWrapper.WrapperLookup wrapperLookup) { .addTag(FLOWER_PILES) .add(DARK_AMARANTH_ROOTS); valueLookupBuilder(BlockTags.BEE_GROWABLES).add(BLUEBERRY_BUSH); - valueLookupBuilder(BlockTags.MUSHROOM_GROW_BLOCK).add(DARK_AMARANTH_NYLIUM); + valueLookupBuilder(BlockTags.OVERRIDES_MUSHROOM_LIGHT_REQUIREMENT).add(DARK_AMARANTH_NYLIUM); + valueLookupBuilder(BlockTags.HUGE_BROWN_MUSHROOM_CAN_PLACE_ON).add(DARK_AMARANTH_NYLIUM); + valueLookupBuilder(BlockTags.HUGE_RED_MUSHROOM_CAN_PLACE_ON).add(DARK_AMARANTH_NYLIUM); valueLookupBuilder(BlockTags.NYLIUM).add(DARK_AMARANTH_NYLIUM); valueLookupBuilder(BlockTags.WART_BLOCKS).add(DARK_AMARANTH_WART_BLOCK); @@ -180,7 +180,7 @@ protected void configure(RegistryWrapper.WrapperLookup wrapperLookup) { .addTag(LEAF_PILES) .addTag(FLOWER_PILES) .add(DARK_AMARANTH_ROOTS, COILED_VINES, COILED_VINES_PLANT); - valueLookupBuilder(BlockTags.PICKAXE_MINEABLE).add( + valueLookupBuilder(BlockTags.MINEABLE_WITH_PICKAXE).add( BLUNITE, BLUNITE_STAIRS, BLUNITE_SLAB, @@ -196,8 +196,8 @@ protected void configure(RegistryWrapper.WrapperLookup wrapperLookup) { MOAI, DARK_AMARANTH_NYLIUM ); - valueLookupBuilder(BlockTags.AXE_MINEABLE).add(DARK_AMARANTH_FUNGUS, COILED_VINES, COILED_VINES_PLANT); - valueLookupBuilder(BlockTags.HOE_MINEABLE) + valueLookupBuilder(BlockTags.MINEABLE_WITH_AXE).add(DARK_AMARANTH_FUNGUS, COILED_VINES, COILED_VINES_PLANT); + valueLookupBuilder(BlockTags.MINEABLE_WITH_HOE) .add( VERMILION_MAPLE_LEAVES, FULVOUS_MAPLE_LEAVES, @@ -222,8 +222,8 @@ protected void configure(RegistryWrapper.WrapperLookup wrapperLookup) { valueLookupBuilder(ConventionalBlockTags.STRIPPED_LOGS).add(STRIPPED_SAKURA_LOG, STRIPPED_MAPLE_LOG, STRIPPED_PALM_LOG, STRIPPED_DARK_AMARANTH_STEM); valueLookupBuilder(ConventionalBlockTags.STRIPPED_WOODS).add(STRIPPED_SAKURA_WOOD, STRIPPED_MAPLE_WOOD, STRIPPED_PALM_WOOD, STRIPPED_DARK_AMARANTH_HYPHAE); - valueLookupBuilder(IGNEOUS_ROCKS) - .add(Blocks.ANDESITE, Blocks.DIORITE, Blocks.GRANITE, Blocks.TUFF, BLUNITE); + valueLookupBuilder(IGNEOUS_ROCKS) + .add(Blocks.ANDESITE, Blocks.DIORITE, Blocks.GRANITE, Blocks.TUFF, BLUNITE); } } \ No newline at end of file diff --git a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeCapybaraVariantProvider.java b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeCapybaraVariantProvider.java index 73e9cedb..df30ae3b 100644 --- a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeCapybaraVariantProvider.java +++ b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeCapybaraVariantProvider.java @@ -4,25 +4,25 @@ import fr.hugman.promenade.entity.variant.CapybaraVariant; import fr.hugman.promenade.entity.variant.CapybaraVariants; import fr.hugman.promenade.registry.PromenadeRegistryKeys; -import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; +import net.fabricmc.fabric.api.datagen.v1.FabricPackOutput; import net.fabricmc.fabric.api.datagen.v1.provider.FabricDynamicRegistryProvider; -import net.minecraft.entity.spawn.SpawnConditionSelectors; -import net.minecraft.registry.Registerable; -import net.minecraft.registry.RegistryKey; -import net.minecraft.registry.RegistryWrapper; -import net.minecraft.util.AssetInfo.TextureAssetInfo; +import net.minecraft.core.ClientAsset.ResourceTexture; +import net.minecraft.core.HolderLookup; +import net.minecraft.data.worldgen.BootstrapContext; +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.entity.variant.SpawnPrioritySelectors; import java.util.concurrent.CompletableFuture; //TODO: a generic class for other devs public class PromenadeCapybaraVariantProvider extends FabricDynamicRegistryProvider { - public PromenadeCapybaraVariantProvider(FabricDataOutput output, CompletableFuture registriesFuture) { + public PromenadeCapybaraVariantProvider(FabricPackOutput output, CompletableFuture registriesFuture) { super(output, registriesFuture); } @Override - protected void configure(RegistryWrapper.WrapperLookup registries, Entries entries) { - entries.addAll(registries.getOrThrow(PromenadeRegistryKeys.CAPYBARA_VARIANT)); + protected void configure(HolderLookup.Provider registries, Entries entries) { + entries.addAll(registries.lookupOrThrow(PromenadeRegistryKeys.CAPYBARA_VARIANT)); } @Override @@ -30,21 +30,28 @@ public String getName() { return "Capybara Variants"; } - public static void register(Registerable registerable) { - of(registerable, CapybaraVariants.BROWN, SpawnConditionSelectors.createFallback(0)); + public static void register(BootstrapContext registerable) { + of(registerable, CapybaraVariants.BROWN, SpawnPrioritySelectors.fallback(0)); of(registerable, CapybaraVariants.ALBINO, 1 / 50f); } - private static void of(Registerable registry, RegistryKey key, float rarity) { - of(registry, key, SpawnConditionSelectors.createSingle(new ChanceSpawnCondition(rarity), 0)); + private static void of(BootstrapContext registry, ResourceKey key, float rarity) { + of(registry, key, SpawnPrioritySelectors.single(new ChanceSpawnCondition(rarity), 0)); } - private static void of(Registerable registry, RegistryKey key, SpawnConditionSelectors spawnConditions) { - var baseId = key.getValue().withPrefixedPath("entity/capybara/"); + private static void of(BootstrapContext registry, ResourceKey key, SpawnPrioritySelectors spawnConditions) { + var baseId = key.identifier().withPrefix("entity/capybara/"); registry.register(key, new CapybaraVariant( - new TextureAssetInfo(baseId.withSuffixedPath("/small_eyes")), - new TextureAssetInfo(baseId.withSuffixedPath("/large_eyes")), - new TextureAssetInfo(baseId.withSuffixedPath("/closed_eyes")), + new CapybaraVariant.AssetInfo( + new ResourceTexture(baseId.withSuffix("/normal")), + new ResourceTexture(baseId.withSuffix("/surprised")), + new ResourceTexture(baseId.withSuffix("/sleeping")) + ), + new CapybaraVariant.AssetInfo( + new ResourceTexture(baseId.withSuffix("/normal_baby")), + new ResourceTexture(baseId.withSuffix("/normal_baby")), + new ResourceTexture(baseId.withSuffix("/sleeping_baby")) + ), spawnConditions )); } diff --git a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeChestLootTableProvider.java b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeChestLootTableProvider.java index b817692a..c1f3c20e 100644 --- a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeChestLootTableProvider.java +++ b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeChestLootTableProvider.java @@ -1,62 +1,62 @@ package fr.hugman.promenade.data.provider; import fr.hugman.promenade.loot.PromenadeLootTables; -import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; -import net.fabricmc.fabric.api.datagen.v1.provider.SimpleFabricLootTableProvider; -import net.minecraft.item.Items; -import net.minecraft.loot.LootPool; -import net.minecraft.loot.LootTable; -import net.minecraft.loot.context.LootContextTypes; -import net.minecraft.loot.entry.ItemEntry; -import net.minecraft.loot.function.SetCountLootFunction; -import net.minecraft.loot.provider.number.UniformLootNumberProvider; -import net.minecraft.registry.RegistryKey; -import net.minecraft.registry.RegistryWrapper; +import net.fabricmc.fabric.api.datagen.v1.FabricPackOutput; +import net.fabricmc.fabric.api.datagen.v1.provider.SimpleFabricLootTableSubProvider; +import net.minecraft.core.HolderLookup; +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.item.Items; +import net.minecraft.world.level.storage.loot.LootPool; +import net.minecraft.world.level.storage.loot.LootTable; +import net.minecraft.world.level.storage.loot.entries.LootItem; +import net.minecraft.world.level.storage.loot.functions.SetItemCountFunction; +import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets; +import net.minecraft.world.level.storage.loot.providers.number.UniformGenerator; import java.util.concurrent.CompletableFuture; import java.util.function.BiConsumer; -public class PromenadeChestLootTableProvider extends SimpleFabricLootTableProvider { - public PromenadeChestLootTableProvider(FabricDataOutput output, CompletableFuture registryLookup) { - super(output, registryLookup, LootContextTypes.CHEST); +public class PromenadeChestLootTableProvider extends SimpleFabricLootTableSubProvider { + public PromenadeChestLootTableProvider(FabricPackOutput output, CompletableFuture registryLookup) { + super(output, registryLookup, LootContextParamSets.CHEST); } @Override - public void accept(BiConsumer, LootTable.Builder> output) { + public void generate(BiConsumer, LootTable.Builder> output) { output.accept(PromenadeLootTables.WITCH_HUT_CHEST, - LootTable.builder().pool(LootPool.builder() - .rolls(UniformLootNumberProvider.create(4, 7)) - .with(ItemEntry.builder(Items.GLASS_BOTTLE) - .weight(5) - .apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(1, 3))) + LootTable.lootTable().withPool(LootPool.lootPool() + .setRolls(UniformGenerator.between(4, 7)) + .add(LootItem.lootTableItem(Items.GLASS_BOTTLE) + .setWeight(5) + .apply(SetItemCountFunction.setCount(UniformGenerator.between(1, 3))) ) - .with(ItemEntry.builder(Items.MAGMA_CREAM).weight(2)) - .with(ItemEntry.builder(Items.MELON_SLICE) - .weight(6) - .apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(1, 3))) + .add(LootItem.lootTableItem(Items.MAGMA_CREAM).setWeight(2)) + .add(LootItem.lootTableItem(Items.MELON_SLICE) + .setWeight(6) + .apply(SetItemCountFunction.setCount(UniformGenerator.between(1, 3))) ) - .with(ItemEntry.builder(Items.GLISTERING_MELON_SLICE).weight(2)) - .with(ItemEntry.builder(Items.CARROT) - .weight(10) - .apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(1, 4))) + .add(LootItem.lootTableItem(Items.GLISTERING_MELON_SLICE).setWeight(2)) + .add(LootItem.lootTableItem(Items.CARROT) + .setWeight(10) + .apply(SetItemCountFunction.setCount(UniformGenerator.between(1, 4))) ) - .with(ItemEntry.builder(Items.GOLDEN_CARROT).weight(2)) - .with(ItemEntry.builder(Items.APPLE) - .weight(10) - .apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(1, 5))) + .add(LootItem.lootTableItem(Items.GOLDEN_CARROT).setWeight(2)) + .add(LootItem.lootTableItem(Items.APPLE) + .setWeight(10) + .apply(SetItemCountFunction.setCount(UniformGenerator.between(1, 5))) ) - .with(ItemEntry.builder(Items.GOLDEN_APPLE)) - .with(ItemEntry.builder(Items.RABBIT_FOOT) - .weight(3) - .apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(1, 2))) + .add(LootItem.lootTableItem(Items.GOLDEN_APPLE)) + .add(LootItem.lootTableItem(Items.RABBIT_FOOT) + .setWeight(3) + .apply(SetItemCountFunction.setCount(UniformGenerator.between(1, 2))) ) - .with(ItemEntry.builder(Items.SPIDER_EYE) - .weight(6) - .apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(1, 2))) + .add(LootItem.lootTableItem(Items.SPIDER_EYE) + .setWeight(6) + .apply(SetItemCountFunction.setCount(UniformGenerator.between(1, 2))) ) - .with(ItemEntry.builder(Items.EMERALD) - .weight(4) - .apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(1, 4))) + .add(LootItem.lootTableItem(Items.EMERALD) + .setWeight(4) + .apply(SetItemCountFunction.setCount(UniformGenerator.between(1, 4))) ) ) ); diff --git a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeConfiguredFeatureProvider.java b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeConfiguredFeatureProvider.java index d37a64f5..ae7d3528 100644 --- a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeConfiguredFeatureProvider.java +++ b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeConfiguredFeatureProvider.java @@ -5,44 +5,50 @@ import fr.hugman.promenade.data.provider.builders.PromenadeFeatureConfigs; import fr.hugman.promenade.util.NoiseScale; import fr.hugman.promenade.world.gen.feature.*; -import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; +import net.fabricmc.fabric.api.datagen.v1.FabricPackOutput; import net.fabricmc.fabric.api.datagen.v1.provider.FabricDynamicRegistryProvider; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.LeafLitterBlock; -import net.minecraft.registry.Registerable; -import net.minecraft.registry.RegistryKey; -import net.minecraft.registry.RegistryKeys; -import net.minecraft.registry.RegistryWrapper; -import net.minecraft.registry.entry.RegistryEntry; -import net.minecraft.registry.tag.BlockTags; -import net.minecraft.state.property.EnumProperty; -import net.minecraft.state.property.IntProperty; -import net.minecraft.structure.rule.TagMatchRuleTest; -import net.minecraft.util.collection.Pool; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.VerticalSurfaceType; -import net.minecraft.util.math.intprovider.ConstantIntProvider; -import net.minecraft.util.math.intprovider.UniformIntProvider; -import net.minecraft.world.gen.blockpredicate.BlockPredicate; -import net.minecraft.world.gen.feature.*; -import net.minecraft.world.gen.placementmodifier.BlockFilterPlacementModifier; -import net.minecraft.world.gen.stateprovider.BlockStateProvider; -import net.minecraft.world.gen.stateprovider.WeightedBlockStateProvider; -import net.minecraft.world.gen.treedecorator.BeehiveTreeDecorator; +import net.minecraft.core.Direction; +import net.minecraft.core.Holder; +import net.minecraft.core.HolderLookup; +import net.minecraft.core.registries.Registries; +import net.minecraft.data.worldgen.BootstrapContext; +import net.minecraft.data.worldgen.features.FeatureUtils; +import net.minecraft.data.worldgen.features.VegetationFeatures; +import net.minecraft.data.worldgen.placement.PlacementUtils; +import net.minecraft.resources.ResourceKey; +import net.minecraft.tags.BlockTags; +import net.minecraft.util.random.WeightedList; +import net.minecraft.util.valueproviders.ConstantInt; +import net.minecraft.util.valueproviders.UniformInt; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.LeafLitterBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import net.minecraft.world.level.levelgen.blockpredicates.BlockPredicate; +import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; +import net.minecraft.world.level.levelgen.feature.Feature; +import net.minecraft.world.level.levelgen.feature.WeightedPlacedFeature; +import net.minecraft.world.level.levelgen.feature.configurations.*; +import net.minecraft.world.level.levelgen.feature.stateproviders.BlockStateProvider; +import net.minecraft.world.level.levelgen.feature.stateproviders.WeightedStateProvider; +import net.minecraft.world.level.levelgen.feature.treedecorators.BeehiveDecorator; +import net.minecraft.world.level.levelgen.placement.BlockPredicateFilter; +import net.minecraft.world.level.levelgen.placement.CaveSurface; +import net.minecraft.world.level.levelgen.structure.templatesystem.TagMatchTest; import java.util.List; import java.util.concurrent.CompletableFuture; public class PromenadeConfiguredFeatureProvider extends FabricDynamicRegistryProvider { - public PromenadeConfiguredFeatureProvider(FabricDataOutput output, CompletableFuture registriesFuture) { + public PromenadeConfiguredFeatureProvider(FabricPackOutput output, CompletableFuture registriesFuture) { super(output, registriesFuture); } @Override - protected void configure(RegistryWrapper.WrapperLookup registries, Entries entries) { - entries.addAll(registries.getOrThrow(RegistryKeys.CONFIGURED_FEATURE)); + protected void configure(HolderLookup.Provider registries, Entries entries) { + entries.addAll(registries.lookupOrThrow(Registries.CONFIGURED_FEATURE)); } @Override @@ -50,21 +56,21 @@ public String getName() { return "Configured Features"; } - public static void register(Registerable> registerable) { - final var configured = registerable.getRegistryLookup(RegistryKeys.CONFIGURED_FEATURE); - final var placed = registerable.getRegistryLookup(RegistryKeys.PLACED_FEATURE); + public static void register(BootstrapContext> registerable) { + final var configured = registerable.lookup(Registries.CONFIGURED_FEATURE); + final var placed = registerable.lookup(Registries.PLACED_FEATURE); // Ores - var isBaseStoneOverworld = new TagMatchRuleTest(BlockTags.BASE_STONE_OVERWORLD); + var isBaseStoneOverworld = new TagMatchTest(BlockTags.BASE_STONE_OVERWORLD); - of(registerable, PromenadeConfiguredFeatures.PACKED_ICE_ORE, Feature.ORE, new OreFeatureConfig(isBaseStoneOverworld, Blocks.PACKED_ICE.getDefaultState(), 50)); - of(registerable, PromenadeConfiguredFeatures.BLUE_ICE_ORE, Feature.ORE, new OreFeatureConfig(isBaseStoneOverworld, Blocks.PACKED_ICE.getDefaultState(), 10)); - of(registerable, PromenadeConfiguredFeatures.ASPHALT_ORE, Feature.ORE, new OreFeatureConfig(isBaseStoneOverworld, PromenadeBlocks.ASPHALT.getDefaultState(), 48)); - of(registerable, PromenadeConfiguredFeatures.BLUNITE_ORE, Feature.ORE, new OreFeatureConfig(isBaseStoneOverworld, PromenadeBlocks.BLUNITE.getDefaultState(), 48)); + of(registerable, PromenadeConfiguredFeatures.PACKED_ICE_ORE, Feature.ORE, new OreConfiguration(isBaseStoneOverworld, Blocks.PACKED_ICE.defaultBlockState(), 50)); + of(registerable, PromenadeConfiguredFeatures.BLUE_ICE_ORE, Feature.ORE, new OreConfiguration(isBaseStoneOverworld, Blocks.PACKED_ICE.defaultBlockState(), 10)); + of(registerable, PromenadeConfiguredFeatures.ASPHALT_ORE, Feature.ORE, new OreConfiguration(isBaseStoneOverworld, PromenadeBlocks.ASPHALT.defaultBlockState(), 48)); + of(registerable, PromenadeConfiguredFeatures.BLUNITE_ORE, Feature.ORE, new OreConfiguration(isBaseStoneOverworld, PromenadeBlocks.BLUNITE.defaultBlockState(), 48)); // Trees - var beehive005 = new BeehiveTreeDecorator(0.05F); - var beehive002 = new BeehiveTreeDecorator(0.02F); + var beehive005 = new BeehiveDecorator(0.05F); + var beehive002 = new BeehiveDecorator(0.02F); of(registerable, PromenadeConfiguredFeatures.BLUSH_SAKURA, Feature.TREE, PromenadeFeatureConfigs.sakura(PromenadeBlocks.BLUSH_SAKURA_BLOSSOMS, false).build()); of(registerable, PromenadeConfiguredFeatures.FANCY_BLUSH_SAKURA, Feature.TREE, PromenadeFeatureConfigs.sakura(PromenadeBlocks.BLUSH_SAKURA_BLOSSOMS, true).build()); @@ -105,112 +111,93 @@ public static void register(Registerable> registerable) // Vegetation of(registerable, PromenadeConfiguredFeatures.WATER_POOL_GRAVEL_DECORATED, Feature.WATERLOGGED_VEGETATION_PATCH, - new VegetationPatchFeatureConfig( + new VegetationPatchConfiguration( BlockTags.LUSH_GROUND_REPLACEABLE, - BlockStateProvider.of(Blocks.GRAVEL), - PlacedFeatures.createEntry(RegistryEntry.of(new ConfiguredFeature<>(Feature.RANDOM_SELECTOR, new RandomFeatureConfig(List.of(new RandomFeatureEntry(PlacedFeatures.createEntry(configured.getOrThrow(VegetationConfiguredFeatures.BAMBOO_SOME_PODZOL)), 0.4F)), PlacedFeatures.createEntry(configured.getOrThrow(VegetationConfiguredFeatures.PATCH_WATERLILY)))))), //hello there - VerticalSurfaceType.FLOOR, - ConstantIntProvider.create(3), + BlockStateProvider.simple(Blocks.GRAVEL), + PlacementUtils.inlinePlaced(Holder.direct(new ConfiguredFeature<>(Feature.RANDOM_SELECTOR, new RandomFeatureConfiguration(List.of(new WeightedPlacedFeature(PlacementUtils.inlinePlaced(configured.getOrThrow(VegetationFeatures.BAMBOO_SOME_PODZOL)), 0.4F)), PlacementUtils.inlinePlaced(configured.getOrThrow(VegetationFeatures.WATERLILY)))))), //hello there + CaveSurface.FLOOR, + ConstantInt.of(3), 0.8F, 5, 0.15F, - UniformIntProvider.create(4, 7), + UniformInt.of(4, 7), 0.7F )); of(registerable, PromenadeConfiguredFeatures.CUTE_LITTLE_ROCK, PromenadeFeatures.BOULDER, new BoulderFeatureConfig( - new WeightedBlockStateProvider( - Pool.builder() - .add(Blocks.STONE.getDefaultState(), 80) - .add(Blocks.CALCITE.getDefaultState(), 20) + new WeightedStateProvider( + WeightedList.builder() + .add(Blocks.STONE.defaultBlockState(), 80) + .add(Blocks.CALCITE.defaultBlockState(), 20) ), - BlockPredicate.matchingBlocks(Blocks.GRASS_BLOCK), - UniformIntProvider.create(3, 4) + BlockPredicate.matchesBlocks(Blocks.GRASS_BLOCK), + UniformInt.of(3, 4) )); + of(registerable, PromenadeConfiguredFeatures.BLUEBERRY_BUSH, Feature.SIMPLE_BLOCK, new SimpleBlockConfiguration(BlockStateProvider.simple(PromenadeBlocks.BLUEBERRY_BUSH.defaultBlockState().setValue(BerryBushBlock.AGE, 3)))); - of(registerable, PromenadeConfiguredFeatures.BAMBOO_PATCH, Feature.RANDOM_PATCH, - new RandomPatchFeatureConfig(25, 3, 3, - PlacedFeatures.createEntry(configured.getOrThrow(VegetationConfiguredFeatures.BAMBOO_SOME_PODZOL), BlockFilterPlacementModifier.of(BlockPredicate.IS_AIR)) - )); - of(registerable, PromenadeConfiguredFeatures.BLUEBERRY_BUSH_PATCH, Feature.RANDOM_PATCH, - ConfiguredFeatures.createRandomPatchFeatureConfig( - Feature.SIMPLE_BLOCK, - new SimpleBlockFeatureConfig(BlockStateProvider.of(PromenadeBlocks.BLUEBERRY_BUSH.getDefaultState().with(BerryBushBlock.AGE, 3))), - List.of(Blocks.GRASS_BLOCK) - )); - - WeightedBlockStateProvider darkAmaranthVegetation = new WeightedBlockStateProvider( - Pool.builder() - .add(PromenadeBlocks.DARK_AMARANTH_ROOTS.getDefaultState(), 87) - .add(PromenadeBlocks.DARK_AMARANTH_FUNGUS.getDefaultState(), 11) - .add(Blocks.WARPED_FUNGUS.getDefaultState(), 1) - .add(Blocks.WARPED_ROOTS.getDefaultState(), 1) + WeightedStateProvider darkAmaranthVegetation = new WeightedStateProvider( + WeightedList.builder() + .add(PromenadeBlocks.DARK_AMARANTH_ROOTS.defaultBlockState(), 87) + .add(PromenadeBlocks.DARK_AMARANTH_FUNGUS.defaultBlockState(), 11) + .add(Blocks.WARPED_FUNGUS.defaultBlockState(), 1) + .add(Blocks.WARPED_ROOTS.defaultBlockState(), 1) ); - of(registerable, PromenadeConfiguredFeatures.DARK_AMARANTH_FOREST_VEGETATION, Feature.NETHER_FOREST_VEGETATION, new NetherForestVegetationFeatureConfig(darkAmaranthVegetation, 8, 4)); - of(registerable, PromenadeConfiguredFeatures.DARK_AMARANTH_FOREST_BONEMEAL_VEGETATION, Feature.NETHER_FOREST_VEGETATION, new NetherForestVegetationFeatureConfig(darkAmaranthVegetation, 3, 1)); + of(registerable, PromenadeConfiguredFeatures.DARK_AMARANTH_FOREST_VEGETATION, Feature.NETHER_FOREST_VEGETATION, new NetherForestVegetationConfig(darkAmaranthVegetation, 8, 4)); + of(registerable, PromenadeConfiguredFeatures.DARK_AMARANTH_FOREST_BONEMEAL_VEGETATION, Feature.NETHER_FOREST_VEGETATION, new NetherForestVegetationConfig(darkAmaranthVegetation, 3, 1)); var horizontalDirections = List.of(Direction.NORTH, Direction.SOUTH, Direction.WEST, Direction.EAST); of(registerable, PromenadeConfiguredFeatures.COILED_VINES, PromenadeFeatures.COILED_VINES, new CoiledVinesFeatureConfig(8, 4, 8, horizontalDirections)); - of(registerable, PromenadeConfiguredFeatures.FALLEN_VERMILION_MAPLE_LEAVES, Feature.RANDOM_PATCH, ConfiguredFeatures.createRandomPatchFeatureConfig( - Feature.SIMPLE_BLOCK, - new SimpleBlockFeatureConfig(new WeightedBlockStateProvider(fallenLeaves(PromenadeBlocks.FALLEN_VERMILION_MAPLE_LEAVES, 1, 3))) - )); - of(registerable, PromenadeConfiguredFeatures.FALLEN_FULVOUS_MAPLE_LEAVES, Feature.RANDOM_PATCH, ConfiguredFeatures.createRandomPatchFeatureConfig( - Feature.SIMPLE_BLOCK, - new SimpleBlockFeatureConfig(new WeightedBlockStateProvider(fallenLeaves(PromenadeBlocks.FALLEN_FULVOUS_MAPLE_LEAVES, 1, 3))) - )); - of(registerable, PromenadeConfiguredFeatures.FALLEN_MIKADO_MAPLE_LEAVES, Feature.RANDOM_PATCH, ConfiguredFeatures.createRandomPatchFeatureConfig( - Feature.SIMPLE_BLOCK, - new SimpleBlockFeatureConfig(new WeightedBlockStateProvider(fallenLeaves(PromenadeBlocks.FALLEN_MIKADO_MAPLE_LEAVES, 1, 3))) - )); + of(registerable, PromenadeConfiguredFeatures.FALLEN_VERMILION_MAPLE_LEAVES, Feature.SIMPLE_BLOCK, new SimpleBlockConfiguration(new WeightedStateProvider(fallenLeaves(PromenadeBlocks.FALLEN_VERMILION_MAPLE_LEAVES, 1, 3)))); + of(registerable, PromenadeConfiguredFeatures.FALLEN_FULVOUS_MAPLE_LEAVES, Feature.SIMPLE_BLOCK, new SimpleBlockConfiguration(new WeightedStateProvider(fallenLeaves(PromenadeBlocks.FALLEN_FULVOUS_MAPLE_LEAVES, 1, 3)))); + of(registerable, PromenadeConfiguredFeatures.FALLEN_MIKADO_MAPLE_LEAVES, Feature.SIMPLE_BLOCK, new SimpleBlockConfiguration(new WeightedStateProvider(fallenLeaves(PromenadeBlocks.FALLEN_MIKADO_MAPLE_LEAVES, 1, 3)))); // Grouped features of(registerable, PromenadeConfiguredFeatures.BLUSH_SAKURA_GROVE_TREE, Feature.RANDOM_SELECTOR, - new RandomFeatureConfig(List.of( - new RandomFeatureEntry(placed.getOrThrow(PromenadePlacedFeatures.FANCY_BLUSH_SAKURA), 0.1f), - new RandomFeatureEntry(placed.getOrThrow(PromenadePlacedFeatures.COTTON_SAKURA), 0.2f) + new RandomFeatureConfiguration(List.of( + new WeightedPlacedFeature(placed.getOrThrow(PromenadePlacedFeatures.FANCY_BLUSH_SAKURA), 0.1f), + new WeightedPlacedFeature(placed.getOrThrow(PromenadePlacedFeatures.COTTON_SAKURA), 0.2f) ), placed.getOrThrow(PromenadePlacedFeatures.BLUSH_SAKURA)) ); of(registerable, PromenadeConfiguredFeatures.COTTON_SAKURA_GROVE_TREE, Feature.RANDOM_SELECTOR, - new RandomFeatureConfig(List.of( - new RandomFeatureEntry(placed.getOrThrow(PromenadePlacedFeatures.FANCY_COTTON_SAKURA), 0.1f), - new RandomFeatureEntry(placed.getOrThrow(PromenadePlacedFeatures.BLUSH_SAKURA), 0.2f) + new RandomFeatureConfiguration(List.of( + new WeightedPlacedFeature(placed.getOrThrow(PromenadePlacedFeatures.FANCY_COTTON_SAKURA), 0.1f), + new WeightedPlacedFeature(placed.getOrThrow(PromenadePlacedFeatures.BLUSH_SAKURA), 0.2f) ), placed.getOrThrow(PromenadePlacedFeatures.COTTON_SAKURA)) ); of(registerable, PromenadeConfiguredFeatures.CARNELIAN_TREEWAY_SAP_TREE, Feature.RANDOM_SELECTOR, - new RandomFeatureConfig(List.of( - new RandomFeatureEntry(placed.getOrThrow(PromenadePlacedFeatures.FANCY_SAP_MAPLE_BEES), 0.1f), - new RandomFeatureEntry(placed.getOrThrow(PromenadePlacedFeatures.FANCY_SAP_MAPLE), 0.2f) + new RandomFeatureConfiguration(List.of( + new WeightedPlacedFeature(placed.getOrThrow(PromenadePlacedFeatures.FANCY_SAP_MAPLE_BEES), 0.1f), + new WeightedPlacedFeature(placed.getOrThrow(PromenadePlacedFeatures.FANCY_SAP_MAPLE), 0.2f) ), placed.getOrThrow(PromenadePlacedFeatures.SAP_MAPLE)) ); of(registerable, PromenadeConfiguredFeatures.CARNELIAN_TREEWAY_VERMILION_TREE, Feature.RANDOM_SELECTOR, - new RandomFeatureConfig(List.of( - new RandomFeatureEntry(placed.getOrThrow(PromenadePlacedFeatures.FANCY_VERMILION_MAPLE_BEES), 0.1f), - new RandomFeatureEntry(placed.getOrThrow(PromenadePlacedFeatures.FANCY_VERMILION_MAPLE), 0.2f) + new RandomFeatureConfiguration(List.of( + new WeightedPlacedFeature(placed.getOrThrow(PromenadePlacedFeatures.FANCY_VERMILION_MAPLE_BEES), 0.1f), + new WeightedPlacedFeature(placed.getOrThrow(PromenadePlacedFeatures.FANCY_VERMILION_MAPLE), 0.2f) ), placed.getOrThrow(PromenadePlacedFeatures.VERMILION_MAPLE)) ); of(registerable, PromenadeConfiguredFeatures.CARNELIAN_TREEWAY_FULVOUS_TREE, Feature.RANDOM_SELECTOR, - new RandomFeatureConfig(List.of( - new RandomFeatureEntry(placed.getOrThrow(PromenadePlacedFeatures.FANCY_FULVOUS_MAPLE_BEES), 0.1f), - new RandomFeatureEntry(placed.getOrThrow(PromenadePlacedFeatures.FANCY_FULVOUS_MAPLE), 0.2f) + new RandomFeatureConfiguration(List.of( + new WeightedPlacedFeature(placed.getOrThrow(PromenadePlacedFeatures.FANCY_FULVOUS_MAPLE_BEES), 0.1f), + new WeightedPlacedFeature(placed.getOrThrow(PromenadePlacedFeatures.FANCY_FULVOUS_MAPLE), 0.2f) ), placed.getOrThrow(PromenadePlacedFeatures.FULVOUS_MAPLE)) ); of(registerable, PromenadeConfiguredFeatures.CARNELIAN_TREEWAY_MIKADO_TREE, Feature.RANDOM_SELECTOR, - new RandomFeatureConfig(List.of( - new RandomFeatureEntry(placed.getOrThrow(PromenadePlacedFeatures.FANCY_MIKADO_MAPLE_BEES), 0.1f), - new RandomFeatureEntry(placed.getOrThrow(PromenadePlacedFeatures.FANCY_MIKADO_MAPLE), 0.2f) + new RandomFeatureConfiguration(List.of( + new WeightedPlacedFeature(placed.getOrThrow(PromenadePlacedFeatures.FANCY_MIKADO_MAPLE_BEES), 0.1f), + new WeightedPlacedFeature(placed.getOrThrow(PromenadePlacedFeatures.FANCY_MIKADO_MAPLE), 0.2f) ), placed.getOrThrow(PromenadePlacedFeatures.MIKADO_MAPLE)) ); of(registerable, PromenadeConfiguredFeatures.CARNELIAN_TREEWAY_TREE, PromenadeFeatures.NOISE_PICKED, new NoisePickedFeatureConfig(NoiseScale.of(200.0f), List.of( - new NoisePickedFeatureEntry(PlacedFeatures.createEntry(configured.getOrThrow(PromenadeConfiguredFeatures.CARNELIAN_TREEWAY_SAP_TREE)), -1.0f, 1.0f), - new NoisePickedFeatureEntry(PlacedFeatures.createEntry(configured.getOrThrow(PromenadeConfiguredFeatures.CARNELIAN_TREEWAY_VERMILION_TREE)), 0.2f, 0.95f), - new NoisePickedFeatureEntry(PlacedFeatures.createEntry(configured.getOrThrow(PromenadeConfiguredFeatures.CARNELIAN_TREEWAY_FULVOUS_TREE)), -0.5f, 0.5f), - new NoisePickedFeatureEntry(PlacedFeatures.createEntry(configured.getOrThrow(PromenadeConfiguredFeatures.CARNELIAN_TREEWAY_MIKADO_TREE)), -0.95f, -0.2f) + new NoisePickedFeatureEntry(PlacementUtils.inlinePlaced(configured.getOrThrow(PromenadeConfiguredFeatures.CARNELIAN_TREEWAY_SAP_TREE)), -1.0f, 1.0f), + new NoisePickedFeatureEntry(PlacementUtils.inlinePlaced(configured.getOrThrow(PromenadeConfiguredFeatures.CARNELIAN_TREEWAY_VERMILION_TREE)), 0.2f, 0.95f), + new NoisePickedFeatureEntry(PlacementUtils.inlinePlaced(configured.getOrThrow(PromenadeConfiguredFeatures.CARNELIAN_TREEWAY_FULVOUS_TREE)), -0.5f, 0.5f), + new NoisePickedFeatureEntry(PlacementUtils.inlinePlaced(configured.getOrThrow(PromenadeConfiguredFeatures.CARNELIAN_TREEWAY_MIKADO_TREE)), -0.95f, -0.2f) )) ); of(registerable, PromenadeConfiguredFeatures.CARNELIAN_TREEWAY_FALLEN_LEAVES, PromenadeFeatures.NOISE_PICKED, @@ -222,23 +209,23 @@ public static void register(Registerable> registerable) ); } - public static Pool.Builder fallenLeaves(Block block, int min, int max) { - return segmentedBlock(block, min, max, LeafLitterBlock.SEGMENT_AMOUNT, LeafLitterBlock.HORIZONTAL_FACING); + public static WeightedList.Builder fallenLeaves(Block block, int min, int max) { + return segmentedBlock(block, min, max, LeafLitterBlock.AMOUNT, LeafLitterBlock.FACING); } - private static Pool.Builder segmentedBlock(Block block, int min, int max, IntProperty amountProperty, EnumProperty facingProperty) { - Pool.Builder builder = Pool.builder(); + private static WeightedList.Builder segmentedBlock(Block block, int min, int max, IntegerProperty amountProperty, EnumProperty facingProperty) { + WeightedList.Builder builder = WeightedList.builder(); for (int i = min; i <= max; ++i) { - for (Direction direction : Direction.Type.HORIZONTAL) { - builder.add(block.getDefaultState().with(amountProperty, i).with(facingProperty, direction), 1); + for (Direction direction : Direction.Plane.HORIZONTAL) { + builder.add(block.defaultBlockState().setValue(amountProperty, i).setValue(facingProperty, direction), 1); } } return builder; } - private static > void of(Registerable> registry, RegistryKey> key, F feature, FC config) { - ConfiguredFeatures.register(registry, key, feature, config); + private static > void of(BootstrapContext> registry, ResourceKey> key, F feature, FC config) { + FeatureUtils.register(registry, key, feature, config); } } \ No newline at end of file diff --git a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeDuckVariantProvider.java b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeDuckVariantProvider.java index 0b4378d1..89a454bd 100644 --- a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeDuckVariantProvider.java +++ b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeDuckVariantProvider.java @@ -4,28 +4,28 @@ import fr.hugman.promenade.entity.variant.DuckVariants; import fr.hugman.promenade.registry.PromenadeRegistryKeys; import fr.hugman.promenade.tag.PromenadeBiomeTags; -import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; +import net.fabricmc.fabric.api.datagen.v1.FabricPackOutput; import net.fabricmc.fabric.api.datagen.v1.provider.FabricDynamicRegistryProvider; -import net.minecraft.entity.spawn.SpawnConditionSelectors; -import net.minecraft.registry.Registerable; -import net.minecraft.registry.RegistryKey; -import net.minecraft.registry.RegistryKeys; -import net.minecraft.registry.RegistryWrapper; -import net.minecraft.registry.tag.TagKey; -import net.minecraft.util.AssetInfo.TextureAssetInfo; -import net.minecraft.world.biome.Biome; +import net.minecraft.core.ClientAsset.ResourceTexture; +import net.minecraft.core.HolderLookup; +import net.minecraft.core.registries.Registries; +import net.minecraft.data.worldgen.BootstrapContext; +import net.minecraft.resources.ResourceKey; +import net.minecraft.tags.TagKey; +import net.minecraft.world.entity.variant.SpawnPrioritySelectors; +import net.minecraft.world.level.biome.Biome; import java.util.concurrent.CompletableFuture; //TODO: a generic class for other devs public class PromenadeDuckVariantProvider extends FabricDynamicRegistryProvider { - public PromenadeDuckVariantProvider(FabricDataOutput output, CompletableFuture registriesFuture) { + public PromenadeDuckVariantProvider(FabricPackOutput output, CompletableFuture registriesFuture) { super(output, registriesFuture); } @Override - protected void configure(RegistryWrapper.WrapperLookup registries, Entries entries) { - entries.addAll(registries.getOrThrow(PromenadeRegistryKeys.DUCK_VARIANT)); + protected void configure(HolderLookup.Provider registries, Entries entries) { + entries.addAll(registries.lookupOrThrow(PromenadeRegistryKeys.DUCK_VARIANT)); } @Override @@ -33,16 +33,16 @@ public String getName() { return "Duck Variants"; } - public static void register(Registerable registerable) { + public static void register(BootstrapContext registerable) { of(registerable, DuckVariants.PEKIN, PromenadeBiomeTags.SPAWNS_PEKIN_DUCKS); of(registerable, DuckVariants.MALLARD, PromenadeBiomeTags.SPAWNS_MALLARD_DUCKS); } - private static void of(Registerable registry, RegistryKey key, TagKey biomeTag) { - of(registry, key, DataProviderUtil.createSpawnConditions(registry.getRegistryLookup(RegistryKeys.BIOME).getOrThrow(biomeTag))); + private static void of(BootstrapContext registry, ResourceKey key, TagKey biomeTag) { + of(registry, key, DataProviderUtil.createSpawnConditions(registry.lookup(Registries.BIOME).getOrThrow(biomeTag))); } - private static void of(Registerable registry, RegistryKey key, SpawnConditionSelectors spawnConditions) { - registry.register(key, new DuckVariant(new TextureAssetInfo(key.getValue().withPrefixedPath("entity/duck/")), DuckVariant.DEFAULT_DUCKLING_ASSET, spawnConditions)); + private static void of(BootstrapContext registry, ResourceKey key, SpawnPrioritySelectors spawnConditions) { + registry.register(key, new DuckVariant(new ResourceTexture(key.identifier().withPrefix("entity/duck/")), DuckVariant.DEFAULT_DUCKLING_ASSET, spawnConditions)); } } \ No newline at end of file diff --git a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeEnglishLangProvider.java b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeEnglishLangProvider.java index 3db4b965..57f4bb5a 100644 --- a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeEnglishLangProvider.java +++ b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeEnglishLangProvider.java @@ -6,204 +6,205 @@ import fr.hugman.promenade.tag.PromenadeBlockTags; import fr.hugman.promenade.tag.PromenadeEntityTypeTags; import fr.hugman.promenade.tag.PromenadeItemTags; -import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; +import net.fabricmc.fabric.api.datagen.v1.FabricPackOutput; import net.fabricmc.fabric.api.datagen.v1.provider.FabricLanguageProvider; -import net.minecraft.registry.Registry; -import net.minecraft.registry.RegistryKey; -import net.minecraft.registry.RegistryKeys; -import net.minecraft.registry.RegistryWrapper; -import net.minecraft.registry.entry.RegistryEntry; -import net.minecraft.registry.tag.TagKey; -import net.minecraft.util.DyeColor; +import net.minecraft.core.Holder; +import net.minecraft.core.HolderLookup; +import net.minecraft.core.Registry; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceKey; +import net.minecraft.tags.TagKey; import net.minecraft.util.Util; +import net.minecraft.world.item.DyeColor; import java.util.List; import java.util.Set; import java.util.concurrent.CompletableFuture; public class PromenadeEnglishLangProvider extends FabricLanguageProvider { - private static final Set DO_NOT_TITLE_CASE = Set.of( - "of", "the", "and", "a", "an", "in", "on", "for", "to", "at", "by", "from", "with" - ); - - public PromenadeEnglishLangProvider(FabricDataOutput dataOutput, CompletableFuture registryLookup) { - super(dataOutput, "en_us", registryLookup); - } - - @Override - public void generateTranslations(RegistryWrapper.WrapperLookup wrapperLookup, TranslationBuilder builder) { - builder.add(PromenadeItems.DUCK, "Raw Duck"); - - this.generateAutomaticTranslations(wrapperLookup, builder); - - // Advancements - - builder.add("advancements.promenade.adventure.kill_sunken_outside_water.description", "Kill a sunken that's outside of water using a crossbow while being submerged yourself"); - builder.add("advancements.promenade.adventure.kill_sunken_outside_water.title", "Supernautica: Above Sixty-Two"); - builder.add("advancements.promenade.husbandry.harvest_maple_syrup.description", "Strip a natural Maple tree using an Axe to collect Maple Syrup with a Bottle"); - builder.add("advancements.promenade.husbandry.harvest_maple_syrup.title", "Don't Worry, Be Sappy!"); - - // Subtitles - - builder.add("subtitles.promenade.entity.capybara.ambient", "Capybara squeaks"); - builder.add("subtitles.promenade.entity.capybara.death", "Capybara dies"); - builder.add("subtitles.promenade.entity.capybara.fart", "Capybara farts"); - builder.add("subtitles.promenade.entity.capybara.hurt", "Capybara hurts"); - builder.add("subtitles.promenade.entity.duck.ambient", "Duck quacks"); - builder.add("subtitles.promenade.entity.duck.death", "Duck dies"); - builder.add("subtitles.promenade.entity.duck.hurt", "Duck hurts"); - builder.add("subtitles.promenade.entity.sunken.ambient", "Sunken rattles"); - builder.add("subtitles.promenade.entity.sunken.death", "Sunken dies"); - builder.add("subtitles.promenade.entity.sunken.hurt", "Sunken hurts"); - builder.add("subtitles.promenade.entity.sunken.shoot", "Sunken shoots"); - - // Tags - - builder.add(PromenadeItemTags.APRICOTS_FOODS, "Apricots"); - builder.add(PromenadeItemTags.BANANA_FOODS, "Bananas"); - builder.add(PromenadeItemTags.MANGOES_FOODS, "Mangoes"); - builder.add(PromenadeItemTags.BLUEBERRIES_FOODS, "Blueberries"); - builder.add(PromenadeItemTags.MAPLE_SYRUP_DRINKS, "Maple Syrups"); - builder.add(PromenadeItemTags.CAPYBARA_FOOD, "Food for Capybaras"); - builder.add(PromenadeItemTags.DUCK_FOOD, "Food for Ducks"); - builder.add(PromenadeBiomeTags.PRIMARY_WOOD_TYPE_SAKURA, "Sakura Primary Wood Type"); - builder.add(PromenadeBiomeTags.PRIMARY_WOOD_TYPE_PALM, "Palm Primary Wood Type"); - builder.add(PromenadeBiomeTags.PRIMARY_WOOD_TYPE_MAPLE, "Maple Primary Wood Type"); - builder.add(PromenadeBiomeTags.PRIMARY_WOOD_TYPE_DARK_AMARANTH, "Dark Amaranth Primary Wood Type"); - this.generateAutomaticTagTranslations(builder, - PromenadeBlockTags.SAKURA_LOGS, - PromenadeBlockTags.MAPLE_LOGS, - PromenadeBlockTags.PALM_LOGS, - PromenadeBlockTags.DARK_AMARANTH_STEMS, - PromenadeBlockTags.SNOWY_LEAVES, - PromenadeBlockTags.FALLEN_LEAVES, - PromenadeBlockTags.LEAF_PILES, - PromenadeBlockTags.FLOWER_PILES, - PromenadeBlockTags.DARK_AMARANTH_FUNGUS_PLACEABLE_ON, - PromenadeBlockTags.DARK_AMARANTH_FUNGUS_GROWABLE_ON, - PromenadeBlockTags.DARK_AMARANTH_ROOTS_PLACEABLE_ON, - PromenadeBlockTags.IGNEOUS_ROCKS, - PromenadeItemTags.SAKURA_LOGS, - PromenadeItemTags.MAPLE_LOGS, - PromenadeItemTags.PALM_LOGS, - PromenadeItemTags.DARK_AMARANTH_STEMS, - PromenadeItemTags.SNOWY_LEAVES, - PromenadeItemTags.IGNEOUS_ROCKS, - PromenadeEntityTypeTags.ANIMALS, - PromenadeEntityTypeTags.MONSTERS, - PromenadeEntityTypeTags.BIRDS, - PromenadeEntityTypeTags.RODENTS, - PromenadeEntityTypeTags.CREEPERS, - PromenadeBiomeTags.SAKURA_GROVES, - PromenadeBiomeTags.HAS_PALMS, - PromenadeBiomeTags.HAS_DARK_FOREST_WITCH_HUTS, - PromenadeBiomeTags.CAN_FREEZE_DURING_SNOWFALL, - PromenadeBiomeTags.SPAWNS_CAPYBARAS, - PromenadeBiomeTags.SPAWNS_SUNKEN, - PromenadeBiomeTags.SPAWNS_MALLARD_DUCKS, - PromenadeBiomeTags.SPAWNS_PEKIN_DUCKS - ); - - // Other - - builder.add("name.hugman", "Hugman"); - builder.add("death.fell.accident.coiled_vines", "%1$s fell off some coiled vines"); - builder.add("gamerule.doBlocksGetSnowy", "Blocks can get snowy"); - builder.add("gamerule.doBlocksGetSnowy.description", "Some blocks may turn into snowy variants when they are covered by a snow layer"); - - // Mod compatibility - - builder.add("modmenu.descriptionTranslation.promenade", "Fancy and simplistic animals, biomes, structures and more!"); - } - - private void generateAutomaticTranslations(RegistryWrapper.WrapperLookup wrapperLookup, TranslationBuilder builder) { - for (var block : getRegistryEntries(wrapperLookup, RegistryKeys.BLOCK)) { - builder.add(block.value(), snakeToTitleCase(block.registryKey().getValue().getPath())); - } - - for (var item : getRegistryEntries(wrapperLookup, RegistryKeys.ITEM)) { - if (item.value().getTranslationKey().startsWith("block.")) { - continue; - } - var path = item.registryKey().getValue().getPath(); - if (path.endsWith("_chest_boat")) { - path = path.replace("_chest_boat", "_boat_with_chest"); - } - try { - builder.add(item.value(), snakeToTitleCase(path)); - } catch (RuntimeException ignored) {} - } - - for (var entity : getRegistryEntries(wrapperLookup, RegistryKeys.ENTITY_TYPE)) { - var path = entity.registryKey().getValue().getPath(); - if (path.endsWith("_chest_boat")) { - path = path.replace("_chest_boat", "_boat_with_chest"); - } - builder.add(entity.value(), snakeToTitleCase(path)); - } - - for (var biome : getRegistryEntries(wrapperLookup, RegistryKeys.BIOME)) { - var id = biome.registryKey().getValue(); - builder.add(Util.createTranslationKey("biome", id), snakeToTitleCase(id.getPath())); - } - - for (var bannerPattern : getRegistryEntries(wrapperLookup, RegistryKeys.BANNER_PATTERN)) { - var id = bannerPattern.registryKey().getValue(); - builder.add( - Util.createTranslationKey("item", id.withPath(s -> s + "_banner_pattern.desc")), - snakeToTitleCase(id.getPath()) - ); - for (DyeColor color : DyeColor.values()) { - builder.add( - Util.createTranslationKey("block", id.withPath(s -> "banner." + s + "." + color.getId())), - snakeToTitleCase(color.getId() + "_" + id.getPath()) - ); - } - } - - for (var paintingVariant : getRegistryEntries(wrapperLookup, RegistryKeys.PAINTING_VARIANT)) { - var id = paintingVariant.registryKey().getValue(); - builder.add(Util.createTranslationKey("painting", id) + ".title", snakeToTitleCase(id.getPath())); - } - - for (var itemGroup : getRegistryEntries(wrapperLookup, RegistryKeys.ITEM_GROUP)) { - var id = itemGroup.registryKey().getValue(); - builder.add(Util.createTranslationKey("item_group", id), snakeToTitleCase(id.getPath())); - } - } - - - private void generateAutomaticTagTranslations(TranslationBuilder builder, TagKey... tagKeys) { - for (var tagKey : tagKeys) { - var id = tagKey.id(); - builder.add(tagKey, snakeToTitleCase(id.getPath())); - } - } - - private static List> getRegistryEntries(RegistryWrapper.WrapperLookup wrapperLookup, RegistryKey> registryKey) { - return wrapperLookup.getOrThrow(registryKey).streamEntries() - .filter(entry -> entry.registryKey().getValue().getNamespace().equals(Promenade.MOD_ID)) - .toList(); - } - - private static String snakeToTitleCase(String str) { - String[] words = str.split("_"); - StringBuilder titleCase = new StringBuilder(); - for (int i = 0; i < words.length; i++) { - String word = words[i]; - if (word.isEmpty()) { - continue; - } - if (i != 0 && DO_NOT_TITLE_CASE.contains(word.toLowerCase())) { - titleCase.append(word.toLowerCase()); - } else { - titleCase.append(Character.toUpperCase(word.charAt(0))) - .append(word.substring(1).toLowerCase()); - } - if (i < words.length - 1) { - titleCase.append(" "); - } - } - return titleCase.toString(); - } + private static final Set DO_NOT_TITLE_CASE = Set.of( + "of", "the", "and", "a", "an", "in", "on", "for", "to", "at", "by", "from", "with" + ); + + public PromenadeEnglishLangProvider(FabricPackOutput dataOutput, CompletableFuture registryLookup) { + super(dataOutput, "en_us", registryLookup); + } + + @Override + public void generateTranslations(HolderLookup.Provider wrapperLookup, TranslationBuilder builder) { + builder.add(PromenadeItems.DUCK, "Raw Duck"); + + this.generateAutomaticTranslations(wrapperLookup, builder); + + // Advancements + + builder.add("advancements.promenade.adventure.kill_sunken_outside_water.description", "Kill a sunken that's outside of water using a crossbow while being submerged yourself"); + builder.add("advancements.promenade.adventure.kill_sunken_outside_water.title", "Supernautica: Above Sixty-Two"); + builder.add("advancements.promenade.husbandry.harvest_maple_syrup.description", "Strip a natural Maple tree using an Axe to collect Maple Syrup with a Bottle"); + builder.add("advancements.promenade.husbandry.harvest_maple_syrup.title", "Don't Worry, Be Sappy!"); + + // Subtitles + + builder.add("subtitles.promenade.entity.capybara.ambient", "Capybara squeaks"); + builder.add("subtitles.promenade.entity.capybara.death", "Capybara dies"); + builder.add("subtitles.promenade.entity.capybara.fart", "Capybara farts"); + builder.add("subtitles.promenade.entity.capybara.hurt", "Capybara hurts"); + builder.add("subtitles.promenade.entity.duck.ambient", "Duck quacks"); + builder.add("subtitles.promenade.entity.duck.death", "Duck dies"); + builder.add("subtitles.promenade.entity.duck.hurt", "Duck hurts"); + builder.add("subtitles.promenade.entity.sunken.ambient", "Sunken rattles"); + builder.add("subtitles.promenade.entity.sunken.death", "Sunken dies"); + builder.add("subtitles.promenade.entity.sunken.hurt", "Sunken hurts"); + builder.add("subtitles.promenade.entity.sunken.shoot", "Sunken shoots"); + + // Tags + + builder.add(PromenadeItemTags.APRICOTS_FOODS, "Apricots"); + builder.add(PromenadeItemTags.BANANA_FOODS, "Bananas"); + builder.add(PromenadeItemTags.MANGOES_FOODS, "Mangoes"); + builder.add(PromenadeItemTags.BLUEBERRIES_FOODS, "Blueberries"); + builder.add(PromenadeItemTags.MAPLE_SYRUP_DRINKS, "Maple Syrups"); + builder.add(PromenadeItemTags.CAPYBARA_FOOD, "Food for Capybaras"); + builder.add(PromenadeItemTags.DUCK_FOOD, "Food for Ducks"); + builder.add(PromenadeBiomeTags.PRIMARY_WOOD_TYPE_SAKURA, "Sakura Primary Wood Type"); + builder.add(PromenadeBiomeTags.PRIMARY_WOOD_TYPE_PALM, "Palm Primary Wood Type"); + builder.add(PromenadeBiomeTags.PRIMARY_WOOD_TYPE_MAPLE, "Maple Primary Wood Type"); + builder.add(PromenadeBiomeTags.PRIMARY_WOOD_TYPE_DARK_AMARANTH, "Dark Amaranth Primary Wood Type"); + this.generateAutomaticTagTranslations(builder, + PromenadeBlockTags.SAKURA_LOGS, + PromenadeBlockTags.MAPLE_LOGS, + PromenadeBlockTags.PALM_LOGS, + PromenadeBlockTags.DARK_AMARANTH_STEMS, + PromenadeBlockTags.SNOWY_LEAVES, + PromenadeBlockTags.FALLEN_LEAVES, + PromenadeBlockTags.LEAF_PILES, + PromenadeBlockTags.FLOWER_PILES, + PromenadeBlockTags.DARK_AMARANTH_FUNGUS_PLACEABLE_ON, + PromenadeBlockTags.DARK_AMARANTH_FUNGUS_GROWABLE_ON, + PromenadeBlockTags.DARK_AMARANTH_ROOTS_PLACEABLE_ON, + PromenadeBlockTags.IGNEOUS_ROCKS, + PromenadeItemTags.SAKURA_LOGS, + PromenadeItemTags.MAPLE_LOGS, + PromenadeItemTags.PALM_LOGS, + PromenadeItemTags.DARK_AMARANTH_STEMS, + PromenadeItemTags.SNOWY_LEAVES, + PromenadeItemTags.IGNEOUS_ROCKS, + PromenadeEntityTypeTags.ANIMALS, + PromenadeEntityTypeTags.MONSTERS, + PromenadeEntityTypeTags.BIRDS, + PromenadeEntityTypeTags.RODENTS, + PromenadeEntityTypeTags.CREEPERS, + PromenadeBiomeTags.SAKURA_GROVES, + PromenadeBiomeTags.HAS_PALMS, + PromenadeBiomeTags.HAS_DARK_FOREST_WITCH_HUTS, + PromenadeBiomeTags.CAN_FREEZE_DURING_SNOWFALL, + PromenadeBiomeTags.SPAWNS_CAPYBARAS, + PromenadeBiomeTags.SPAWNS_SUNKEN, + PromenadeBiomeTags.SPAWNS_MALLARD_DUCKS, + PromenadeBiomeTags.SPAWNS_PEKIN_DUCKS + ); + + // Other + + builder.add("name.hugman", "Hugman"); + builder.add("death.fell.accident.coiled_vines", "%1$s fell off some coiled vines"); + builder.add("gamerule.doBlocksGetSnowy", "Blocks can get snowy"); + builder.add("gamerule.doBlocksGetSnowy.description", "Some blocks may turn into snowy variants when they are covered by a snow layer"); + + // Mod compatibility + + builder.add("modmenu.descriptionTranslation.promenade", "Fancy and simplistic animals, biomes, structures and more!"); + } + + private void generateAutomaticTranslations(HolderLookup.Provider wrapperLookup, TranslationBuilder builder) { + for (var block : getRegistryEntries(wrapperLookup, Registries.BLOCK)) { + builder.add(block.value(), snakeToTitleCase(block.key().identifier().getPath())); + } + + for (var item : getRegistryEntries(wrapperLookup, Registries.ITEM)) { + if (item.value().getDescriptionId().startsWith("block.")) { + continue; + } + var path = item.key().identifier().getPath(); + if (path.endsWith("_chest_boat")) { + path = path.replace("_chest_boat", "_boat_with_chest"); + } + try { + builder.add(item.value(), snakeToTitleCase(path)); + } catch (RuntimeException ignored) { + } + } + + for (var entity : getRegistryEntries(wrapperLookup, Registries.ENTITY_TYPE)) { + var path = entity.key().identifier().getPath(); + if (path.endsWith("_chest_boat")) { + path = path.replace("_chest_boat", "_boat_with_chest"); + } + builder.add(entity.value(), snakeToTitleCase(path)); + } + + for (var biome : getRegistryEntries(wrapperLookup, Registries.BIOME)) { + var id = biome.key().identifier(); + builder.add(Util.makeDescriptionId("biome", id), snakeToTitleCase(id.getPath())); + } + + for (var bannerPattern : getRegistryEntries(wrapperLookup, Registries.BANNER_PATTERN)) { + var id = bannerPattern.key().identifier(); + builder.add( + Util.makeDescriptionId("item", id.withPath(s -> s + "_banner_pattern.desc")), + snakeToTitleCase(id.getPath()) + ); + for (DyeColor color : DyeColor.values()) { + builder.add( + Util.makeDescriptionId("block", id.withPath(s -> "banner." + s + "." + color.getName())), + snakeToTitleCase(color.getName() + "_" + id.getPath()) + ); + } + } + + for (var paintingVariant : getRegistryEntries(wrapperLookup, Registries.PAINTING_VARIANT)) { + var id = paintingVariant.key().identifier(); + builder.add(Util.makeDescriptionId("painting", id) + ".title", snakeToTitleCase(id.getPath())); + } + + for (var itemGroup : getRegistryEntries(wrapperLookup, Registries.CREATIVE_MODE_TAB)) { + var id = itemGroup.key().identifier(); + builder.add(Util.makeDescriptionId("item_group", id), snakeToTitleCase(id.getPath())); + } + } + + + private void generateAutomaticTagTranslations(TranslationBuilder builder, TagKey... tagKeys) { + for (var tagKey : tagKeys) { + var id = tagKey.location(); + builder.add(tagKey, snakeToTitleCase(id.getPath())); + } + } + + private static List> getRegistryEntries(HolderLookup.Provider wrapperLookup, ResourceKey> registryKey) { + return wrapperLookup.lookupOrThrow(registryKey).listElements() + .filter(entry -> entry.key().identifier().getNamespace().equals(Promenade.MOD_ID)) + .toList(); + } + + private static String snakeToTitleCase(String str) { + String[] words = str.split("_"); + StringBuilder titleCase = new StringBuilder(); + for (int i = 0; i < words.length; i++) { + String word = words[i]; + if (word.isEmpty()) { + continue; + } + if (i != 0 && DO_NOT_TITLE_CASE.contains(word.toLowerCase())) { + titleCase.append(word.toLowerCase()); + } else { + titleCase.append(Character.toUpperCase(word.charAt(0))) + .append(word.substring(1).toLowerCase()); + } + if (i < words.length - 1) { + titleCase.append(" "); + } + } + return titleCase.toString(); + } } \ No newline at end of file diff --git a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeEntityLootTableProvider.java b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeEntityLootTableProvider.java index 2a100055..7d038043 100644 --- a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeEntityLootTableProvider.java +++ b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeEntityLootTableProvider.java @@ -3,103 +3,95 @@ import fr.hugman.promenade.entity.PromenadeEntityTypes; import fr.hugman.promenade.item.PromenadeItems; import fr.hugman.promenade.loot.PromenadeLootTables; -import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; -import net.fabricmc.fabric.api.datagen.v1.provider.SimpleFabricLootTableProvider; -import net.minecraft.enchantment.Enchantment; -import net.minecraft.fluid.Fluid; -import net.minecraft.item.Item; -import net.minecraft.item.Items; -import net.minecraft.loot.LootPool; -import net.minecraft.loot.LootTable; -import net.minecraft.loot.condition.AnyOfLootCondition; -import net.minecraft.loot.condition.EntityPropertiesLootCondition; -import net.minecraft.loot.condition.LocationCheckLootCondition; -import net.minecraft.loot.context.LootContext; -import net.minecraft.loot.context.LootContextTypes; -import net.minecraft.loot.entry.ItemEntry; -import net.minecraft.loot.entry.TagEntry; -import net.minecraft.loot.function.EnchantedCountIncreaseLootFunction; -import net.minecraft.loot.function.FurnaceSmeltLootFunction; -import net.minecraft.loot.function.SetCountLootFunction; -import net.minecraft.loot.provider.number.UniformLootNumberProvider; -import net.minecraft.predicate.FluidPredicate; -import net.minecraft.predicate.NumberRange; -import net.minecraft.predicate.component.ComponentPredicateTypes; -import net.minecraft.predicate.component.ComponentsPredicate; -import net.minecraft.predicate.entity.EntityEquipmentPredicate; -import net.minecraft.predicate.entity.EntityFlagsPredicate; -import net.minecraft.predicate.entity.EntityPredicate; -import net.minecraft.predicate.entity.LocationPredicate; -import net.minecraft.predicate.item.EnchantmentPredicate; -import net.minecraft.predicate.item.EnchantmentsPredicate; -import net.minecraft.predicate.item.ItemPredicate; -import net.minecraft.registry.RegistryEntryLookup; -import net.minecraft.registry.RegistryKey; -import net.minecraft.registry.RegistryKeys; -import net.minecraft.registry.RegistryWrapper; -import net.minecraft.registry.tag.EnchantmentTags; -import net.minecraft.registry.tag.EntityTypeTags; -import net.minecraft.registry.tag.FluidTags; -import net.minecraft.registry.tag.ItemTags; +import net.fabricmc.fabric.api.datagen.v1.FabricPackOutput; +import net.fabricmc.fabric.api.datagen.v1.provider.SimpleFabricLootTableSubProvider; +import net.minecraft.advancements.criterion.*; +import net.minecraft.core.HolderGetter; +import net.minecraft.core.HolderLookup; +import net.minecraft.core.component.predicates.DataComponentPredicates; +import net.minecraft.core.component.predicates.EnchantmentsPredicate; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceKey; +import net.minecraft.tags.EnchantmentTags; +import net.minecraft.tags.EntityTypeTags; +import net.minecraft.tags.FluidTags; +import net.minecraft.tags.ItemTags; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.Items; +import net.minecraft.world.item.enchantment.Enchantment; +import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.world.level.storage.loot.LootPool; +import net.minecraft.world.level.storage.loot.LootTable; +import net.minecraft.world.level.storage.loot.entries.LootItem; +import net.minecraft.world.level.storage.loot.entries.TagEntry; +import net.minecraft.world.level.storage.loot.functions.EnchantedCountIncreaseFunction; +import net.minecraft.world.level.storage.loot.functions.SetItemCountFunction; +import net.minecraft.world.level.storage.loot.functions.SmeltItemFunction; +import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets; +import net.minecraft.world.level.storage.loot.predicates.AnyOfCondition; +import net.minecraft.world.level.storage.loot.predicates.LocationCheck; +import net.minecraft.world.level.storage.loot.predicates.LootItemEntityPropertyCondition; +import net.minecraft.world.level.storage.loot.providers.number.UniformGenerator; import java.util.List; import java.util.concurrent.CompletableFuture; import java.util.function.BiConsumer; -public class PromenadeEntityLootTableProvider extends SimpleFabricLootTableProvider { - private final RegistryWrapper.WrapperLookup registries; +public class PromenadeEntityLootTableProvider extends SimpleFabricLootTableSubProvider { + private final HolderLookup.Provider registries; - public PromenadeEntityLootTableProvider(FabricDataOutput output, CompletableFuture registryLookup) { - super(output, registryLookup, LootContextTypes.ENTITY); + public PromenadeEntityLootTableProvider(FabricPackOutput output, CompletableFuture registryLookup) { + super(output, registryLookup, LootContextParamSets.ENTITY); this.registries = registryLookup.join(); } @Override - public void accept(BiConsumer, LootTable.Builder> output) { - final var entities = this.registries.getOrThrow(RegistryKeys.ENTITY_TYPE); - final var fluids = this.registries.getOrThrow(RegistryKeys.FLUID); + public void generate(BiConsumer, LootTable.Builder> output) { + final var entities = this.registries.lookupOrThrow(Registries.ENTITY_TYPE); + final var fluids = this.registries.lookupOrThrow(Registries.FLUID); - output.accept(PromenadeEntityTypes.CAPYBARA.getLootTableKey().orElseThrow(), LootTable.builder()); + output.accept(PromenadeEntityTypes.CAPYBARA.getDefaultLootTable().orElseThrow(), LootTable.lootTable()); output.accept( - PromenadeEntityTypes.DUCK.getLootTableKey().orElseThrow(), - LootTable.builder() - .pool(LootPool.builder() - .with(ItemEntry.builder(Items.FEATHER) - .apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(0.0F, 2.0F))) - .apply(EnchantedCountIncreaseLootFunction.builder(registries, UniformLootNumberProvider.create(0.0F, 1.0F))) + PromenadeEntityTypes.DUCK.getDefaultLootTable().orElseThrow(), + LootTable.lootTable() + .withPool(LootPool.lootPool() + .add(LootItem.lootTableItem(Items.FEATHER) + .apply(SetItemCountFunction.setCount(UniformGenerator.between(0.0F, 2.0F))) + .apply(EnchantedCountIncreaseFunction.lootingMultiplier(registries, UniformGenerator.between(0.0F, 1.0F))) ) ) - .pool(LootPool.builder() - .with(ItemEntry.builder(PromenadeItems.DUCK) - .apply(FurnaceSmeltLootFunction.builder().conditionally(this.createSmeltLootCondition())) - .apply(EnchantedCountIncreaseLootFunction.builder(registries, UniformLootNumberProvider.create(0.0F, 1.0F))) + .withPool(LootPool.lootPool() + .add(LootItem.lootTableItem(PromenadeItems.DUCK) + .apply(SmeltItemFunction.smelted().when(this.createSmeltLootCondition())) + .apply(EnchantedCountIncreaseFunction.lootingMultiplier(registries, UniformGenerator.between(0.0F, 1.0F))) ) ) ); output.accept( - PromenadeEntityTypes.LUSH_CREEPER.getLootTableKey().orElseThrow(), - LootTable.builder() - .pool(LootPool.builder() - .with(ItemEntry.builder(Items.GUNPOWDER) - .apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(0.0F, 2.0F))) - .apply(EnchantedCountIncreaseLootFunction.builder(this.registries, UniformLootNumberProvider.create(0.0F, 1.0F))) + PromenadeEntityTypes.LUSH_CREEPER.getDefaultLootTable().orElseThrow(), + LootTable.lootTable() + .withPool(LootPool.lootPool() + .add(LootItem.lootTableItem(Items.GUNPOWDER) + .apply(SetItemCountFunction.setCount(UniformGenerator.between(0.0F, 2.0F))) + .apply(EnchantedCountIncreaseFunction.lootingMultiplier(this.registries, UniformGenerator.between(0.0F, 1.0F))) ) ) - .pool(LootPool.builder() - .with(ItemEntry.builder(Items.BONE_MEAL).weight(2).quality(2) - .apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(0.0F, 2.0F))) - .apply(EnchantedCountIncreaseLootFunction.builder(this.registries, UniformLootNumberProvider.create(0.0F, 1.0F))) + .withPool(LootPool.lootPool() + .add(LootItem.lootTableItem(Items.BONE_MEAL).setWeight(2).setQuality(2) + .apply(SetItemCountFunction.setCount(UniformGenerator.between(0.0F, 2.0F))) + .apply(EnchantedCountIncreaseFunction.lootingMultiplier(this.registries, UniformGenerator.between(0.0F, 1.0F))) ) - .with(ItemEntry.builder(Items.MOSS_BLOCK).weight(1).quality(5) - .apply(EnchantedCountIncreaseLootFunction.builder(this.registries, UniformLootNumberProvider.create(0.0F, 1.0F))) + .add(LootItem.lootTableItem(Items.MOSS_BLOCK).setWeight(1).setQuality(5) + .apply(EnchantedCountIncreaseFunction.lootingMultiplier(this.registries, UniformGenerator.between(0.0F, 1.0F))) ) ) - .pool(LootPool.builder() - .with(TagEntry.expandBuilder(ItemTags.CREEPER_DROP_MUSIC_DISCS)) - .conditionally( - EntityPropertiesLootCondition.builder( - LootContext.EntityReference.ATTACKER, EntityPredicate.Builder.create().type(entities, EntityTypeTags.SKELETONS) + .withPool(LootPool.lootPool() + .add(TagEntry.expandTag(ItemTags.CREEPER_DROP_MUSIC_DISCS)) + .when( + LootItemEntityPropertyCondition.hasProperties( + LootContext.EntityTarget.ATTACKER, EntityPredicate.Builder.entity().of(entities, EntityTypeTags.SKELETONS) ) ) ) @@ -112,24 +104,24 @@ public void accept(BiConsumer, LootTable.Builder> output) output.accept(PromenadeLootTables.HORN_SUNKEN, sunken(fluids, Items.HORN_CORAL, Items.DEAD_HORN_CORAL)); } - protected final AnyOfLootCondition.Builder createSmeltLootCondition() { - RegistryWrapper.Impl impl = this.registries.getOrThrow(RegistryKeys.ENCHANTMENT); - return AnyOfLootCondition.builder( - EntityPropertiesLootCondition.builder( - LootContext.EntityReference.THIS, EntityPredicate.Builder.create().flags(EntityFlagsPredicate.Builder.create().onFire(true)) + protected final AnyOfCondition.Builder createSmeltLootCondition() { + HolderLookup.RegistryLookup impl = this.registries.lookupOrThrow(Registries.ENCHANTMENT); + return AnyOfCondition.anyOf( + LootItemEntityPropertyCondition.hasProperties( + LootContext.EntityTarget.THIS, EntityPredicate.Builder.entity().flags(EntityFlagsPredicate.Builder.flags().setOnFire(true)) ), - EntityPropertiesLootCondition.builder( - LootContext.EntityReference.DIRECT_ATTACKER, - EntityPredicate.Builder.create() + LootItemEntityPropertyCondition.hasProperties( + LootContext.EntityTarget.DIRECT_ATTACKER, + EntityPredicate.Builder.entity() .equipment( - EntityEquipmentPredicate.Builder.create() + EntityEquipmentPredicate.Builder.equipment() .mainhand( - ItemPredicate.Builder.create() - .components( - ComponentsPredicate.Builder.create() + ItemPredicate.Builder.item() + .withComponents( + DataComponentMatchers.Builder.components() .partial( - ComponentPredicateTypes.ENCHANTMENTS, - EnchantmentsPredicate.enchantments(List.of(new EnchantmentPredicate(impl.getOrThrow(EnchantmentTags.SMELTS_LOOT), NumberRange.IntRange.ANY))) + DataComponentPredicates.ENCHANTMENTS, + EnchantmentsPredicate.enchantments(List.of(new EnchantmentPredicate(impl.getOrThrow(EnchantmentTags.SMELTS_LOOT), MinMaxBounds.Ints.ANY))) ) .build() ) @@ -139,28 +131,28 @@ protected final AnyOfLootCondition.Builder createSmeltLootCondition() { ); } - protected final LootTable.Builder sunken(RegistryEntryLookup fluids, Item coral, Item deadCoral) { - return LootTable.builder() - .pool(LootPool.builder() - .with(ItemEntry.builder(Items.ARROW) - .apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(0.0F, 2.0F))) - .apply(EnchantedCountIncreaseLootFunction.builder(this.registries, UniformLootNumberProvider.create(0.0F, 1.0F))) + protected final LootTable.Builder sunken(HolderGetter fluids, Item coral, Item deadCoral) { + return LootTable.lootTable() + .withPool(LootPool.lootPool() + .add(LootItem.lootTableItem(Items.ARROW) + .apply(SetItemCountFunction.setCount(UniformGenerator.between(0.0F, 2.0F))) + .apply(EnchantedCountIncreaseFunction.lootingMultiplier(this.registries, UniformGenerator.between(0.0F, 1.0F))) ) ) - .pool(LootPool.builder() - .with(ItemEntry.builder(Items.BONE) - .apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(0.0F, 2.0F))) - .apply(EnchantedCountIncreaseLootFunction.builder(this.registries, UniformLootNumberProvider.create(0.0F, 1.0F))) + .withPool(LootPool.lootPool() + .add(LootItem.lootTableItem(Items.BONE) + .apply(SetItemCountFunction.setCount(UniformGenerator.between(0.0F, 2.0F))) + .apply(EnchantedCountIncreaseFunction.lootingMultiplier(this.registries, UniformGenerator.between(0.0F, 1.0F))) ) ) - .pool(LootPool.builder() - .with( - ItemEntry.builder(coral) - .conditionally(LocationCheckLootCondition.builder(LocationPredicate.Builder.create().fluid(FluidPredicate.Builder.create().tag(fluids.getOrThrow(FluidTags.WATER))))) - .alternatively(ItemEntry.builder(deadCoral)) + .withPool(LootPool.lootPool() + .add( + LootItem.lootTableItem(coral) + .when(LocationCheck.checkLocation(LocationPredicate.Builder.location().setFluid(FluidPredicate.Builder.fluid().of(fluids.getOrThrow(FluidTags.WATER))))) + .otherwise(LootItem.lootTableItem(deadCoral)) ) - .apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(1.0F, 3.0F))) - .apply(EnchantedCountIncreaseLootFunction.builder(this.registries, UniformLootNumberProvider.create(0.0F, 1.0F))) + .apply(SetItemCountFunction.setCount(UniformGenerator.between(1.0F, 3.0F))) + .apply(EnchantedCountIncreaseFunction.lootingMultiplier(this.registries, UniformGenerator.between(0.0F, 1.0F))) ); } } \ No newline at end of file diff --git a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeEntityTypeTagProvider.java b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeEntityTypeTagProvider.java index 3ffd6289..c732eac2 100644 --- a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeEntityTypeTagProvider.java +++ b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeEntityTypeTagProvider.java @@ -1,43 +1,43 @@ package fr.hugman.promenade.data.provider; -import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; -import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider; -import net.minecraft.registry.RegistryWrapper; -import net.minecraft.registry.tag.EntityTypeTags; +import net.fabricmc.fabric.api.datagen.v1.FabricPackOutput; +import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagsProvider; +import net.minecraft.core.HolderLookup; +import net.minecraft.tags.EntityTypeTags; import java.util.concurrent.CompletableFuture; import static fr.hugman.promenade.entity.PromenadeEntityTypes.*; import static fr.hugman.promenade.tag.PromenadeEntityTypeTags.*; -public class PromenadeEntityTypeTagProvider extends FabricTagProvider.EntityTypeTagProvider { - public PromenadeEntityTypeTagProvider(FabricDataOutput output, CompletableFuture completableFuture) { - super(output, completableFuture); - } - - @Override - protected void configure(RegistryWrapper.WrapperLookup wrapperLookup) { - // Vanilla - valueLookupBuilder(EntityTypeTags.SKELETONS).add(SUNKEN); - valueLookupBuilder(EntityTypeTags.BOAT).add(SAKURA_BOAT, MAPLE_BOAT, PALM_BOAT); - valueLookupBuilder(EntityTypeTags.AQUATIC).add(SUNKEN, CAPYBARA); - - valueLookupBuilder(EntityTypeTags.BURN_IN_DAYLIGHT).add(SUNKEN); - - valueLookupBuilder(EntityTypeTags.AXOLOTL_ALWAYS_HOSTILES).add(SUNKEN); - valueLookupBuilder(EntityTypeTags.FREEZE_IMMUNE_ENTITY_TYPES).add(DUCK); - valueLookupBuilder(EntityTypeTags.FALL_DAMAGE_IMMUNE).add(DUCK); - valueLookupBuilder(EntityTypeTags.POWDER_SNOW_WALKABLE_MOBS).add(DUCK); - valueLookupBuilder(EntityTypeTags.NOT_SCARY_FOR_PUFFERFISH).add(CAPYBARA); - valueLookupBuilder(EntityTypeTags.CANDIDATE_FOR_IRON_GOLEM_GIFT).add(CAPYBARA); - valueLookupBuilder(EntityTypeTags.FOLLOWABLE_FRIENDLY_MOBS).add(DUCK, CAPYBARA); - - // Conventional - valueLookupBuilder(ANIMALS).add(DUCK, CAPYBARA); - valueLookupBuilder(MONSTERS).add(LUSH_CREEPER); - - valueLookupBuilder(BIRDS).add(DUCK); - valueLookupBuilder(RODENTS).add(CAPYBARA); - valueLookupBuilder(CREEPERS).add(LUSH_CREEPER); - } +public class PromenadeEntityTypeTagProvider extends FabricTagsProvider.EntityTypeTagsProvider { + public PromenadeEntityTypeTagProvider(FabricPackOutput output, CompletableFuture completableFuture) { + super(output, completableFuture); + } + + @Override + protected void addTags(HolderLookup.Provider wrapperLookup) { + // Vanilla + valueLookupBuilder(EntityTypeTags.SKELETONS).add(SUNKEN); + valueLookupBuilder(EntityTypeTags.BOAT).add(SAKURA_BOAT, MAPLE_BOAT, PALM_BOAT); + valueLookupBuilder(EntityTypeTags.AQUATIC).add(SUNKEN, CAPYBARA); + + valueLookupBuilder(EntityTypeTags.BURN_IN_DAYLIGHT).add(SUNKEN); + + valueLookupBuilder(EntityTypeTags.AXOLOTL_ALWAYS_HOSTILES).add(SUNKEN); + valueLookupBuilder(EntityTypeTags.FREEZE_IMMUNE_ENTITY_TYPES).add(DUCK); + valueLookupBuilder(EntityTypeTags.FALL_DAMAGE_IMMUNE).add(DUCK); + valueLookupBuilder(EntityTypeTags.POWDER_SNOW_WALKABLE_MOBS).add(DUCK); + valueLookupBuilder(EntityTypeTags.NOT_SCARY_FOR_PUFFERFISH).add(CAPYBARA); + valueLookupBuilder(EntityTypeTags.CANDIDATE_FOR_IRON_GOLEM_GIFT).add(CAPYBARA); + valueLookupBuilder(EntityTypeTags.FOLLOWABLE_FRIENDLY_MOBS).add(DUCK, CAPYBARA); + + // Conventional + valueLookupBuilder(ANIMALS).add(DUCK, CAPYBARA); + valueLookupBuilder(MONSTERS).add(LUSH_CREEPER); + + valueLookupBuilder(BIRDS).add(DUCK); + valueLookupBuilder(RODENTS).add(CAPYBARA); + valueLookupBuilder(CREEPERS).add(LUSH_CREEPER); + } } \ No newline at end of file diff --git a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeItemTagProvider.java b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeItemTagProvider.java index 564f7782..de05a131 100644 --- a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeItemTagProvider.java +++ b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeItemTagProvider.java @@ -2,14 +2,14 @@ import fr.hugman.promenade.block.PromenadeBlocks; import fr.hugman.promenade.tag.PromenadeBlockTags; -import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; -import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider; +import net.fabricmc.fabric.api.datagen.v1.FabricPackOutput; +import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagsProvider; import net.fabricmc.fabric.api.tag.convention.v2.ConventionalBlockTags; import net.fabricmc.fabric.api.tag.convention.v2.ConventionalItemTags; -import net.minecraft.item.Items; -import net.minecraft.registry.RegistryWrapper; -import net.minecraft.registry.tag.BlockTags; -import net.minecraft.registry.tag.ItemTags; +import net.minecraft.core.HolderLookup; +import net.minecraft.tags.BlockTags; +import net.minecraft.tags.ItemTags; +import net.minecraft.world.item.Items; import org.jetbrains.annotations.Nullable; import java.util.concurrent.CompletableFuture; @@ -17,13 +17,13 @@ import static fr.hugman.promenade.item.PromenadeItems.*; import static fr.hugman.promenade.tag.PromenadeItemTags.*; -public class PromenadeItemTagProvider extends FabricTagProvider.ItemTagProvider { - public PromenadeItemTagProvider(FabricDataOutput output, CompletableFuture completableFuture, @Nullable BlockTagProvider blockTagProvider) { +public class PromenadeItemTagProvider extends FabricTagsProvider.ItemTagsProvider { + public PromenadeItemTagProvider(FabricPackOutput output, CompletableFuture completableFuture, @Nullable BlockTagsProvider blockTagProvider) { super(output, completableFuture, blockTagProvider); } @Override - protected void configure(RegistryWrapper.WrapperLookup wrapperLookup) { + protected void addTags(HolderLookup.Provider wrapperLookup) { // Promenade copy(PromenadeBlockTags.SAKURA_LOGS, SAKURA_LOGS); copy(PromenadeBlockTags.MAPLE_LOGS, MAPLE_LOGS); @@ -91,36 +91,36 @@ protected void configure(RegistryWrapper.WrapperLookup wrapperLookup) { // Conventional valueLookupBuilder(ConventionalItemTags.RAW_MEAT_FOODS).add(DUCK); valueLookupBuilder(ConventionalItemTags.COOKED_MEAT_FOODS).add(COOKED_DUCK); - valueLookupBuilder(APRICOTS_FOODS).add(APRICOT); - valueLookupBuilder(BANANA_FOODS).add(BANANA); - valueLookupBuilder(MANGOES_FOODS).add(MANGO); - valueLookupBuilder(BLUEBERRIES_FOODS).add(BLUEBERRIES); - - valueLookupBuilder(ConventionalItemTags.FOODS) - .add(DUCK) - .add(COOKED_DUCK); - - valueLookupBuilder(ConventionalItemTags.FRUIT_FOODS) - .addTag(APRICOTS_FOODS) - .addTag(BANANA_FOODS) - .addTag(MANGOES_FOODS); - - valueLookupBuilder(ConventionalItemTags.BERRY_FOODS) - .addTag(BLUEBERRIES_FOODS); - - valueLookupBuilder(MAPLE_SYRUP_DRINKS) - .add(MAPLE_SYRUP_BOTTLE); - - valueLookupBuilder(ConventionalItemTags.DRINK_CONTAINING_BOTTLE) - .add(MAPLE_SYRUP_BOTTLE); - - copy(ConventionalBlockTags.STONES, ConventionalItemTags.STONES); - copy(ConventionalBlockTags.FENCES, ConventionalItemTags.FENCES); - copy(ConventionalBlockTags.WOODEN_FENCES, ConventionalItemTags.WOODEN_FENCES); - copy(ConventionalBlockTags.FENCE_GATES, ConventionalItemTags.FENCE_GATES); - copy(ConventionalBlockTags.WOODEN_FENCE_GATES, ConventionalItemTags.WOODEN_FENCE_GATES); - copy(ConventionalBlockTags.STRIPPED_WOODS, ConventionalItemTags.STRIPPED_WOODS); - copy(ConventionalBlockTags.STRIPPED_LOGS, ConventionalItemTags.STRIPPED_LOGS); - copy(PromenadeBlockTags.IGNEOUS_ROCKS, IGNEOUS_ROCKS); - } + valueLookupBuilder(APRICOTS_FOODS).add(APRICOT); + valueLookupBuilder(BANANA_FOODS).add(BANANA); + valueLookupBuilder(MANGOES_FOODS).add(MANGO); + valueLookupBuilder(BLUEBERRIES_FOODS).add(BLUEBERRIES); + + valueLookupBuilder(ConventionalItemTags.FOODS) + .add(DUCK) + .add(COOKED_DUCK); + + valueLookupBuilder(ConventionalItemTags.FRUIT_FOODS) + .addTag(APRICOTS_FOODS) + .addTag(BANANA_FOODS) + .addTag(MANGOES_FOODS); + + valueLookupBuilder(ConventionalItemTags.BERRY_FOODS) + .addTag(BLUEBERRIES_FOODS); + + valueLookupBuilder(MAPLE_SYRUP_DRINKS) + .add(MAPLE_SYRUP_BOTTLE); + + valueLookupBuilder(ConventionalItemTags.DRINK_CONTAINING_BOTTLE) + .add(MAPLE_SYRUP_BOTTLE); + + copy(ConventionalBlockTags.STONES, ConventionalItemTags.STONES); + copy(ConventionalBlockTags.FENCES, ConventionalItemTags.FENCES); + copy(ConventionalBlockTags.WOODEN_FENCES, ConventionalItemTags.WOODEN_FENCES); + copy(ConventionalBlockTags.FENCE_GATES, ConventionalItemTags.FENCE_GATES); + copy(ConventionalBlockTags.WOODEN_FENCE_GATES, ConventionalItemTags.WOODEN_FENCE_GATES); + copy(ConventionalBlockTags.STRIPPED_WOODS, ConventionalItemTags.STRIPPED_WOODS); + copy(ConventionalBlockTags.STRIPPED_LOGS, ConventionalItemTags.STRIPPED_LOGS); + copy(PromenadeBlockTags.IGNEOUS_ROCKS, IGNEOUS_ROCKS); + } } \ No newline at end of file diff --git a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeModelProvider.java b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeModelProvider.java index 907f8a1d..1fea59a5 100644 --- a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeModelProvider.java +++ b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeModelProvider.java @@ -1,5 +1,6 @@ package fr.hugman.promenade.data.provider; +import com.mojang.math.Quadrant; import fr.hugman.promenade.block.MoaiBlock; import fr.hugman.promenade.block.MoaiType; import fr.hugman.promenade.block.PromenadeBlocks; @@ -12,281 +13,285 @@ import fr.hugman.promenade.item.PromenadeItems; import fr.hugman.promenade.world.biome.PromenadeFoliageColors; import net.fabricmc.fabric.api.client.datagen.v1.provider.FabricModelProvider; -import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; -import net.minecraft.block.Block; -import net.minecraft.block.Blocks; -import net.minecraft.client.data.*; -import net.minecraft.client.render.item.tint.TintSource; -import net.minecraft.client.render.model.json.ModelVariantOperator; -import net.minecraft.client.render.model.json.MultipartModelConditionBuilder; -import net.minecraft.client.render.model.json.WeightedVariant; -import net.minecraft.data.family.BlockFamily; -import net.minecraft.registry.Registries; -import net.minecraft.state.property.Properties; -import net.minecraft.util.Identifier; -import net.minecraft.util.math.AxisRotation; -import net.minecraft.util.math.Direction; -import net.minecraft.world.biome.FoliageColors; +import net.fabricmc.fabric.api.datagen.v1.FabricPackOutput; +import net.minecraft.client.color.item.ItemTintSource; +import net.minecraft.client.data.models.BlockModelGenerators; +import net.minecraft.client.data.models.ItemModelGenerators; +import net.minecraft.client.data.models.MultiVariant; +import net.minecraft.client.data.models.blockstates.ConditionBuilder; +import net.minecraft.client.data.models.blockstates.MultiVariantGenerator; +import net.minecraft.client.data.models.blockstates.PropertyDispatch; +import net.minecraft.client.data.models.model.*; +import net.minecraft.client.renderer.block.dispatch.VariantMutator; +import net.minecraft.client.resources.model.sprite.Material; +import net.minecraft.core.Direction; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.data.BlockFamily; +import net.minecraft.resources.Identifier; +import net.minecraft.world.level.FoliageColor; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; import java.util.function.Function; public class PromenadeModelProvider extends FabricModelProvider { - public static final ModelVariantOperator NO_OP = variant -> variant; - public static final ModelVariantOperator UV_LOCK = ModelVariantOperator.UV_LOCK.withValue(true); - public static final ModelVariantOperator ROTATE_X_90 = ModelVariantOperator.ROTATION_X.withValue(AxisRotation.R90); - public static final ModelVariantOperator ROTATE_X_180 = ModelVariantOperator.ROTATION_X.withValue(AxisRotation.R180); - public static final ModelVariantOperator ROTATE_X_270 = ModelVariantOperator.ROTATION_X.withValue(AxisRotation.R270); - public static final ModelVariantOperator ROTATE_Y_90 = ModelVariantOperator.ROTATION_Y.withValue(AxisRotation.R90); - public static final ModelVariantOperator ROTATE_Y_180 = ModelVariantOperator.ROTATION_Y.withValue(AxisRotation.R180); - public static final ModelVariantOperator ROTATE_Y_270 = ModelVariantOperator.ROTATION_Y.withValue(AxisRotation.R270); - - private static final Function LEAF_LITTER_MODEL_1_CONDITION_FUNCTION = builder -> builder.put(Properties.SEGMENT_AMOUNT, 1); - private static final Function LEAF_LITTER_MODEL_2_CONDITION_FUNCTION = builder -> builder.put(Properties.SEGMENT_AMOUNT, 2, 3); - private static final Function LEAF_LITTER_MODEL_3_CONDITION_FUNCTION = builder -> builder.put(Properties.SEGMENT_AMOUNT, 3); - private static final Function LEAF_LITTER_MODEL_4_CONDITION_FUNCTION = builder -> builder.put(Properties.SEGMENT_AMOUNT, 4); - - private static final BlockStateVariantMap NORTH_DEFAULT_HORIZONTAL_ROTATION_OPERATIONS = BlockStateVariantMap.operations( - Properties.HORIZONTAL_FACING + public static final VariantMutator NO_OP = variant -> variant; + public static final VariantMutator UV_LOCK = VariantMutator.UV_LOCK.withValue(true); + public static final VariantMutator ROTATE_X_90 = VariantMutator.X_ROT.withValue(Quadrant.R90); + public static final VariantMutator ROTATE_X_180 = VariantMutator.X_ROT.withValue(Quadrant.R180); + public static final VariantMutator ROTATE_X_270 = VariantMutator.X_ROT.withValue(Quadrant.R270); + public static final VariantMutator ROTATE_Y_90 = VariantMutator.Y_ROT.withValue(Quadrant.R90); + public static final VariantMutator ROTATE_Y_180 = VariantMutator.Y_ROT.withValue(Quadrant.R180); + public static final VariantMutator ROTATE_Y_270 = VariantMutator.Y_ROT.withValue(Quadrant.R270); + + private static final Function LEAF_LITTER_MODEL_1_CONDITION_FUNCTION = builder -> builder.term(BlockStateProperties.SEGMENT_AMOUNT, 1); + private static final Function LEAF_LITTER_MODEL_2_CONDITION_FUNCTION = builder -> builder.term(BlockStateProperties.SEGMENT_AMOUNT, 2, 3); + private static final Function LEAF_LITTER_MODEL_3_CONDITION_FUNCTION = builder -> builder.term(BlockStateProperties.SEGMENT_AMOUNT, 3); + private static final Function LEAF_LITTER_MODEL_4_CONDITION_FUNCTION = builder -> builder.term(BlockStateProperties.SEGMENT_AMOUNT, 4); + + private static final PropertyDispatch NORTH_DEFAULT_HORIZONTAL_ROTATION_OPERATIONS = PropertyDispatch.modify( + BlockStateProperties.HORIZONTAL_FACING ) - .register(Direction.EAST, ROTATE_Y_90) - .register(Direction.SOUTH, ROTATE_Y_180) - .register(Direction.WEST, ROTATE_Y_270) - .register(Direction.NORTH, NO_OP); - private static final BlockStateVariantMap UP_DEFAULT_ROTATION_OPERATIONS = BlockStateVariantMap.operations(Properties.FACING) - .register(Direction.DOWN, ROTATE_X_180) - .register(Direction.UP, NO_OP) - .register(Direction.NORTH, ROTATE_X_90) - .register(Direction.SOUTH, ROTATE_X_90.then(ROTATE_Y_180)) - .register(Direction.WEST, ROTATE_X_90.then(ROTATE_Y_270)) - .register(Direction.EAST, ROTATE_X_90.then(ROTATE_Y_90)); - - public PromenadeModelProvider(FabricDataOutput output) { + .select(Direction.EAST, ROTATE_Y_90) + .select(Direction.SOUTH, ROTATE_Y_180) + .select(Direction.WEST, ROTATE_Y_270) + .select(Direction.NORTH, NO_OP); + private static final PropertyDispatch UP_DEFAULT_ROTATION_OPERATIONS = PropertyDispatch.modify(BlockStateProperties.FACING) + .select(Direction.DOWN, ROTATE_X_180) + .select(Direction.UP, NO_OP) + .select(Direction.NORTH, ROTATE_X_90) + .select(Direction.SOUTH, ROTATE_X_90.then(ROTATE_Y_180)) + .select(Direction.WEST, ROTATE_X_90.then(ROTATE_Y_270)) + .select(Direction.EAST, ROTATE_X_90.then(ROTATE_Y_90)); + + public PromenadeModelProvider(FabricPackOutput output) { super(output); } @Override - public void generateBlockStateModels(BlockStateModelGenerator gen) { - PromenadeBlockFamilies.getFamilies().filter(BlockFamily::shouldGenerateModels).forEach(family -> gen.registerCubeAllModelTexturePool(family.getBaseBlock()).family(family)); - - gen.registerTintedBlockAndItem(PromenadeBlocks.OAK_LEAF_PILE, PromenadeTexturedModels.pile(Blocks.OAK_LEAVES), FoliageColors.DEFAULT); - gen.registerTintedBlockAndItem(PromenadeBlocks.SPRUCE_LEAF_PILE, PromenadeTexturedModels.pile(Blocks.SPRUCE_LEAVES), FoliageColors.SPRUCE); - gen.registerTintedBlockAndItem(PromenadeBlocks.BIRCH_LEAF_PILE, PromenadeTexturedModels.pile(Blocks.BIRCH_LEAVES), FoliageColors.BIRCH); - gen.registerTintedBlockAndItem(PromenadeBlocks.JUNGLE_LEAF_PILE, PromenadeTexturedModels.pile(Blocks.JUNGLE_LEAVES), FoliageColors.DEFAULT); - gen.registerTintedBlockAndItem(PromenadeBlocks.ACACIA_LEAF_PILE, PromenadeTexturedModels.pile(Blocks.ACACIA_LEAVES), FoliageColors.DEFAULT); - gen.registerSingleton(PromenadeBlocks.CHERRY_LEAF_PILE, PromenadeTexturedModels.pile(Blocks.CHERRY_LEAVES)); - gen.registerTintedBlockAndItem(PromenadeBlocks.DARK_OAK_LEAF_PILE, PromenadeTexturedModels.pile(Blocks.DARK_OAK_LEAVES), FoliageColors.DEFAULT); - gen.registerSingleton(PromenadeBlocks.PALE_OAK_LEAF_PILE, PromenadeTexturedModels.pile(Blocks.PALE_OAK_LEAVES)); - gen.registerTintedBlockAndItem(PromenadeBlocks.MANGROVE_LEAF_PILE, PromenadeTexturedModels.pile(Blocks.MANGROVE_LEAVES), FoliageColors.MANGROVE); - gen.registerSingleton(PromenadeBlocks.AZALEA_LEAF_PILE, PromenadeTexturedModels.pile(Blocks.AZALEA_LEAVES)); - gen.registerSingleton(PromenadeBlocks.FLOWERING_AZALEA_LEAF_PILE, PromenadeTexturedModels.pile(Blocks.FLOWERING_AZALEA_LEAVES)); - - gen.registerSingleton(PromenadeBlocks.DANDELION_PILE, PromenadeTexturedModels.PILE); - gen.registerSingleton(PromenadeBlocks.POPPY_PILE, PromenadeTexturedModels.PILE); - gen.registerSingleton(PromenadeBlocks.BLUE_ORCHID_PILE, PromenadeTexturedModels.PILE); - gen.registerSingleton(PromenadeBlocks.ALLIUM_PILE, PromenadeTexturedModels.PILE); - gen.registerSingleton(PromenadeBlocks.AZURE_BLUET_PILE, PromenadeTexturedModels.PILE); - gen.registerSingleton(PromenadeBlocks.RED_TULIP_PILE, PromenadeTexturedModels.PILE); - gen.registerSingleton(PromenadeBlocks.ORANGE_TULIP_PILE, PromenadeTexturedModels.PILE); - gen.registerSingleton(PromenadeBlocks.WHITE_TULIP_PILE, PromenadeTexturedModels.PILE); - gen.registerSingleton(PromenadeBlocks.PINK_TULIP_PILE, PromenadeTexturedModels.PILE); - gen.registerSingleton(PromenadeBlocks.OXEYE_DAISY_PILE, PromenadeTexturedModels.PILE); - gen.registerSingleton(PromenadeBlocks.CORNFLOWER_PILE, PromenadeTexturedModels.PILE); - gen.registerSingleton(PromenadeBlocks.LILY_OF_THE_VALLEY_PILE, PromenadeTexturedModels.PILE); - gen.registerSingleton(PromenadeBlocks.WITHER_ROSE_PILE, PromenadeTexturedModels.PILE); - - this.registerSnowyLeaves(gen, PromenadeBlocks.SNOWY_OAK_LEAVES, Blocks.OAK_LEAVES, FoliageColors.DEFAULT); - this.registerSnowyLeaves(gen, PromenadeBlocks.SNOWY_SPRUCE_LEAVES, Blocks.SPRUCE_LEAVES, FoliageColors.SPRUCE); - this.registerSnowyLeaves(gen, PromenadeBlocks.SNOWY_BIRCH_LEAVES, Blocks.BIRCH_LEAVES, FoliageColors.BIRCH); - this.registerSnowyLeaves(gen, PromenadeBlocks.SNOWY_JUNGLE_LEAVES, Blocks.JUNGLE_LEAVES, FoliageColors.DEFAULT); - this.registerSnowyLeaves(gen, PromenadeBlocks.SNOWY_ACACIA_LEAVES, Blocks.ACACIA_LEAVES, FoliageColors.DEFAULT); + public void generateBlockStateModels(BlockModelGenerators gen) { + PromenadeBlockFamilies.getFamilies().filter(BlockFamily::shouldGenerateModel).forEach(family -> gen.family(family.getBaseBlock()).generateFor(family)); + + gen.createTintedLeaves(PromenadeBlocks.OAK_LEAF_PILE, PromenadeTexturedModels.pile(Blocks.OAK_LEAVES), FoliageColor.FOLIAGE_DEFAULT); + gen.createTintedLeaves(PromenadeBlocks.SPRUCE_LEAF_PILE, PromenadeTexturedModels.pile(Blocks.SPRUCE_LEAVES), FoliageColor.FOLIAGE_EVERGREEN); + gen.createTintedLeaves(PromenadeBlocks.BIRCH_LEAF_PILE, PromenadeTexturedModels.pile(Blocks.BIRCH_LEAVES), FoliageColor.FOLIAGE_BIRCH); + gen.createTintedLeaves(PromenadeBlocks.JUNGLE_LEAF_PILE, PromenadeTexturedModels.pile(Blocks.JUNGLE_LEAVES), FoliageColor.FOLIAGE_DEFAULT); + gen.createTintedLeaves(PromenadeBlocks.ACACIA_LEAF_PILE, PromenadeTexturedModels.pile(Blocks.ACACIA_LEAVES), FoliageColor.FOLIAGE_DEFAULT); + gen.createTrivialBlock(PromenadeBlocks.CHERRY_LEAF_PILE, PromenadeTexturedModels.pile(Blocks.CHERRY_LEAVES)); + gen.createTintedLeaves(PromenadeBlocks.DARK_OAK_LEAF_PILE, PromenadeTexturedModels.pile(Blocks.DARK_OAK_LEAVES), FoliageColor.FOLIAGE_DEFAULT); + gen.createTrivialBlock(PromenadeBlocks.PALE_OAK_LEAF_PILE, PromenadeTexturedModels.pile(Blocks.PALE_OAK_LEAVES)); + gen.createTintedLeaves(PromenadeBlocks.MANGROVE_LEAF_PILE, PromenadeTexturedModels.pile(Blocks.MANGROVE_LEAVES), FoliageColor.FOLIAGE_MANGROVE); + gen.createTrivialBlock(PromenadeBlocks.AZALEA_LEAF_PILE, PromenadeTexturedModels.pile(Blocks.AZALEA_LEAVES)); + gen.createTrivialBlock(PromenadeBlocks.FLOWERING_AZALEA_LEAF_PILE, PromenadeTexturedModels.pile(Blocks.FLOWERING_AZALEA_LEAVES)); + + gen.createTrivialBlock(PromenadeBlocks.DANDELION_PILE, PromenadeTexturedModels.PILE); + gen.createTrivialBlock(PromenadeBlocks.POPPY_PILE, PromenadeTexturedModels.PILE); + gen.createTrivialBlock(PromenadeBlocks.BLUE_ORCHID_PILE, PromenadeTexturedModels.PILE); + gen.createTrivialBlock(PromenadeBlocks.ALLIUM_PILE, PromenadeTexturedModels.PILE); + gen.createTrivialBlock(PromenadeBlocks.AZURE_BLUET_PILE, PromenadeTexturedModels.PILE); + gen.createTrivialBlock(PromenadeBlocks.RED_TULIP_PILE, PromenadeTexturedModels.PILE); + gen.createTrivialBlock(PromenadeBlocks.ORANGE_TULIP_PILE, PromenadeTexturedModels.PILE); + gen.createTrivialBlock(PromenadeBlocks.WHITE_TULIP_PILE, PromenadeTexturedModels.PILE); + gen.createTrivialBlock(PromenadeBlocks.PINK_TULIP_PILE, PromenadeTexturedModels.PILE); + gen.createTrivialBlock(PromenadeBlocks.OXEYE_DAISY_PILE, PromenadeTexturedModels.PILE); + gen.createTrivialBlock(PromenadeBlocks.CORNFLOWER_PILE, PromenadeTexturedModels.PILE); + gen.createTrivialBlock(PromenadeBlocks.LILY_OF_THE_VALLEY_PILE, PromenadeTexturedModels.PILE); + gen.createTrivialBlock(PromenadeBlocks.WITHER_ROSE_PILE, PromenadeTexturedModels.PILE); + + this.registerSnowyLeaves(gen, PromenadeBlocks.SNOWY_OAK_LEAVES, Blocks.OAK_LEAVES, FoliageColor.FOLIAGE_DEFAULT); + this.registerSnowyLeaves(gen, PromenadeBlocks.SNOWY_SPRUCE_LEAVES, Blocks.SPRUCE_LEAVES, FoliageColor.FOLIAGE_EVERGREEN); + this.registerSnowyLeaves(gen, PromenadeBlocks.SNOWY_BIRCH_LEAVES, Blocks.BIRCH_LEAVES, FoliageColor.FOLIAGE_BIRCH); + this.registerSnowyLeaves(gen, PromenadeBlocks.SNOWY_JUNGLE_LEAVES, Blocks.JUNGLE_LEAVES, FoliageColor.FOLIAGE_DEFAULT); + this.registerSnowyLeaves(gen, PromenadeBlocks.SNOWY_ACACIA_LEAVES, Blocks.ACACIA_LEAVES, FoliageColor.FOLIAGE_DEFAULT); this.registerSnowyLeaves(gen, PromenadeBlocks.SNOWY_CHERRY_LEAVES, Blocks.CHERRY_LEAVES); - this.registerSnowyLeaves(gen, PromenadeBlocks.SNOWY_DARK_OAK_LEAVES, Blocks.DARK_OAK_LEAVES, FoliageColors.DEFAULT); + this.registerSnowyLeaves(gen, PromenadeBlocks.SNOWY_DARK_OAK_LEAVES, Blocks.DARK_OAK_LEAVES, FoliageColor.FOLIAGE_DEFAULT); this.registerSnowyLeaves(gen, PromenadeBlocks.SNOWY_PALE_OAK_LEAVES, Blocks.PALE_OAK_LEAVES); - this.registerSnowyLeaves(gen, PromenadeBlocks.SNOWY_MANGROVE_LEAVES, Blocks.MANGROVE_LEAVES, FoliageColors.MANGROVE); + this.registerSnowyLeaves(gen, PromenadeBlocks.SNOWY_MANGROVE_LEAVES, Blocks.MANGROVE_LEAVES, FoliageColor.FOLIAGE_MANGROVE); this.registerSnowyLeaves(gen, PromenadeBlocks.SNOWY_AZALEA_LEAVES, Blocks.AZALEA_LEAVES); this.registerSnowyLeaves(gen, PromenadeBlocks.SNOWY_FLOWERING_AZALEA_LEAVES, Blocks.FLOWERING_AZALEA_LEAVES); - gen.createLogTexturePool(PromenadeBlocks.SAKURA_LOG).uvLockedLog(PromenadeBlocks.SAKURA_LOG).wood(PromenadeBlocks.SAKURA_WOOD); - gen.createLogTexturePool(PromenadeBlocks.STRIPPED_SAKURA_LOG).uvLockedLog(PromenadeBlocks.STRIPPED_SAKURA_LOG).wood(PromenadeBlocks.STRIPPED_SAKURA_WOOD); - gen.registerHangingSign(PromenadeBlocks.STRIPPED_SAKURA_LOG, PromenadeBlocks.SAKURA_HANGING_SIGN, PromenadeBlocks.SAKURA_WALL_HANGING_SIGN); - gen.registerShelf(PromenadeBlocks.SAKURA_SHELF, PromenadeBlocks.STRIPPED_SAKURA_LOG); - gen.registerFlowerPotPlantAndItem(PromenadeBlocks.BLUSH_SAKURA_SAPLING, PromenadeBlocks.POTTED_BLUSH_SAKURA_SAPLING, BlockStateModelGenerator.CrossType.NOT_TINTED); - gen.registerFlowerPotPlantAndItem(PromenadeBlocks.COTTON_SAKURA_SAPLING, PromenadeBlocks.POTTED_COTTON_SAKURA_SAPLING, BlockStateModelGenerator.CrossType.NOT_TINTED); - gen.registerSingleton(PromenadeBlocks.BLUSH_SAKURA_BLOSSOMS, TexturedModel.LEAVES); + gen.woodProvider(PromenadeBlocks.SAKURA_LOG).logUVLocked(PromenadeBlocks.SAKURA_LOG).wood(PromenadeBlocks.SAKURA_WOOD); + gen.woodProvider(PromenadeBlocks.STRIPPED_SAKURA_LOG).logUVLocked(PromenadeBlocks.STRIPPED_SAKURA_LOG).wood(PromenadeBlocks.STRIPPED_SAKURA_WOOD); + gen.createHangingSign(PromenadeBlocks.STRIPPED_SAKURA_LOG, PromenadeBlocks.SAKURA_HANGING_SIGN, PromenadeBlocks.SAKURA_WALL_HANGING_SIGN); + gen.createShelf(PromenadeBlocks.SAKURA_SHELF, PromenadeBlocks.STRIPPED_SAKURA_LOG); + gen.createPlantWithDefaultItem(PromenadeBlocks.BLUSH_SAKURA_SAPLING, PromenadeBlocks.POTTED_BLUSH_SAKURA_SAPLING, BlockModelGenerators.PlantType.NOT_TINTED); + gen.createPlantWithDefaultItem(PromenadeBlocks.COTTON_SAKURA_SAPLING, PromenadeBlocks.POTTED_COTTON_SAKURA_SAPLING, BlockModelGenerators.PlantType.NOT_TINTED); + gen.createTrivialBlock(PromenadeBlocks.BLUSH_SAKURA_BLOSSOMS, TexturedModel.LEAVES); this.registerSnowyLeaves(gen, PromenadeBlocks.SNOWY_BLUSH_SAKURA_BLOSSOMS, PromenadeBlocks.BLUSH_SAKURA_BLOSSOMS, "snowy_sakura_blossoms"); - gen.registerSingleton(PromenadeBlocks.COTTON_SAKURA_BLOSSOMS, TexturedModel.LEAVES); + gen.createTrivialBlock(PromenadeBlocks.COTTON_SAKURA_BLOSSOMS, TexturedModel.LEAVES); this.registerSnowyLeaves(gen, PromenadeBlocks.SNOWY_COTTON_SAKURA_BLOSSOMS, PromenadeBlocks.COTTON_SAKURA_BLOSSOMS, "snowy_sakura_blossoms"); - gen.registerSingleton(PromenadeBlocks.BLUSH_SAKURA_BLOSSOM_PILE, PromenadeTexturedModels.pile(PromenadeBlocks.BLUSH_SAKURA_BLOSSOMS)); - gen.registerSingleton(PromenadeBlocks.COTTON_SAKURA_BLOSSOM_PILE, PromenadeTexturedModels.pile(PromenadeBlocks.COTTON_SAKURA_BLOSSOMS)); + gen.createTrivialBlock(PromenadeBlocks.BLUSH_SAKURA_BLOSSOM_PILE, PromenadeTexturedModels.pile(PromenadeBlocks.BLUSH_SAKURA_BLOSSOMS)); + gen.createTrivialBlock(PromenadeBlocks.COTTON_SAKURA_BLOSSOM_PILE, PromenadeTexturedModels.pile(PromenadeBlocks.COTTON_SAKURA_BLOSSOMS)); - gen.createLogTexturePool(PromenadeBlocks.MAPLE_LOG).log(PromenadeBlocks.MAPLE_LOG).wood(PromenadeBlocks.MAPLE_WOOD); + gen.woodProvider(PromenadeBlocks.MAPLE_LOG).log(PromenadeBlocks.MAPLE_LOG).wood(PromenadeBlocks.MAPLE_WOOD); registerDripLog(gen, PromenadeBlocks.STRIPPED_MAPLE_LOG); - gen.createLogTexturePool(PromenadeBlocks.STRIPPED_MAPLE_LOG).wood(PromenadeBlocks.STRIPPED_MAPLE_WOOD); - gen.registerHangingSign(PromenadeBlocks.STRIPPED_MAPLE_LOG, PromenadeBlocks.MAPLE_HANGING_SIGN, PromenadeBlocks.MAPLE_WALL_HANGING_SIGN); - gen.registerShelf(PromenadeBlocks.MAPLE_SHELF, PromenadeBlocks.STRIPPED_MAPLE_LOG); - gen.registerFlowerPotPlantAndItem(PromenadeBlocks.SAP_MAPLE_SAPLING, PromenadeBlocks.POTTED_SAP_MAPLE_SAPLING, BlockStateModelGenerator.CrossType.NOT_TINTED); - gen.registerFlowerPotPlantAndItem(PromenadeBlocks.VERMILION_MAPLE_SAPLING, PromenadeBlocks.POTTED_VERMILION_MAPLE_SAPLING, BlockStateModelGenerator.CrossType.NOT_TINTED); - gen.registerFlowerPotPlantAndItem(PromenadeBlocks.FULVOUS_MAPLE_SAPLING, PromenadeBlocks.POTTED_FULVOUS_MAPLE_SAPLING, BlockStateModelGenerator.CrossType.NOT_TINTED); - gen.registerFlowerPotPlantAndItem(PromenadeBlocks.MIKADO_MAPLE_SAPLING, PromenadeBlocks.POTTED_MIKADO_MAPLE_SAPLING, BlockStateModelGenerator.CrossType.NOT_TINTED); - gen.registerTintedBlockAndItem(PromenadeBlocks.SAP_MAPLE_LEAVES, TexturedModel.LEAVES, PromenadeFoliageColors.SAP_MAPLE); + gen.woodProvider(PromenadeBlocks.STRIPPED_MAPLE_LOG).wood(PromenadeBlocks.STRIPPED_MAPLE_WOOD); + gen.createHangingSign(PromenadeBlocks.STRIPPED_MAPLE_LOG, PromenadeBlocks.MAPLE_HANGING_SIGN, PromenadeBlocks.MAPLE_WALL_HANGING_SIGN); + gen.createShelf(PromenadeBlocks.MAPLE_SHELF, PromenadeBlocks.STRIPPED_MAPLE_LOG); + gen.createPlantWithDefaultItem(PromenadeBlocks.SAP_MAPLE_SAPLING, PromenadeBlocks.POTTED_SAP_MAPLE_SAPLING, BlockModelGenerators.PlantType.NOT_TINTED); + gen.createPlantWithDefaultItem(PromenadeBlocks.VERMILION_MAPLE_SAPLING, PromenadeBlocks.POTTED_VERMILION_MAPLE_SAPLING, BlockModelGenerators.PlantType.NOT_TINTED); + gen.createPlantWithDefaultItem(PromenadeBlocks.FULVOUS_MAPLE_SAPLING, PromenadeBlocks.POTTED_FULVOUS_MAPLE_SAPLING, BlockModelGenerators.PlantType.NOT_TINTED); + gen.createPlantWithDefaultItem(PromenadeBlocks.MIKADO_MAPLE_SAPLING, PromenadeBlocks.POTTED_MIKADO_MAPLE_SAPLING, BlockModelGenerators.PlantType.NOT_TINTED); + gen.createTintedLeaves(PromenadeBlocks.SAP_MAPLE_LEAVES, TexturedModel.LEAVES, PromenadeFoliageColors.SAP_MAPLE); this.registerSnowyLeaves(gen, PromenadeBlocks.SNOWY_SAP_MAPLE_LEAVES, PromenadeBlocks.SAP_MAPLE_LEAVES, "snowy_maple_leaves", PromenadeFoliageColors.SAP_MAPLE); - gen.registerSingleton(PromenadeBlocks.VERMILION_MAPLE_LEAVES, TexturedModel.LEAVES); + gen.createTrivialBlock(PromenadeBlocks.VERMILION_MAPLE_LEAVES, TexturedModel.LEAVES); this.registerSnowyLeaves(gen, PromenadeBlocks.SNOWY_VERMILION_MAPLE_LEAVES, PromenadeBlocks.VERMILION_MAPLE_LEAVES, "snowy_maple_leaves"); - gen.registerSingleton(PromenadeBlocks.FULVOUS_MAPLE_LEAVES, TexturedModel.LEAVES); + gen.createTrivialBlock(PromenadeBlocks.FULVOUS_MAPLE_LEAVES, TexturedModel.LEAVES); this.registerSnowyLeaves(gen, PromenadeBlocks.SNOWY_FULVOUS_MAPLE_LEAVES, PromenadeBlocks.FULVOUS_MAPLE_LEAVES, "snowy_maple_leaves"); - gen.registerSingleton(PromenadeBlocks.MIKADO_MAPLE_LEAVES, TexturedModel.LEAVES); + gen.createTrivialBlock(PromenadeBlocks.MIKADO_MAPLE_LEAVES, TexturedModel.LEAVES); this.registerSnowyLeaves(gen, PromenadeBlocks.SNOWY_MIKADO_MAPLE_LEAVES, PromenadeBlocks.MIKADO_MAPLE_LEAVES, "snowy_maple_leaves"); this.registerFallenLeaves(gen, PromenadeBlocks.FALLEN_SAP_MAPLE_LEAVES, PromenadeFoliageColors.SAP_MAPLE); this.registerFallenLeaves(gen, PromenadeBlocks.FALLEN_VERMILION_MAPLE_LEAVES); this.registerFallenLeaves(gen, PromenadeBlocks.FALLEN_FULVOUS_MAPLE_LEAVES); this.registerFallenLeaves(gen, PromenadeBlocks.FALLEN_MIKADO_MAPLE_LEAVES); - gen.registerTintedBlockAndItem(PromenadeBlocks.SAP_MAPLE_LEAF_PILE, PromenadeTexturedModels.pile(PromenadeBlocks.SAP_MAPLE_LEAVES), PromenadeFoliageColors.SAP_MAPLE); - gen.registerSingleton(PromenadeBlocks.VERMILION_MAPLE_LEAF_PILE, PromenadeTexturedModels.pile(PromenadeBlocks.VERMILION_MAPLE_LEAVES)); - gen.registerSingleton(PromenadeBlocks.FULVOUS_MAPLE_LEAF_PILE, PromenadeTexturedModels.pile(PromenadeBlocks.FULVOUS_MAPLE_LEAVES)); - gen.registerSingleton(PromenadeBlocks.MIKADO_MAPLE_LEAF_PILE, PromenadeTexturedModels.pile(PromenadeBlocks.MIKADO_MAPLE_LEAVES)); - - gen.createLogTexturePool(PromenadeBlocks.PALM_LOG).log(PromenadeBlocks.PALM_LOG).wood(PromenadeBlocks.PALM_WOOD); - gen.createLogTexturePool(PromenadeBlocks.STRIPPED_PALM_LOG).log(PromenadeBlocks.STRIPPED_PALM_LOG).wood(PromenadeBlocks.STRIPPED_PALM_WOOD); - gen.registerHangingSign(PromenadeBlocks.STRIPPED_PALM_LOG, PromenadeBlocks.PALM_HANGING_SIGN, PromenadeBlocks.PALM_WALL_HANGING_SIGN); - gen.registerShelf(PromenadeBlocks.PALM_SHELF, PromenadeBlocks.STRIPPED_PALM_LOG); - gen.registerFlowerPotPlantAndItem(PromenadeBlocks.PALM_SAPLING, PromenadeBlocks.POTTED_PALM_SAPLING, BlockStateModelGenerator.CrossType.NOT_TINTED); - gen.registerTintedBlockAndItem(PromenadeBlocks.PALM_LEAVES, TexturedModel.LEAVES, PromenadeFoliageColors.PALM); + gen.createTintedLeaves(PromenadeBlocks.SAP_MAPLE_LEAF_PILE, PromenadeTexturedModels.pile(PromenadeBlocks.SAP_MAPLE_LEAVES), PromenadeFoliageColors.SAP_MAPLE); + gen.createTrivialBlock(PromenadeBlocks.VERMILION_MAPLE_LEAF_PILE, PromenadeTexturedModels.pile(PromenadeBlocks.VERMILION_MAPLE_LEAVES)); + gen.createTrivialBlock(PromenadeBlocks.FULVOUS_MAPLE_LEAF_PILE, PromenadeTexturedModels.pile(PromenadeBlocks.FULVOUS_MAPLE_LEAVES)); + gen.createTrivialBlock(PromenadeBlocks.MIKADO_MAPLE_LEAF_PILE, PromenadeTexturedModels.pile(PromenadeBlocks.MIKADO_MAPLE_LEAVES)); + + gen.woodProvider(PromenadeBlocks.PALM_LOG).log(PromenadeBlocks.PALM_LOG).wood(PromenadeBlocks.PALM_WOOD); + gen.woodProvider(PromenadeBlocks.STRIPPED_PALM_LOG).log(PromenadeBlocks.STRIPPED_PALM_LOG).wood(PromenadeBlocks.STRIPPED_PALM_WOOD); + gen.createHangingSign(PromenadeBlocks.STRIPPED_PALM_LOG, PromenadeBlocks.PALM_HANGING_SIGN, PromenadeBlocks.PALM_WALL_HANGING_SIGN); + gen.createShelf(PromenadeBlocks.PALM_SHELF, PromenadeBlocks.STRIPPED_PALM_LOG); + gen.createPlantWithDefaultItem(PromenadeBlocks.PALM_SAPLING, PromenadeBlocks.POTTED_PALM_SAPLING, BlockModelGenerators.PlantType.NOT_TINTED); + gen.createTintedLeaves(PromenadeBlocks.PALM_LEAVES, TexturedModel.LEAVES, PromenadeFoliageColors.PALM); this.registerSnowyLeaves(gen, PromenadeBlocks.SNOWY_PALM_LEAVES, PromenadeBlocks.PALM_LEAVES, PromenadeFoliageColors.PALM); - gen.registerTintedBlockAndItem(PromenadeBlocks.PALM_LEAF_PILE, PromenadeTexturedModels.pile(PromenadeBlocks.PALM_LEAVES), PromenadeFoliageColors.PALM); - gen.registerTintableCrossBlockState(PromenadeBlocks.PALM_HANGING_LEAVES, BlockStateModelGenerator.CrossType.TINTED); + gen.createTintedLeaves(PromenadeBlocks.PALM_LEAF_PILE, PromenadeTexturedModels.pile(PromenadeBlocks.PALM_LEAVES), PromenadeFoliageColors.PALM); + gen.createCrossBlock(PromenadeBlocks.PALM_HANGING_LEAVES, BlockModelGenerators.PlantType.TINTED); this.registerTintedItem(gen, PromenadeBlocks.PALM_HANGING_LEAVES, PromenadeFoliageColors.PALM); - gen.registerNetherrackBottomCustomTop(PromenadeBlocks.DARK_AMARANTH_NYLIUM); - gen.registerSimpleCubeAll(PromenadeBlocks.DARK_AMARANTH_WART_BLOCK); - gen.registerRoots(PromenadeBlocks.DARK_AMARANTH_ROOTS, PromenadeBlocks.POTTED_DARK_AMARANTH_ROOTS); - gen.createLogTexturePool(PromenadeBlocks.DARK_AMARANTH_STEM).stem(PromenadeBlocks.DARK_AMARANTH_STEM).wood(PromenadeBlocks.DARK_AMARANTH_HYPHAE); - gen.createLogTexturePool(PromenadeBlocks.STRIPPED_DARK_AMARANTH_STEM).stem(PromenadeBlocks.STRIPPED_DARK_AMARANTH_STEM).wood(PromenadeBlocks.STRIPPED_DARK_AMARANTH_HYPHAE); - gen.registerHangingSign(PromenadeBlocks.STRIPPED_DARK_AMARANTH_STEM, PromenadeBlocks.DARK_AMARANTH_HANGING_SIGN, PromenadeBlocks.DARK_AMARANTH_WALL_HANGING_SIGN); - gen.registerShelf(PromenadeBlocks.DARK_AMARANTH_SHELF, PromenadeBlocks.STRIPPED_DARK_AMARANTH_STEM); - gen.registerFlowerPotPlantAndItem(PromenadeBlocks.DARK_AMARANTH_FUNGUS, PromenadeBlocks.POTTED_DARK_AMARANTH_FUNGUS, BlockStateModelGenerator.CrossType.NOT_TINTED); + gen.createNyliumBlock(PromenadeBlocks.DARK_AMARANTH_NYLIUM); + gen.createTrivialCube(PromenadeBlocks.DARK_AMARANTH_WART_BLOCK); + gen.createNetherRoots(PromenadeBlocks.DARK_AMARANTH_ROOTS, PromenadeBlocks.POTTED_DARK_AMARANTH_ROOTS); + gen.woodProvider(PromenadeBlocks.DARK_AMARANTH_STEM).log(PromenadeBlocks.DARK_AMARANTH_STEM).wood(PromenadeBlocks.DARK_AMARANTH_HYPHAE); + gen.woodProvider(PromenadeBlocks.STRIPPED_DARK_AMARANTH_STEM).log(PromenadeBlocks.STRIPPED_DARK_AMARANTH_STEM).wood(PromenadeBlocks.STRIPPED_DARK_AMARANTH_HYPHAE); + gen.createHangingSign(PromenadeBlocks.STRIPPED_DARK_AMARANTH_STEM, PromenadeBlocks.DARK_AMARANTH_HANGING_SIGN, PromenadeBlocks.DARK_AMARANTH_WALL_HANGING_SIGN); + gen.createShelf(PromenadeBlocks.DARK_AMARANTH_SHELF, PromenadeBlocks.STRIPPED_DARK_AMARANTH_STEM); + gen.createPlantWithDefaultItem(PromenadeBlocks.DARK_AMARANTH_FUNGUS, PromenadeBlocks.POTTED_DARK_AMARANTH_FUNGUS, BlockModelGenerators.PlantType.NOT_TINTED); - gen.registerSimpleCubeAll(PromenadeBlocks.SOUL_SHROOMLIGHT); + gen.createTrivialCube(PromenadeBlocks.SOUL_SHROOMLIGHT); - this.registerFacingPlantPart(gen, PromenadeBlocks.COILED_VINES, PromenadeBlocks.COILED_VINES_PLANT, BlockStateModelGenerator.CrossType.NOT_TINTED); - gen.registerItemModel(PromenadeBlocks.COILED_VINES, "_plant"); + this.registerFacingPlantPart(gen, PromenadeBlocks.COILED_VINES, PromenadeBlocks.COILED_VINES_PLANT, BlockModelGenerators.PlantType.NOT_TINTED); + gen.registerSimpleFlatItemModel(PromenadeBlocks.COILED_VINES, "_plant"); this.registerMoai(gen); this.registerBlueberryBush(gen); } - public final void registerDripLog(BlockStateModelGenerator gen, Block block) { - var textureMap = new TextureMap().put(TextureKey.SIDE, TextureMap.getId(block)).put(TextureKey.END, TextureMap.getSubId(block, "_top")).put(TextureKey.PARTICLE, TextureMap.getId(block)); - var textureMapDrip = new TextureMap().put(TextureKey.SIDE, TextureMap.getSubId(block, "_drip")).put(TextureKey.END, TextureMap.getSubId(block, "_top")).put(TextureKey.PARTICLE, TextureMap.getId(block)); + public final void registerDripLog(BlockModelGenerators gen, Block block) { + var textureMap = new TextureMapping().put(TextureSlot.SIDE, TextureMapping.getBlockTexture(block)).put(TextureSlot.END, TextureMapping.getBlockTexture(block, "_top")).put(TextureSlot.PARTICLE, TextureMapping.getBlockTexture(block)); + var textureMapDrip = new TextureMapping().put(TextureSlot.SIDE, TextureMapping.getBlockTexture(block, "_drip")).put(TextureSlot.END, TextureMapping.getBlockTexture(block, "_top")).put(TextureSlot.PARTICLE, TextureMapping.getBlockTexture(block)); - var verticalModel = BlockStateModelGenerator.createWeightedVariant(Models.CUBE_COLUMN.upload(block, textureMap, gen.modelCollector)); - var horizontalModel = BlockStateModelGenerator.createWeightedVariant(Models.CUBE_COLUMN_HORIZONTAL.upload(block, textureMap, gen.modelCollector)); + var verticalModel = BlockModelGenerators.plainVariant(ModelTemplates.CUBE_COLUMN.create(block, textureMap, gen.modelOutput)); + var horizontalModel = BlockModelGenerators.plainVariant(ModelTemplates.CUBE_COLUMN_HORIZONTAL.create(block, textureMap, gen.modelOutput)); - var verticalModelDrip = BlockStateModelGenerator.createWeightedVariant(Models.CUBE_COLUMN.upload(block, "_drip", textureMapDrip, gen.modelCollector)); - var horizontalModelDrip = BlockStateModelGenerator.createWeightedVariant(Models.CUBE_COLUMN_HORIZONTAL.upload(block, "_drip", textureMapDrip, gen.modelCollector)); + var verticalModelDrip = BlockModelGenerators.plainVariant(ModelTemplates.CUBE_COLUMN.createWithSuffix(block, "_drip", textureMapDrip, gen.modelOutput)); + var horizontalModelDrip = BlockModelGenerators.plainVariant(ModelTemplates.CUBE_COLUMN_HORIZONTAL.createWithSuffix(block, "_drip", textureMapDrip, gen.modelOutput)); - gen.blockStateCollector.accept(VariantsBlockModelDefinitionCreator.of(block).with( - BlockStateVariantMap.models(Properties.AXIS, PromenadeBlockProperties.DRIP) - .register(Direction.Axis.Y, false, verticalModel) - .register(Direction.Axis.Z, false, horizontalModel.apply(ROTATE_X_90)) - .register(Direction.Axis.X, false, horizontalModel.apply(ROTATE_X_90).apply(ROTATE_Y_90)) - .register(Direction.Axis.Y, true, verticalModelDrip) - .register(Direction.Axis.Z, true, horizontalModelDrip.apply(ROTATE_X_90)) - .register(Direction.Axis.X, true, horizontalModelDrip.apply(ROTATE_X_90).apply(ROTATE_Y_90)) + gen.blockStateOutput.accept(MultiVariantGenerator.dispatch(block).with( + PropertyDispatch.initial(BlockStateProperties.AXIS, PromenadeBlockProperties.DRIP) + .select(Direction.Axis.Y, false, verticalModel) + .select(Direction.Axis.Z, false, horizontalModel.with(ROTATE_X_90)) + .select(Direction.Axis.X, false, horizontalModel.with(ROTATE_X_90).with(ROTATE_Y_90)) + .select(Direction.Axis.Y, true, verticalModelDrip) + .select(Direction.Axis.Z, true, horizontalModelDrip.with(ROTATE_X_90)) + .select(Direction.Axis.X, true, horizontalModelDrip.with(ROTATE_X_90).with(ROTATE_Y_90)) )); } - public final void registerTintedItem(BlockStateModelGenerator gen, Block block, int constant) { - registerTintedItem(gen, block, ItemModels.constantTintSource(constant)); + public final void registerTintedItem(BlockModelGenerators gen, Block block, int constant) { + registerTintedItem(gen, block, ItemModelUtils.constantTint(constant)); } - public final void registerTintedItem(BlockStateModelGenerator gen, Block block, TintSource tint) { - Identifier identifier = gen.uploadBlockItemModel(block.asItem(), block); - gen.registerTintedItemModel(block, identifier, tint); + public final void registerTintedItem(BlockModelGenerators gen, Block block, ItemTintSource tint) { + Identifier identifier = gen.createFlatItemModelWithBlockTexture(block.asItem(), block); + gen.registerSimpleTintedItemModel(block, identifier, tint); } - public final void registerBlueberryBush(BlockStateModelGenerator gen) { - gen.registerItemModel(PromenadeItems.BLUEBERRIES); - gen.blockStateCollector.accept(VariantsBlockModelDefinitionCreator.of(PromenadeBlocks.BLUEBERRY_BUSH) + public final void registerBlueberryBush(BlockModelGenerators gen) { + gen.registerSimpleFlatItemModel(PromenadeItems.BLUEBERRIES); + gen.blockStateOutput.accept(MultiVariantGenerator.dispatch(PromenadeBlocks.BLUEBERRY_BUSH) .with( - BlockStateVariantMap.models(Properties.AGE_3) - .generate(stage -> BlockStateModelGenerator.createWeightedVariant(gen.createSubModel(PromenadeBlocks.BLUEBERRY_BUSH, "_stage" + stage, Models.CROSS, TextureMap::cross))) + PropertyDispatch.initial(BlockStateProperties.AGE_3) + .generate(stage -> BlockModelGenerators.plainVariant(gen.createSuffixedVariant(PromenadeBlocks.BLUEBERRY_BUSH, "_stage" + stage, ModelTemplates.CROSS, TextureMapping::cross))) ) ); } - private void registerMoai(BlockStateModelGenerator gen) { + private void registerMoai(BlockModelGenerators gen) { // maybe check if we can't generate the models too? - gen.blockStateCollector + gen.blockStateOutput .accept( - VariantsBlockModelDefinitionCreator.of(PromenadeBlocks.MOAI) - .with(BlockStateVariantMap.models(MoaiBlock.TYPE) - .register(MoaiType.SINGLE, BlockStateModelGenerator.createWeightedVariant(ModelIds.getBlockModelId(PromenadeBlocks.MOAI))) - .register(MoaiType.TOP, BlockStateModelGenerator.createWeightedVariant(ModelIds.getBlockSubModelId(PromenadeBlocks.MOAI, "_top"))) - .register(MoaiType.BOTTOM, BlockStateModelGenerator.createWeightedVariant(ModelIds.getBlockSubModelId(PromenadeBlocks.MOAI, "_bottom"))) + MultiVariantGenerator.dispatch(PromenadeBlocks.MOAI) + .with(PropertyDispatch.initial(MoaiBlock.TYPE) + .select(MoaiType.SINGLE, BlockModelGenerators.plainVariant(ModelLocationUtils.getModelLocation(PromenadeBlocks.MOAI))) + .select(MoaiType.TOP, BlockModelGenerators.plainVariant(ModelLocationUtils.getModelLocation(PromenadeBlocks.MOAI, "_top"))) + .select(MoaiType.BOTTOM, BlockModelGenerators.plainVariant(ModelLocationUtils.getModelLocation(PromenadeBlocks.MOAI, "_bottom"))) ) - .apply(NORTH_DEFAULT_HORIZONTAL_ROTATION_OPERATIONS) + .with(NORTH_DEFAULT_HORIZONTAL_ROTATION_OPERATIONS) ); } - private void registerSnowyLeaves(BlockStateModelGenerator gen, Block snowyLeaves, Block normalLeaves) { + private void registerSnowyLeaves(BlockModelGenerators gen, Block snowyLeaves, Block normalLeaves) { registerSnowyLeaves(gen, snowyLeaves, normalLeaves, 0); } - private void registerSnowyLeaves(BlockStateModelGenerator gen, Block snowyLeaves, Block normalLeaves, int tint) { - var bottomModel = gen.createSubModel(snowyLeaves, "_bottom", PromenadeModels.BOTTOM_SNOWY_LEAVES, block -> PromenadeTextureMaps.snowyLeaves(snowyLeaves, normalLeaves)); + private void registerSnowyLeaves(BlockModelGenerators gen, Block snowyLeaves, Block normalLeaves, int tint) { + var bottomModel = gen.createSuffixedVariant(snowyLeaves, "_bottom", PromenadeModels.BOTTOM_SNOWY_LEAVES, block -> PromenadeTextureMaps.snowyLeaves(snowyLeaves, normalLeaves)); if (tint != 0) { - gen.registerTintedItemModel(snowyLeaves, bottomModel, ItemModels.constantTintSource(tint)); + gen.registerSimpleTintedItemModel(snowyLeaves, bottomModel, ItemModelUtils.constantTint(tint)); } else { - gen.registerItemModel(snowyLeaves.asItem(), bottomModel); + gen.registerSimpleItemModel(snowyLeaves.asItem(), bottomModel); } - gen.blockStateCollector.accept( - VariantsBlockModelDefinitionCreator.of(snowyLeaves) - .with(BlockStateVariantMap.models(SnowyLeavesBlock.BOTTOM) - .register(true, BlockStateModelGenerator.createWeightedVariant(bottomModel)) - .register(false, BlockStateModelGenerator.createWeightedVariant(gen.createSubModel(snowyLeaves, "", Models.CUBE_ALL, TextureMap::all))) + gen.blockStateOutput.accept( + MultiVariantGenerator.dispatch(snowyLeaves) + .with(PropertyDispatch.initial(SnowyLeavesBlock.BOTTOM) + .select(true, BlockModelGenerators.plainVariant(bottomModel)) + .select(false, BlockModelGenerators.plainVariant(gen.createSuffixedVariant(snowyLeaves, "", ModelTemplates.CUBE_ALL, TextureMapping::cube))) ) ); } - private void registerSnowyLeaves(BlockStateModelGenerator gen, Block snowyLeaves, Block normalLeaves, String textureName) { + private void registerSnowyLeaves(BlockModelGenerators gen, Block snowyLeaves, Block normalLeaves, String textureName) { registerSnowyLeaves(gen, snowyLeaves, normalLeaves, textureName, 0); } - private void registerSnowyLeaves(BlockStateModelGenerator gen, Block snowyLeaves, Block normalLeaves, String textureName, int tint) { - var textureId = Identifier.of(Registries.BLOCK.getId(snowyLeaves).getNamespace(), "block/" + textureName); - var bottomModel = gen.createSubModel(snowyLeaves, "_bottom", PromenadeModels.BOTTOM_SNOWY_LEAVES, block -> PromenadeTextureMaps.snowyLeaves(textureId, normalLeaves)); + private void registerSnowyLeaves(BlockModelGenerators gen, Block snowyLeaves, Block normalLeaves, String textureName, int tint) { + var textureId = Identifier.fromNamespaceAndPath(BuiltInRegistries.BLOCK.getKey(snowyLeaves).getNamespace(), "block/" + textureName); + var bottomModel = gen.createSuffixedVariant(snowyLeaves, "_bottom", PromenadeModels.BOTTOM_SNOWY_LEAVES, block -> PromenadeTextureMaps.snowyLeaves(textureId, normalLeaves)); if (tint != 0) { - gen.registerTintedItemModel(snowyLeaves, bottomModel, ItemModels.constantTintSource(tint)); + gen.registerSimpleTintedItemModel(snowyLeaves, bottomModel, ItemModelUtils.constantTint(tint)); } else { - gen.registerItemModel(snowyLeaves.asItem(), bottomModel); + gen.registerSimpleItemModel(snowyLeaves.asItem(), bottomModel); } - gen.blockStateCollector.accept( - VariantsBlockModelDefinitionCreator.of(snowyLeaves) - .with(BlockStateVariantMap.models(SnowyLeavesBlock.BOTTOM) - .register(true, BlockStateModelGenerator.createWeightedVariant(bottomModel)) - .register(false, BlockStateModelGenerator.createWeightedVariant(gen.createSubModel(snowyLeaves, "", Models.CUBE_ALL, identifier -> TextureMap.all(textureId)))) + gen.blockStateOutput.accept( + MultiVariantGenerator.dispatch(snowyLeaves) + .with(PropertyDispatch.initial(SnowyLeavesBlock.BOTTOM) + .select(true, BlockModelGenerators.plainVariant(bottomModel)) + .select(false, BlockModelGenerators.plainVariant(gen.createSuffixedVariant(snowyLeaves, "", ModelTemplates.CUBE_ALL, identifier -> TextureMapping.cube(new Material(textureId))))) ) ); } - private void registerFallenLeaves(BlockStateModelGenerator gen, Block fallenLeaves) { + private void registerFallenLeaves(BlockModelGenerators gen, Block fallenLeaves) { registerFallenLeaves(gen, fallenLeaves, 0); } - public final void registerFallenLeaves(BlockStateModelGenerator gen, Block fallenLeaves, int tintSource) { + public final void registerFallenLeaves(BlockModelGenerators gen, Block fallenLeaves, int tintSource) { if (tintSource != 0) { - Identifier identifier = gen.uploadBlockItemModel(fallenLeaves.asItem(), fallenLeaves); - gen.registerTintedItemModel(fallenLeaves, identifier, ItemModels.constantTintSource(tintSource)); + Identifier identifier = gen.createFlatItemModelWithBlockTexture(fallenLeaves.asItem(), fallenLeaves); + gen.registerSimpleTintedItemModel(fallenLeaves, identifier, ItemModelUtils.constantTint(tintSource)); } else { - gen.registerItemModel(fallenLeaves); + gen.registerSimpleFlatItemModel(fallenLeaves); } - var weightedVariant = BlockStateModelGenerator.createWeightedVariant(TexturedModel.TEMPLATE_LEAF_LITTER_1.upload(fallenLeaves, gen.modelCollector)); - var weightedVariant2 = BlockStateModelGenerator.createWeightedVariant(TexturedModel.TEMPLATE_LEAF_LITTER_2.upload(fallenLeaves, gen.modelCollector)); - var weightedVariant3 = BlockStateModelGenerator.createWeightedVariant(TexturedModel.TEMPLATE_LEAF_LITTER_3.upload(fallenLeaves, gen.modelCollector)); - var weightedVariant4 = BlockStateModelGenerator.createWeightedVariant(TexturedModel.TEMPLATE_LEAF_LITTER_4.upload(fallenLeaves, gen.modelCollector)); - gen.registerSegmentedBlock(fallenLeaves, + var weightedVariant = BlockModelGenerators.plainVariant(TexturedModel.LEAF_LITTER_1.create(fallenLeaves, gen.modelOutput)); + var weightedVariant2 = BlockModelGenerators.plainVariant(TexturedModel.LEAF_LITTER_2.create(fallenLeaves, gen.modelOutput)); + var weightedVariant3 = BlockModelGenerators.plainVariant(TexturedModel.LEAF_LITTER_3.create(fallenLeaves, gen.modelOutput)); + var weightedVariant4 = BlockModelGenerators.plainVariant(TexturedModel.LEAF_LITTER_4.create(fallenLeaves, gen.modelOutput)); + gen.createSegmentedBlock(fallenLeaves, weightedVariant, LEAF_LITTER_MODEL_1_CONDITION_FUNCTION, weightedVariant2, LEAF_LITTER_MODEL_2_CONDITION_FUNCTION, weightedVariant3, LEAF_LITTER_MODEL_3_CONDITION_FUNCTION, @@ -294,45 +299,45 @@ public final void registerFallenLeaves(BlockStateModelGenerator gen, Block falle ); } - public final void registerFacingPlantPart(BlockStateModelGenerator gen, Block plant, Block plantStem, BlockStateModelGenerator.CrossType tintType) { + public final void registerFacingPlantPart(BlockModelGenerators gen, Block plant, Block plantStem, BlockModelGenerators.PlantType tintType) { this.registerFacingTintableCrossBlockState(gen, plant, tintType); this.registerFacingTintableCrossBlockState(gen, plantStem, tintType); } - public final void registerFacingTintableCrossBlockState(BlockStateModelGenerator gen, Block block, BlockStateModelGenerator.CrossType tintType) { - TextureMap textureMap = tintType.getTextureMap(block); + public final void registerFacingTintableCrossBlockState(BlockModelGenerators gen, Block block, BlockModelGenerators.PlantType tintType) { + TextureMapping textureMap = tintType.getTextureMapping(block); this.registerFacingTintableCrossBlockState(gen, block, tintType, textureMap); } - public final void registerFacingTintableCrossBlockState(BlockStateModelGenerator gen, Block block, BlockStateModelGenerator.CrossType tintType, TextureMap crossTexture) { - WeightedVariant weightedVariant = BlockStateModelGenerator.createWeightedVariant(tintType.getCrossModel().upload(block, crossTexture, gen.modelCollector)); - gen.blockStateCollector.accept( - BlockStateModelGenerator.createSingletonBlockState(block, weightedVariant) - .apply(UP_DEFAULT_ROTATION_OPERATIONS) + public final void registerFacingTintableCrossBlockState(BlockModelGenerators gen, Block block, BlockModelGenerators.PlantType tintType, TextureMapping crossTexture) { + MultiVariant weightedVariant = BlockModelGenerators.plainVariant(tintType.getCross().create(block, crossTexture, gen.modelOutput)); + gen.blockStateOutput.accept( + BlockModelGenerators.createSimpleBlock(block, weightedVariant) + .with(UP_DEFAULT_ROTATION_OPERATIONS) ); } @Override - public void generateItemModels(ItemModelGenerator gen) { - gen.register(PromenadeItems.SAKURA_BOAT, Models.GENERATED); - gen.register(PromenadeItems.SAKURA_CHEST_BOAT, Models.GENERATED); - gen.register(PromenadeItems.MAPLE_BOAT, Models.GENERATED); - gen.register(PromenadeItems.MAPLE_CHEST_BOAT, Models.GENERATED); - gen.register(PromenadeItems.MAPLE_SYRUP_BOTTLE, Models.GENERATED); - gen.register(PromenadeItems.PALM_BOAT, Models.GENERATED); - gen.register(PromenadeItems.PALM_CHEST_BOAT, Models.GENERATED); - - gen.register(PromenadeItems.BANANA, Models.GENERATED); - gen.register(PromenadeItems.APRICOT, Models.GENERATED); - gen.register(PromenadeItems.MANGO, Models.GENERATED); - gen.register(PromenadeItems.DUCK, Models.GENERATED); - gen.register(PromenadeItems.COOKED_DUCK, Models.GENERATED); - - gen.register(PromenadeItems.BOVINE_BANNER_PATTERN, Models.GENERATED); - - gen.register(PromenadeItems.CAPYBARA_SPAWN_EGG, Models.GENERATED); - gen.register(PromenadeItems.DUCK_SPAWN_EGG, Models.GENERATED); - gen.register(PromenadeItems.LUSH_CREEPER_SPAWN_EGG, Models.GENERATED); - gen.register(PromenadeItems.SUNKEN_SPAWN_EGG, Models.GENERATED); + public void generateItemModels(ItemModelGenerators gen) { + gen.generateFlatItem(PromenadeItems.SAKURA_BOAT, ModelTemplates.FLAT_ITEM); + gen.generateFlatItem(PromenadeItems.SAKURA_CHEST_BOAT, ModelTemplates.FLAT_ITEM); + gen.generateFlatItem(PromenadeItems.MAPLE_BOAT, ModelTemplates.FLAT_ITEM); + gen.generateFlatItem(PromenadeItems.MAPLE_CHEST_BOAT, ModelTemplates.FLAT_ITEM); + gen.generateFlatItem(PromenadeItems.MAPLE_SYRUP_BOTTLE, ModelTemplates.FLAT_ITEM); + gen.generateFlatItem(PromenadeItems.PALM_BOAT, ModelTemplates.FLAT_ITEM); + gen.generateFlatItem(PromenadeItems.PALM_CHEST_BOAT, ModelTemplates.FLAT_ITEM); + + gen.generateFlatItem(PromenadeItems.BANANA, ModelTemplates.FLAT_ITEM); + gen.generateFlatItem(PromenadeItems.APRICOT, ModelTemplates.FLAT_ITEM); + gen.generateFlatItem(PromenadeItems.MANGO, ModelTemplates.FLAT_ITEM); + gen.generateFlatItem(PromenadeItems.DUCK, ModelTemplates.FLAT_ITEM); + gen.generateFlatItem(PromenadeItems.COOKED_DUCK, ModelTemplates.FLAT_ITEM); + + gen.generateFlatItem(PromenadeItems.BOVINE_BANNER_PATTERN, ModelTemplates.FLAT_ITEM); + + gen.generateFlatItem(PromenadeItems.CAPYBARA_SPAWN_EGG, ModelTemplates.FLAT_ITEM); + gen.generateFlatItem(PromenadeItems.DUCK_SPAWN_EGG, ModelTemplates.FLAT_ITEM); + gen.generateFlatItem(PromenadeItems.LUSH_CREEPER_SPAWN_EGG, ModelTemplates.FLAT_ITEM); + gen.generateFlatItem(PromenadeItems.SUNKEN_SPAWN_EGG, ModelTemplates.FLAT_ITEM); } } diff --git a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadePaintingVariantProvider.java b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadePaintingVariantProvider.java index ccba777b..4dbcee75 100644 --- a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadePaintingVariantProvider.java +++ b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadePaintingVariantProvider.java @@ -1,27 +1,27 @@ package fr.hugman.promenade.data.provider; import fr.hugman.promenade.entity.variant.PromenadePaintingVariants; -import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; +import net.fabricmc.fabric.api.datagen.v1.FabricPackOutput; import net.fabricmc.fabric.api.datagen.v1.provider.FabricDynamicRegistryProvider; -import net.minecraft.entity.decoration.painting.PaintingVariant; -import net.minecraft.registry.Registerable; -import net.minecraft.registry.RegistryKey; -import net.minecraft.registry.RegistryKeys; -import net.minecraft.registry.RegistryWrapper; -import net.minecraft.text.Text; -import net.minecraft.util.Formatting; +import net.minecraft.ChatFormatting; +import net.minecraft.core.HolderLookup; +import net.minecraft.core.registries.Registries; +import net.minecraft.data.worldgen.BootstrapContext; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.entity.decoration.painting.PaintingVariant; import java.util.Optional; import java.util.concurrent.CompletableFuture; public class PromenadePaintingVariantProvider extends FabricDynamicRegistryProvider { - public PromenadePaintingVariantProvider(FabricDataOutput output, CompletableFuture registriesFuture) { + public PromenadePaintingVariantProvider(FabricPackOutput output, CompletableFuture registriesFuture) { super(output, registriesFuture); } @Override - protected void configure(RegistryWrapper.WrapperLookup registries, Entries entries) { - final var wrapper = registries.getOrThrow(RegistryKeys.PAINTING_VARIANT); + protected void configure(HolderLookup.Provider registries, Entries entries) { + final var wrapper = registries.lookupOrThrow(Registries.PAINTING_VARIANT); entries.add(wrapper, PromenadePaintingVariants.OPTIMISM); entries.add(wrapper, PromenadePaintingVariants.NURTURE); } @@ -31,18 +31,18 @@ public String getName() { return "Painting Variants"; } - public static void register(Registerable registerable) { + public static void register(BootstrapContext registerable) { of(registerable, PromenadePaintingVariants.OPTIMISM, 2, 2, "hugman"); of(registerable, PromenadePaintingVariants.NURTURE, 2, 2, "hugman"); } - private static void of(Registerable registry, RegistryKey key, int width, int height, String authorKey) { + private static void of(BootstrapContext registry, ResourceKey key, int width, int height, String authorKey) { registry.register(key, new PaintingVariant( width, height, - key.getValue(), - Optional.of(Text.translatable(key.getValue().toTranslationKey("painting", "title")).formatted(Formatting.YELLOW)), - Optional.of(Text.translatable("name." + authorKey).formatted(Formatting.GRAY))) + key.identifier(), + Optional.of(Component.translatable(key.identifier().toLanguageKey("painting", "title")).withStyle(ChatFormatting.YELLOW)), + Optional.of(Component.translatable("name." + authorKey).withStyle(ChatFormatting.GRAY))) ); } } \ No newline at end of file diff --git a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadePaintingVariantTagProvider.java b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadePaintingVariantTagProvider.java index b0832a68..072f8ad1 100644 --- a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadePaintingVariantTagProvider.java +++ b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadePaintingVariantTagProvider.java @@ -1,22 +1,22 @@ package fr.hugman.promenade.data.provider; import fr.hugman.promenade.entity.variant.PromenadePaintingVariants; -import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; -import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider; -import net.minecraft.entity.decoration.painting.PaintingVariant; -import net.minecraft.registry.RegistryKeys; -import net.minecraft.registry.RegistryWrapper; -import net.minecraft.registry.tag.PaintingVariantTags; +import net.fabricmc.fabric.api.datagen.v1.FabricPackOutput; +import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagsProvider; +import net.minecraft.core.HolderLookup; +import net.minecraft.core.registries.Registries; +import net.minecraft.tags.PaintingVariantTags; +import net.minecraft.world.entity.decoration.painting.PaintingVariant; import java.util.concurrent.CompletableFuture; -public class PromenadePaintingVariantTagProvider extends FabricTagProvider { - public PromenadePaintingVariantTagProvider(FabricDataOutput output, CompletableFuture completableFuture) { - super(output, RegistryKeys.PAINTING_VARIANT, completableFuture); +public class PromenadePaintingVariantTagProvider extends FabricTagsProvider { + public PromenadePaintingVariantTagProvider(FabricPackOutput output, CompletableFuture completableFuture) { + super(output, Registries.PAINTING_VARIANT, completableFuture); } @Override - protected void configure(RegistryWrapper.WrapperLookup wrapperLookup) { + protected void addTags(HolderLookup.Provider wrapperLookup) { builder(PaintingVariantTags.PLACEABLE) .add(PromenadePaintingVariants.OPTIMISM, PromenadePaintingVariants.NURTURE); } diff --git a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadePlacedFeatureProvider.java b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadePlacedFeatureProvider.java index 6415fa20..f2ba96dd 100644 --- a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadePlacedFeatureProvider.java +++ b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadePlacedFeatureProvider.java @@ -6,38 +6,40 @@ import fr.hugman.promenade.world.gen.feature.PromenadeFeatures; import fr.hugman.promenade.world.gen.feature.PromenadePlacedFeatures; import fr.hugman.promenade.world.gen.placement_modifier.NoiseIntervalCountPlacementModifier; -import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; +import net.fabricmc.fabric.api.datagen.v1.FabricPackOutput; import net.fabricmc.fabric.api.datagen.v1.provider.FabricDynamicRegistryProvider; -import net.minecraft.block.Block; -import net.minecraft.block.Blocks; -import net.minecraft.registry.Registerable; -import net.minecraft.registry.RegistryKey; -import net.minecraft.registry.RegistryKeys; -import net.minecraft.registry.RegistryWrapper; -import net.minecraft.registry.entry.RegistryEntry; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.gen.YOffset; -import net.minecraft.world.gen.blockpredicate.BlockPredicate; -import net.minecraft.world.gen.feature.ConfiguredFeature; -import net.minecraft.world.gen.feature.FeatureConfig; -import net.minecraft.world.gen.feature.PlacedFeature; -import net.minecraft.world.gen.feature.PlacedFeatures; -import net.minecraft.world.gen.heightprovider.TrapezoidHeightProvider; -import net.minecraft.world.gen.placementmodifier.*; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.core.Holder; +import net.minecraft.core.HolderLookup; +import net.minecraft.core.registries.Registries; +import net.minecraft.data.worldgen.BootstrapContext; +import net.minecraft.data.worldgen.features.VegetationFeatures; +import net.minecraft.data.worldgen.placement.PlacementUtils; +import net.minecraft.resources.ResourceKey; +import net.minecraft.util.Util; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.levelgen.VerticalAnchor; +import net.minecraft.world.level.levelgen.blockpredicates.BlockPredicate; +import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; +import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration; +import net.minecraft.world.level.levelgen.heightproviders.TrapezoidHeight; +import net.minecraft.world.level.levelgen.placement.*; import java.util.List; import java.util.concurrent.CompletableFuture; public class PromenadePlacedFeatureProvider extends FabricDynamicRegistryProvider { - private static final PlacementModifier NOT_IN_SURFACE_WATER_MODIFIER = SurfaceWaterDepthFilterPlacementModifier.of(0); + private static final PlacementModifier NOT_IN_SURFACE_WATER_MODIFIER = SurfaceWaterDepthFilter.forMaxDepth(0); - public PromenadePlacedFeatureProvider(FabricDataOutput output, CompletableFuture registriesFuture) { + public PromenadePlacedFeatureProvider(FabricPackOutput output, CompletableFuture registriesFuture) { super(output, registriesFuture); } @Override - protected void configure(RegistryWrapper.WrapperLookup registries, Entries entries) { - entries.addAll(registries.getOrThrow(RegistryKeys.PLACED_FEATURE)); + protected void configure(HolderLookup.Provider registries, Entries entries) { + entries.addAll(registries.lookupOrThrow(Registries.PLACED_FEATURE)); } @Override @@ -45,68 +47,96 @@ public String getName() { return "Placed Features"; } - public static void register(Registerable registerable) { - final var configured = registerable.getRegistryLookup(RegistryKeys.CONFIGURED_FEATURE); + public static void register(BootstrapContext registerable) { + final var configured = registerable.lookup(Registries.CONFIGURED_FEATURE); // Ores var asphalt = configured.getOrThrow(PromenadeConfiguredFeatures.ASPHALT_ORE); - of(registerable, PromenadePlacedFeatures.ORE_ASPHALT_UPPER, asphalt, modifiersWithRarity(6, HeightRangePlacementModifier.uniform(YOffset.fixed(64), YOffset.fixed(128)))); - of(registerable, PromenadePlacedFeatures.ORE_ASPHALT_LOWER, asphalt, modifiersWithCount(2, HeightRangePlacementModifier.uniform(YOffset.fixed(0), YOffset.fixed(60)))); + of(registerable, PromenadePlacedFeatures.ORE_ASPHALT_UPPER, asphalt, modifiersWithRarity(6, HeightRangePlacement.uniform(VerticalAnchor.absolute(64), VerticalAnchor.absolute(128)))); + of(registerable, PromenadePlacedFeatures.ORE_ASPHALT_LOWER, asphalt, modifiersWithCount(2, HeightRangePlacement.uniform(VerticalAnchor.absolute(0), VerticalAnchor.absolute(60)))); var blunite = configured.getOrThrow(PromenadeConfiguredFeatures.BLUNITE_ORE); - of(registerable, PromenadePlacedFeatures.ORE_BLUNITE_UPPER, blunite, modifiersWithRarity(4, HeightRangePlacementModifier.uniform(YOffset.fixed(64), YOffset.fixed(128)))); - of(registerable, PromenadePlacedFeatures.ORE_BLUNITE_LOWER, blunite, modifiersWithCount(2, HeightRangePlacementModifier.uniform(YOffset.fixed(0), YOffset.fixed(60)))); + of(registerable, PromenadePlacedFeatures.ORE_BLUNITE_UPPER, blunite, modifiersWithRarity(4, HeightRangePlacement.uniform(VerticalAnchor.absolute(64), VerticalAnchor.absolute(128)))); + of(registerable, PromenadePlacedFeatures.ORE_BLUNITE_LOWER, blunite, modifiersWithCount(2, HeightRangePlacement.uniform(VerticalAnchor.absolute(0), VerticalAnchor.absolute(60)))); of(registerable, PromenadePlacedFeatures.PACKED_ICE_ORE, configured.getOrThrow(PromenadeConfiguredFeatures.PACKED_ICE_ORE), - modifiersWithCount(17, HeightRangePlacementModifier.of(TrapezoidHeightProvider.create(YOffset.fixed(0), YOffset.fixed(100), 60)))); + modifiersWithCount(17, HeightRangePlacement.of(TrapezoidHeight.of(VerticalAnchor.absolute(0), VerticalAnchor.absolute(100), 60)))); of(registerable, PromenadePlacedFeatures.BLUE_ICE_ORE, configured.getOrThrow(PromenadeConfiguredFeatures.BLUE_ICE_ORE), - modifiersWithCount(4, HeightRangePlacementModifier.of(TrapezoidHeightProvider.create(YOffset.fixed(0), YOffset.fixed(100), 20)))); + modifiersWithCount(4, HeightRangePlacement.of(TrapezoidHeight.of(VerticalAnchor.absolute(0), VerticalAnchor.absolute(100), 20)))); // Trees - of(registerable, PromenadePlacedFeatures.BLUSH_SAKURA, configured.getOrThrow(PromenadeConfiguredFeatures.BLUSH_SAKURA), PlacedFeatures.wouldSurvive(PromenadeBlocks.BLUSH_SAKURA_SAPLING)); - of(registerable, PromenadePlacedFeatures.FANCY_BLUSH_SAKURA, configured.getOrThrow(PromenadeConfiguredFeatures.FANCY_BLUSH_SAKURA), PlacedFeatures.wouldSurvive(PromenadeBlocks.BLUSH_SAKURA_SAPLING)); - of(registerable, PromenadePlacedFeatures.BLUSH_SAKURA_BEES, configured.getOrThrow(PromenadeConfiguredFeatures.BLUSH_SAKURA_BEES), PlacedFeatures.wouldSurvive(PromenadeBlocks.BLUSH_SAKURA_SAPLING)); - of(registerable, PromenadePlacedFeatures.FANCY_BLUSH_SAKURA_BEES, configured.getOrThrow(PromenadeConfiguredFeatures.FANCY_BLUSH_SAKURA_BEES), PlacedFeatures.wouldSurvive(PromenadeBlocks.BLUSH_SAKURA_SAPLING)); + of(registerable, PromenadePlacedFeatures.BLUSH_SAKURA, configured.getOrThrow(PromenadeConfiguredFeatures.BLUSH_SAKURA), PlacementUtils.filteredByBlockSurvival(PromenadeBlocks.BLUSH_SAKURA_SAPLING)); + of(registerable, PromenadePlacedFeatures.FANCY_BLUSH_SAKURA, configured.getOrThrow(PromenadeConfiguredFeatures.FANCY_BLUSH_SAKURA), PlacementUtils.filteredByBlockSurvival(PromenadeBlocks.BLUSH_SAKURA_SAPLING)); + of(registerable, PromenadePlacedFeatures.BLUSH_SAKURA_BEES, configured.getOrThrow(PromenadeConfiguredFeatures.BLUSH_SAKURA_BEES), PlacementUtils.filteredByBlockSurvival(PromenadeBlocks.BLUSH_SAKURA_SAPLING)); + of(registerable, PromenadePlacedFeatures.FANCY_BLUSH_SAKURA_BEES, configured.getOrThrow(PromenadeConfiguredFeatures.FANCY_BLUSH_SAKURA_BEES), PlacementUtils.filteredByBlockSurvival(PromenadeBlocks.BLUSH_SAKURA_SAPLING)); - of(registerable, PromenadePlacedFeatures.COTTON_SAKURA, configured.getOrThrow(PromenadeConfiguredFeatures.COTTON_SAKURA), PlacedFeatures.wouldSurvive(PromenadeBlocks.COTTON_SAKURA_SAPLING)); - of(registerable, PromenadePlacedFeatures.FANCY_COTTON_SAKURA, configured.getOrThrow(PromenadeConfiguredFeatures.FANCY_COTTON_SAKURA), PlacedFeatures.wouldSurvive(PromenadeBlocks.COTTON_SAKURA_SAPLING)); - of(registerable, PromenadePlacedFeatures.COTTON_SAKURA_BEES, configured.getOrThrow(PromenadeConfiguredFeatures.COTTON_SAKURA_BEES), PlacedFeatures.wouldSurvive(PromenadeBlocks.COTTON_SAKURA_SAPLING)); - of(registerable, PromenadePlacedFeatures.FANCY_COTTON_SAKURA_BEES, configured.getOrThrow(PromenadeConfiguredFeatures.FANCY_COTTON_SAKURA_BEES), PlacedFeatures.wouldSurvive(PromenadeBlocks.COTTON_SAKURA_SAPLING)); + of(registerable, PromenadePlacedFeatures.COTTON_SAKURA, configured.getOrThrow(PromenadeConfiguredFeatures.COTTON_SAKURA), PlacementUtils.filteredByBlockSurvival(PromenadeBlocks.COTTON_SAKURA_SAPLING)); + of(registerable, PromenadePlacedFeatures.FANCY_COTTON_SAKURA, configured.getOrThrow(PromenadeConfiguredFeatures.FANCY_COTTON_SAKURA), PlacementUtils.filteredByBlockSurvival(PromenadeBlocks.COTTON_SAKURA_SAPLING)); + of(registerable, PromenadePlacedFeatures.COTTON_SAKURA_BEES, configured.getOrThrow(PromenadeConfiguredFeatures.COTTON_SAKURA_BEES), PlacementUtils.filteredByBlockSurvival(PromenadeBlocks.COTTON_SAKURA_SAPLING)); + of(registerable, PromenadePlacedFeatures.FANCY_COTTON_SAKURA_BEES, configured.getOrThrow(PromenadeConfiguredFeatures.FANCY_COTTON_SAKURA_BEES), PlacementUtils.filteredByBlockSurvival(PromenadeBlocks.COTTON_SAKURA_SAPLING)); - of(registerable, PromenadePlacedFeatures.SAP_MAPLE, configured.getOrThrow(PromenadeConfiguredFeatures.SAP_MAPLE), PlacedFeatures.wouldSurvive(PromenadeBlocks.SAP_MAPLE_SAPLING)); - of(registerable, PromenadePlacedFeatures.FANCY_SAP_MAPLE, configured.getOrThrow(PromenadeConfiguredFeatures.FANCY_SAP_MAPLE), PlacedFeatures.wouldSurvive(PromenadeBlocks.SAP_MAPLE_SAPLING)); - of(registerable, PromenadePlacedFeatures.SAP_MAPLE_BEES, configured.getOrThrow(PromenadeConfiguredFeatures.SAP_MAPLE_BEES), PlacedFeatures.wouldSurvive(PromenadeBlocks.SAP_MAPLE_SAPLING)); - of(registerable, PromenadePlacedFeatures.FANCY_SAP_MAPLE_BEES, configured.getOrThrow(PromenadeConfiguredFeatures.FANCY_SAP_MAPLE_BEES), PlacedFeatures.wouldSurvive(PromenadeBlocks.SAP_MAPLE_SAPLING)); + of(registerable, PromenadePlacedFeatures.SAP_MAPLE, configured.getOrThrow(PromenadeConfiguredFeatures.SAP_MAPLE), PlacementUtils.filteredByBlockSurvival(PromenadeBlocks.SAP_MAPLE_SAPLING)); + of(registerable, PromenadePlacedFeatures.FANCY_SAP_MAPLE, configured.getOrThrow(PromenadeConfiguredFeatures.FANCY_SAP_MAPLE), PlacementUtils.filteredByBlockSurvival(PromenadeBlocks.SAP_MAPLE_SAPLING)); + of(registerable, PromenadePlacedFeatures.SAP_MAPLE_BEES, configured.getOrThrow(PromenadeConfiguredFeatures.SAP_MAPLE_BEES), PlacementUtils.filteredByBlockSurvival(PromenadeBlocks.SAP_MAPLE_SAPLING)); + of(registerable, PromenadePlacedFeatures.FANCY_SAP_MAPLE_BEES, configured.getOrThrow(PromenadeConfiguredFeatures.FANCY_SAP_MAPLE_BEES), PlacementUtils.filteredByBlockSurvival(PromenadeBlocks.SAP_MAPLE_SAPLING)); - of(registerable, PromenadePlacedFeatures.VERMILION_MAPLE, configured.getOrThrow(PromenadeConfiguredFeatures.VERMILION_MAPLE), PlacedFeatures.wouldSurvive(PromenadeBlocks.VERMILION_MAPLE_SAPLING)); - of(registerable, PromenadePlacedFeatures.FANCY_VERMILION_MAPLE, configured.getOrThrow(PromenadeConfiguredFeatures.FANCY_VERMILION_MAPLE), PlacedFeatures.wouldSurvive(PromenadeBlocks.VERMILION_MAPLE_SAPLING)); - of(registerable, PromenadePlacedFeatures.VERMILION_MAPLE_BEES, configured.getOrThrow(PromenadeConfiguredFeatures.VERMILION_MAPLE_BEES), PlacedFeatures.wouldSurvive(PromenadeBlocks.VERMILION_MAPLE_SAPLING)); - of(registerable, PromenadePlacedFeatures.FANCY_VERMILION_MAPLE_BEES, configured.getOrThrow(PromenadeConfiguredFeatures.FANCY_VERMILION_MAPLE_BEES), PlacedFeatures.wouldSurvive(PromenadeBlocks.VERMILION_MAPLE_SAPLING)); + of(registerable, PromenadePlacedFeatures.VERMILION_MAPLE, configured.getOrThrow(PromenadeConfiguredFeatures.VERMILION_MAPLE), PlacementUtils.filteredByBlockSurvival(PromenadeBlocks.VERMILION_MAPLE_SAPLING)); + of(registerable, PromenadePlacedFeatures.FANCY_VERMILION_MAPLE, configured.getOrThrow(PromenadeConfiguredFeatures.FANCY_VERMILION_MAPLE), PlacementUtils.filteredByBlockSurvival(PromenadeBlocks.VERMILION_MAPLE_SAPLING)); + of(registerable, PromenadePlacedFeatures.VERMILION_MAPLE_BEES, configured.getOrThrow(PromenadeConfiguredFeatures.VERMILION_MAPLE_BEES), PlacementUtils.filteredByBlockSurvival(PromenadeBlocks.VERMILION_MAPLE_SAPLING)); + of(registerable, PromenadePlacedFeatures.FANCY_VERMILION_MAPLE_BEES, configured.getOrThrow(PromenadeConfiguredFeatures.FANCY_VERMILION_MAPLE_BEES), PlacementUtils.filteredByBlockSurvival(PromenadeBlocks.VERMILION_MAPLE_SAPLING)); - of(registerable, PromenadePlacedFeatures.FULVOUS_MAPLE, configured.getOrThrow(PromenadeConfiguredFeatures.FULVOUS_MAPLE), PlacedFeatures.wouldSurvive(PromenadeBlocks.FULVOUS_MAPLE_SAPLING)); - of(registerable, PromenadePlacedFeatures.FANCY_FULVOUS_MAPLE, configured.getOrThrow(PromenadeConfiguredFeatures.FANCY_FULVOUS_MAPLE), PlacedFeatures.wouldSurvive(PromenadeBlocks.FULVOUS_MAPLE_SAPLING)); - of(registerable, PromenadePlacedFeatures.FULVOUS_MAPLE_BEES, configured.getOrThrow(PromenadeConfiguredFeatures.FULVOUS_MAPLE_BEES), PlacedFeatures.wouldSurvive(PromenadeBlocks.FULVOUS_MAPLE_SAPLING)); - of(registerable, PromenadePlacedFeatures.FANCY_FULVOUS_MAPLE_BEES, configured.getOrThrow(PromenadeConfiguredFeatures.FANCY_FULVOUS_MAPLE_BEES), PlacedFeatures.wouldSurvive(PromenadeBlocks.FULVOUS_MAPLE_SAPLING)); + of(registerable, PromenadePlacedFeatures.FULVOUS_MAPLE, configured.getOrThrow(PromenadeConfiguredFeatures.FULVOUS_MAPLE), PlacementUtils.filteredByBlockSurvival(PromenadeBlocks.FULVOUS_MAPLE_SAPLING)); + of(registerable, PromenadePlacedFeatures.FANCY_FULVOUS_MAPLE, configured.getOrThrow(PromenadeConfiguredFeatures.FANCY_FULVOUS_MAPLE), PlacementUtils.filteredByBlockSurvival(PromenadeBlocks.FULVOUS_MAPLE_SAPLING)); + of(registerable, PromenadePlacedFeatures.FULVOUS_MAPLE_BEES, configured.getOrThrow(PromenadeConfiguredFeatures.FULVOUS_MAPLE_BEES), PlacementUtils.filteredByBlockSurvival(PromenadeBlocks.FULVOUS_MAPLE_SAPLING)); + of(registerable, PromenadePlacedFeatures.FANCY_FULVOUS_MAPLE_BEES, configured.getOrThrow(PromenadeConfiguredFeatures.FANCY_FULVOUS_MAPLE_BEES), PlacementUtils.filteredByBlockSurvival(PromenadeBlocks.FULVOUS_MAPLE_SAPLING)); - of(registerable, PromenadePlacedFeatures.MIKADO_MAPLE, configured.getOrThrow(PromenadeConfiguredFeatures.MIKADO_MAPLE), PlacedFeatures.wouldSurvive(PromenadeBlocks.MIKADO_MAPLE_SAPLING)); - of(registerable, PromenadePlacedFeatures.FANCY_MIKADO_MAPLE, configured.getOrThrow(PromenadeConfiguredFeatures.FANCY_MIKADO_MAPLE), PlacedFeatures.wouldSurvive(PromenadeBlocks.MIKADO_MAPLE_SAPLING)); - of(registerable, PromenadePlacedFeatures.MIKADO_MAPLE_BEES, configured.getOrThrow(PromenadeConfiguredFeatures.MIKADO_MAPLE_BEES), PlacedFeatures.wouldSurvive(PromenadeBlocks.MIKADO_MAPLE_SAPLING)); - of(registerable, PromenadePlacedFeatures.FANCY_MIKADO_MAPLE_BEES, configured.getOrThrow(PromenadeConfiguredFeatures.FANCY_MIKADO_MAPLE_BEES), PlacedFeatures.wouldSurvive(PromenadeBlocks.MIKADO_MAPLE_SAPLING)); + of(registerable, PromenadePlacedFeatures.MIKADO_MAPLE, configured.getOrThrow(PromenadeConfiguredFeatures.MIKADO_MAPLE), PlacementUtils.filteredByBlockSurvival(PromenadeBlocks.MIKADO_MAPLE_SAPLING)); + of(registerable, PromenadePlacedFeatures.FANCY_MIKADO_MAPLE, configured.getOrThrow(PromenadeConfiguredFeatures.FANCY_MIKADO_MAPLE), PlacementUtils.filteredByBlockSurvival(PromenadeBlocks.MIKADO_MAPLE_SAPLING)); + of(registerable, PromenadePlacedFeatures.MIKADO_MAPLE_BEES, configured.getOrThrow(PromenadeConfiguredFeatures.MIKADO_MAPLE_BEES), PlacementUtils.filteredByBlockSurvival(PromenadeBlocks.MIKADO_MAPLE_SAPLING)); + of(registerable, PromenadePlacedFeatures.FANCY_MIKADO_MAPLE_BEES, configured.getOrThrow(PromenadeConfiguredFeatures.FANCY_MIKADO_MAPLE_BEES), PlacementUtils.filteredByBlockSurvival(PromenadeBlocks.MIKADO_MAPLE_SAPLING)); // Vegetation - var blueberryBush = configured.getOrThrow(PromenadeConfiguredFeatures.BLUEBERRY_BUSH_PATCH); - of(registerable, PromenadePlacedFeatures.BLUEBERRY_BUSH_COMMON_PATCH, blueberryBush, rare(32)); - of(registerable, PromenadePlacedFeatures.BLUEBERRY_BUSH_RARE_PATCH, blueberryBush, rare(384)); - - of(registerable, PromenadePlacedFeatures.SAKURA_GROVE_BAMBOO, configured.getOrThrow(PromenadeConfiguredFeatures.BAMBOO_PATCH), modifiers(NoiseBasedCountPlacementModifier.of(2, 50.0d, 0.1d), PlacedFeatures.WORLD_SURFACE_WG_HEIGHTMAP)); - - of(registerable, PromenadePlacedFeatures.CUTE_LITTLE_ROCKS, configured.getOrThrow(PromenadeConfiguredFeatures.CUTE_LITTLE_ROCK), count(2, PlacedFeatures.MOTION_BLOCKING_HEIGHTMAP)); - - of(registerable, PromenadePlacedFeatures.WATER_POOLS_GRAVEL_DECORATED, configured.getOrThrow(PromenadeConfiguredFeatures.WATER_POOL_GRAVEL_DECORATED), rare(10, PlacedFeatures.MOTION_BLOCKING_HEIGHTMAP)); - - of(registerable, PromenadePlacedFeatures.FREEZE_TOP_LAYER, RegistryEntry.of(new ConfiguredFeature<>(PromenadeFeatures.FREEZE_TOP_LAYER, FeatureConfig.DEFAULT)), BiomePlacementModifier.of()); + var blueberryBush = configured.getOrThrow(PromenadeConfiguredFeatures.BLUEBERRY_BUSH); + of(registerable, PromenadePlacedFeatures.BLUEBERRY_BUSH_COMMON_PATCH, blueberryBush, + RarityFilter.onAverageOnceEvery(32), + InSquarePlacement.spread(), + PlacementUtils.HEIGHTMAP_WORLD_SURFACE, + BiomeFilter.biome(), + CountPlacement.of(96), + RandomOffsetPlacement.ofTriangle(7, 3), + BlockPredicateFilter.forPredicate( + BlockPredicate.allOf(BlockPredicate.ONLY_IN_AIR_PREDICATE, BlockPredicate.matchesBlocks(Direction.DOWN.getUnitVec3i(), Blocks.GRASS_BLOCK)) + ) + ); + of(registerable, PromenadePlacedFeatures.BLUEBERRY_BUSH_RARE_PATCH, blueberryBush, + RarityFilter.onAverageOnceEvery(384), + InSquarePlacement.spread(), + PlacementUtils.HEIGHTMAP_WORLD_SURFACE, + BiomeFilter.biome(), + CountPlacement.of(96), + RandomOffsetPlacement.ofTriangle(7, 3), + BlockPredicateFilter.forPredicate( + BlockPredicate.allOf(BlockPredicate.ONLY_IN_AIR_PREDICATE, BlockPredicate.matchesBlocks(Direction.DOWN.getUnitVec3i(), Blocks.GRASS_BLOCK)) + ) + ); + + of(registerable, PromenadePlacedFeatures.SAKURA_GROVE_BAMBOO, configured.getOrThrow(VegetationFeatures.BAMBOO_SOME_PODZOL), + NoiseBasedCountPlacement.of(2, 50.0, 0.1), + InSquarePlacement.spread(), + PlacementUtils.HEIGHTMAP_WORLD_SURFACE, + BiomeFilter.biome(), + CountPlacement.of(25), + RandomOffsetPlacement.ofTriangle(7, 3), + BlockPredicateFilter.forPredicate(BlockPredicate.ONLY_IN_AIR_PREDICATE) + ); + + of(registerable, PromenadePlacedFeatures.CUTE_LITTLE_ROCKS, configured.getOrThrow(PromenadeConfiguredFeatures.CUTE_LITTLE_ROCK), count(2, PlacementUtils.HEIGHTMAP)); + + of(registerable, PromenadePlacedFeatures.WATER_POOLS_GRAVEL_DECORATED, configured.getOrThrow(PromenadeConfiguredFeatures.WATER_POOL_GRAVEL_DECORATED), rare(10, PlacementUtils.HEIGHTMAP)); + + of(registerable, PromenadePlacedFeatures.FREEZE_TOP_LAYER, Holder.direct(new ConfiguredFeature<>(PromenadeFeatures.FREEZE_TOP_LAYER, FeatureConfiguration.NONE)), BiomeFilter.biome()); of(registerable, PromenadePlacedFeatures.DARK_AMARANTH_FOREST_VEGETATION, configured.getOrThrow(PromenadeConfiguredFeatures.DARK_AMARANTH_FOREST_VEGETATION), netherCount(6)); @@ -114,81 +144,91 @@ public static void register(Registerable registerable) { of(registerable, PromenadePlacedFeatures.FALLEN_FULVOUS_MAPLE_LEAVES, configured.getOrThrow(PromenadeConfiguredFeatures.FALLEN_FULVOUS_MAPLE_LEAVES)); of(registerable, PromenadePlacedFeatures.FALLEN_MIKADO_MAPLE_LEAVES, configured.getOrThrow(PromenadeConfiguredFeatures.FALLEN_MIKADO_MAPLE_LEAVES)); - of(registerable, PromenadePlacedFeatures.COILED_VINES, configured.getOrThrow(PromenadeConfiguredFeatures.COILED_VINES), CountPlacementModifier.of(10), SquarePlacementModifier.of(), PlacedFeatures.BOTTOM_TO_TOP_RANGE, BiomePlacementModifier.of()); + of(registerable, PromenadePlacedFeatures.COILED_VINES, configured.getOrThrow(PromenadeConfiguredFeatures.COILED_VINES), CountPlacement.of(10), InSquarePlacement.spread(), PlacementUtils.FULL_RANGE, BiomeFilter.biome()); // Tree groups of(registerable, PromenadePlacedFeatures.BLUSH_SAKURA_GROVE_TREES, configured.getOrThrow(PromenadeConfiguredFeatures.BLUSH_SAKURA_GROVE_TREE), - treeModifiers(PlacedFeatures.createCountExtraModifier(2, 0.1F, 1))); + treeModifiers(PlacementUtils.countExtra(2, 0.1F, 1))); of(registerable, PromenadePlacedFeatures.COTTON_SAKURA_GROVE_TREES, configured.getOrThrow(PromenadeConfiguredFeatures.COTTON_SAKURA_GROVE_TREE), - treeModifiers(PlacedFeatures.createCountExtraModifier(2, 0.1F, 1))); + treeModifiers(PlacementUtils.countExtra(2, 0.1F, 1))); - of(registerable, PromenadePlacedFeatures.CARNELIAN_TREEWAY_TREES, configured.getOrThrow(PromenadeConfiguredFeatures.CARNELIAN_TREEWAY_TREE), treeModifiers(PlacedFeatures.createCountExtraModifier(10, 0.1F, 1))); - of(registerable, PromenadePlacedFeatures.CARNELIAN_TREEWAY_FALLEN_LEAVES, configured.getOrThrow(PromenadeConfiguredFeatures.CARNELIAN_TREEWAY_FALLEN_LEAVES), count(25)); + of(registerable, PromenadePlacedFeatures.CARNELIAN_TREEWAY_TREES, configured.getOrThrow(PromenadeConfiguredFeatures.CARNELIAN_TREEWAY_TREE), treeModifiers(PlacementUtils.countExtra(10, 0.1F, 1))); + of(registerable, PromenadePlacedFeatures.CARNELIAN_TREEWAY_FALLEN_LEAVES, configured.getOrThrow(PromenadeConfiguredFeatures.CARNELIAN_TREEWAY_FALLEN_LEAVES), + Util.copyAndAdd( + worldSurfaceSquaredWithCount(20), + CountPlacement.of(32), + RandomOffsetPlacement.ofTriangle(7, 3), + BlockPredicateFilter.forPredicate(BlockPredicate.ONLY_IN_AIR_PREDICATE) + )); - of(registerable, PromenadePlacedFeatures.GLACARIAN_TAIGA_TREES, configured.getOrThrow(PromenadeConfiguredFeatures.SNOWY_MEGA_SPRUCE), treeModifiersWithWouldSurvive(PlacedFeatures.createCountExtraModifier(14, 0.1F, 4), Blocks.SPRUCE_SAPLING)); + of(registerable, PromenadePlacedFeatures.GLACARIAN_TAIGA_TREES, configured.getOrThrow(PromenadeConfiguredFeatures.SNOWY_MEGA_SPRUCE), treeModifiersWithWouldSurvive(PlacementUtils.countExtra(14, 0.1F, 4), Blocks.SPRUCE_SAPLING)); - of(registerable, PromenadePlacedFeatures.PALMS, configured.getOrThrow(PromenadeConfiguredFeatures.PALM), treeModifiersWithWouldSurvive(PlacedFeatures.createCountExtraModifier(0, 0.1F, 1), PromenadeBlocks.PALM_SAPLING)); + of(registerable, PromenadePlacedFeatures.PALMS, configured.getOrThrow(PromenadeConfiguredFeatures.PALM), treeModifiersWithWouldSurvive(PlacementUtils.countExtra(0, 0.1F, 1), PromenadeBlocks.PALM_SAPLING)); of(registerable, PromenadePlacedFeatures.DARK_AMARANTH_FUNGI, configured.getOrThrow(PromenadeConfiguredFeatures.DARK_AMARANTH_FUNGUS), netherCount(8)); } + public static List worldSurfaceSquaredWithCount(final int count) { + return List.of(CountPlacement.of(count), InSquarePlacement.spread(), PlacementUtils.HEIGHTMAP_WORLD_SURFACE, BiomeFilter.biome()); + } + public static List rare(int chance) { - return rare(chance, PlacedFeatures.WORLD_SURFACE_WG_HEIGHTMAP); + return rare(chance, PlacementUtils.HEIGHTMAP_WORLD_SURFACE); } public static List rare(int chance, PlacementModifier heightModifier) { - return modifiers(RarityFilterPlacementModifier.of(chance), heightModifier); + return modifiers(RarityFilter.onAverageOnceEvery(chance), heightModifier); } public static List count(int count) { - return count(count, PlacedFeatures.WORLD_SURFACE_WG_HEIGHTMAP); + return count(count, PlacementUtils.HEIGHTMAP_WORLD_SURFACE); } public static List count(int count, PlacementModifier heightModifier) { - return modifiers(CountPlacementModifier.of(count), heightModifier); + return modifiers(CountPlacement.of(count), heightModifier); } public static List netherCount(int count) { - return List.of(CountMultilayerPlacementModifier.of(count), BiomePlacementModifier.of()); + return List.of(CountOnEveryLayerPlacement.of(count), BiomeFilter.biome()); } private static List modifiers(PlacementModifier countModifier, PlacementModifier heightModifier) { - return List.of(countModifier, SquarePlacementModifier.of(), heightModifier, BiomePlacementModifier.of()); + return List.of(countModifier, InSquarePlacement.spread(), heightModifier, BiomeFilter.biome()); } private static List modifiersWithCount(int count, PlacementModifier heightModifier) { - return modifiers(CountPlacementModifier.of(count), heightModifier); + return modifiers(CountPlacement.of(count), heightModifier); } private static List modifiersWithRarity(int chance, PlacementModifier heightModifier) { - return modifiers(RarityFilterPlacementModifier.of(chance), heightModifier); + return modifiers(RarityFilter.onAverageOnceEvery(chance), heightModifier); } private static ImmutableList.Builder treeModifiersBuilder(PlacementModifier countModifier) { return ImmutableList.builder() .add(countModifier) - .add(SquarePlacementModifier.of()) + .add(InSquarePlacement.spread()) .add(NOT_IN_SURFACE_WATER_MODIFIER) - .add(PlacedFeatures.OCEAN_FLOOR_HEIGHTMAP) - .add(BiomePlacementModifier.of()); + .add(PlacementUtils.HEIGHTMAP_OCEAN_FLOOR) + .add(BiomeFilter.biome()); } public static List treeModifiersWithNoiseInterval(PlacementModifier countModifier, float noiseMin, float noiseMax) { return ImmutableList.builder() .add(countModifier) - .add(SquarePlacementModifier.of()) + .add(InSquarePlacement.spread()) .add(NoiseIntervalCountPlacementModifier.of(noiseMin, noiseMax, 1, 0)) .add(NOT_IN_SURFACE_WATER_MODIFIER) - .add(PlacedFeatures.OCEAN_FLOOR_HEIGHTMAP) - .add(BiomePlacementModifier.of()) + .add(PlacementUtils.HEIGHTMAP_OCEAN_FLOOR) + .add(BiomeFilter.biome()) .build(); } public static List treeModifiersWithWouldSurvive(PlacementModifier modifier, Block block) { - return treeModifiersBuilder(modifier).add(BlockFilterPlacementModifier.of(BlockPredicate.wouldSurvive(block.getDefaultState(), BlockPos.ORIGIN))).build(); + return treeModifiersBuilder(modifier).add(BlockPredicateFilter.forPredicate(BlockPredicate.wouldSurvive(block.defaultBlockState(), BlockPos.ZERO))).build(); } public static List treeModifiers(PlacementModifier modifier) { @@ -196,20 +236,20 @@ public static List treeModifiers(PlacementModifier modifier) } public static void of( - Registerable featureRegisterable, - RegistryKey key, - RegistryEntry> feature, + BootstrapContext featureRegisterable, + ResourceKey key, + Holder> feature, List modifiers ) { - PlacedFeatures.register(featureRegisterable, key, feature, modifiers); + PlacementUtils.register(featureRegisterable, key, feature, modifiers); } public static void of( - Registerable featureRegisterable, - RegistryKey key, - RegistryEntry> feature, + BootstrapContext featureRegisterable, + ResourceKey key, + Holder> feature, PlacementModifier... modifiers ) { - PlacedFeatures.register(featureRegisterable, key, feature, modifiers); + PlacementUtils.register(featureRegisterable, key, feature, modifiers); } } \ No newline at end of file diff --git a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeRecipeGenerator.java b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeRecipeGenerator.java index 5a5d8637..0249a00f 100644 --- a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeRecipeGenerator.java +++ b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeRecipeGenerator.java @@ -4,48 +4,48 @@ import fr.hugman.promenade.data.PromenadeBlockFamilies; import fr.hugman.promenade.item.PromenadeItems; import fr.hugman.promenade.tag.PromenadeItemTags; -import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; +import net.fabricmc.fabric.api.datagen.v1.FabricPackOutput; import net.fabricmc.fabric.api.datagen.v1.provider.FabricRecipeProvider; -import net.minecraft.block.Blocks; -import net.minecraft.data.family.BlockFamily; -import net.minecraft.data.recipe.RecipeExporter; -import net.minecraft.data.recipe.RecipeGenerator; -import net.minecraft.item.ItemConvertible; -import net.minecraft.item.Items; -import net.minecraft.recipe.*; -import net.minecraft.recipe.book.RecipeCategory; -import net.minecraft.registry.RegistryWrapper; -import net.minecraft.resource.featuretoggle.FeatureFlags; -import net.minecraft.resource.featuretoggle.FeatureSet; +import net.minecraft.core.HolderLookup; +import net.minecraft.data.recipes.RecipeCategory; +import net.minecraft.data.recipes.RecipeOutput; +import net.minecraft.data.recipes.RecipeProvider; +import net.minecraft.data.recipes.SimpleCookingRecipeBuilder; +import net.minecraft.world.flag.FeatureFlagSet; +import net.minecraft.world.flag.FeatureFlags; +import net.minecraft.world.item.Items; +import net.minecraft.world.item.crafting.*; +import net.minecraft.world.level.ItemLike; +import net.minecraft.world.level.block.Blocks; import java.util.concurrent.CompletableFuture; -public class PromenadeRecipeGenerator extends RecipeGenerator { - public PromenadeRecipeGenerator(RegistryWrapper.WrapperLookup registries, RecipeExporter exporter) { +public class PromenadeRecipeGenerator extends RecipeProvider { + public PromenadeRecipeGenerator(HolderLookup.Provider registries, RecipeOutput exporter) { super(registries, exporter); } @Override - public void generate() { - PromenadeBlockFamilies.getFamilies().filter(BlockFamily::shouldGenerateRecipes).forEach(family -> this.generateFamily(family, FeatureSet.of(FeatureFlags.VANILLA))); - - this.offerStonecuttingRecipe(RecipeCategory.BUILDING_BLOCKS, PromenadeBlocks.ASPHALT_SLAB, PromenadeBlocks.ASPHALT, 2); - this.offerStonecuttingRecipe(RecipeCategory.BUILDING_BLOCKS, PromenadeBlocks.ASPHALT_STAIRS, PromenadeBlocks.ASPHALT); - this.offerStonecuttingRecipe(RecipeCategory.DECORATIONS, PromenadeBlocks.ASPHALT_WALL, PromenadeBlocks.ASPHALT); - this.offerStonecuttingRecipe(RecipeCategory.BUILDING_BLOCKS, PromenadeBlocks.POLISHED_ASPHALT, PromenadeBlocks.ASPHALT); - this.offerStonecuttingRecipe(RecipeCategory.BUILDING_BLOCKS, PromenadeBlocks.POLISHED_ASPHALT_SLAB, PromenadeBlocks.ASPHALT, 2); - this.offerStonecuttingRecipe(RecipeCategory.BUILDING_BLOCKS, PromenadeBlocks.POLISHED_ASPHALT_STAIRS, PromenadeBlocks.ASPHALT); - this.offerStonecuttingRecipe(RecipeCategory.BUILDING_BLOCKS, PromenadeBlocks.POLISHED_ASPHALT_SLAB, PromenadeBlocks.POLISHED_ASPHALT, 2); - this.offerStonecuttingRecipe(RecipeCategory.BUILDING_BLOCKS, PromenadeBlocks.POLISHED_ASPHALT_STAIRS, PromenadeBlocks.POLISHED_ASPHALT); - - this.offerStonecuttingRecipe(RecipeCategory.BUILDING_BLOCKS, PromenadeBlocks.BLUNITE_SLAB, PromenadeBlocks.BLUNITE, 2); - this.offerStonecuttingRecipe(RecipeCategory.BUILDING_BLOCKS, PromenadeBlocks.BLUNITE_STAIRS, PromenadeBlocks.BLUNITE); - this.offerStonecuttingRecipe(RecipeCategory.DECORATIONS, PromenadeBlocks.BLUNITE_WALL, PromenadeBlocks.BLUNITE); - this.offerStonecuttingRecipe(RecipeCategory.BUILDING_BLOCKS, PromenadeBlocks.POLISHED_BLUNITE, PromenadeBlocks.BLUNITE); - this.offerStonecuttingRecipe(RecipeCategory.BUILDING_BLOCKS, PromenadeBlocks.POLISHED_BLUNITE_SLAB, PromenadeBlocks.BLUNITE, 2); - this.offerStonecuttingRecipe(RecipeCategory.BUILDING_BLOCKS, PromenadeBlocks.POLISHED_BLUNITE_STAIRS, PromenadeBlocks.BLUNITE); - this.offerStonecuttingRecipe(RecipeCategory.BUILDING_BLOCKS, PromenadeBlocks.POLISHED_BLUNITE_SLAB, PromenadeBlocks.POLISHED_BLUNITE, 2); - this.offerStonecuttingRecipe(RecipeCategory.BUILDING_BLOCKS, PromenadeBlocks.POLISHED_BLUNITE_STAIRS, PromenadeBlocks.POLISHED_BLUNITE); + public void buildRecipes() { + PromenadeBlockFamilies.getFamilies().forEach(family -> this.generateRecipes(family, FeatureFlagSet.of(FeatureFlags.VANILLA))); + + this.stonecutterResultFromBase(RecipeCategory.BUILDING_BLOCKS, PromenadeBlocks.ASPHALT_SLAB, PromenadeBlocks.ASPHALT, 2); + this.stonecutterResultFromBase(RecipeCategory.BUILDING_BLOCKS, PromenadeBlocks.ASPHALT_STAIRS, PromenadeBlocks.ASPHALT); + this.stonecutterResultFromBase(RecipeCategory.DECORATIONS, PromenadeBlocks.ASPHALT_WALL, PromenadeBlocks.ASPHALT); + this.stonecutterResultFromBase(RecipeCategory.BUILDING_BLOCKS, PromenadeBlocks.POLISHED_ASPHALT, PromenadeBlocks.ASPHALT); + this.stonecutterResultFromBase(RecipeCategory.BUILDING_BLOCKS, PromenadeBlocks.POLISHED_ASPHALT_SLAB, PromenadeBlocks.ASPHALT, 2); + this.stonecutterResultFromBase(RecipeCategory.BUILDING_BLOCKS, PromenadeBlocks.POLISHED_ASPHALT_STAIRS, PromenadeBlocks.ASPHALT); + this.stonecutterResultFromBase(RecipeCategory.BUILDING_BLOCKS, PromenadeBlocks.POLISHED_ASPHALT_SLAB, PromenadeBlocks.POLISHED_ASPHALT, 2); + this.stonecutterResultFromBase(RecipeCategory.BUILDING_BLOCKS, PromenadeBlocks.POLISHED_ASPHALT_STAIRS, PromenadeBlocks.POLISHED_ASPHALT); + + this.stonecutterResultFromBase(RecipeCategory.BUILDING_BLOCKS, PromenadeBlocks.BLUNITE_SLAB, PromenadeBlocks.BLUNITE, 2); + this.stonecutterResultFromBase(RecipeCategory.BUILDING_BLOCKS, PromenadeBlocks.BLUNITE_STAIRS, PromenadeBlocks.BLUNITE); + this.stonecutterResultFromBase(RecipeCategory.DECORATIONS, PromenadeBlocks.BLUNITE_WALL, PromenadeBlocks.BLUNITE); + this.stonecutterResultFromBase(RecipeCategory.BUILDING_BLOCKS, PromenadeBlocks.POLISHED_BLUNITE, PromenadeBlocks.BLUNITE); + this.stonecutterResultFromBase(RecipeCategory.BUILDING_BLOCKS, PromenadeBlocks.POLISHED_BLUNITE_SLAB, PromenadeBlocks.BLUNITE, 2); + this.stonecutterResultFromBase(RecipeCategory.BUILDING_BLOCKS, PromenadeBlocks.POLISHED_BLUNITE_STAIRS, PromenadeBlocks.BLUNITE); + this.stonecutterResultFromBase(RecipeCategory.BUILDING_BLOCKS, PromenadeBlocks.POLISHED_BLUNITE_SLAB, PromenadeBlocks.POLISHED_BLUNITE, 2); + this.stonecutterResultFromBase(RecipeCategory.BUILDING_BLOCKS, PromenadeBlocks.POLISHED_BLUNITE_STAIRS, PromenadeBlocks.POLISHED_BLUNITE); this.offerLeafPileRecipe(PromenadeBlocks.OAK_LEAF_PILE, Blocks.OAK_LEAVES); this.offerLeafPileRecipe(PromenadeBlocks.SPRUCE_LEAF_PILE, Blocks.SPRUCE_LEAVES); @@ -85,23 +85,23 @@ public void generate() { this.offerSnowyLeavesRecipe(PromenadeBlocks.SNOWY_AZALEA_LEAVES, Blocks.AZALEA_LEAVES); this.offerSnowyLeavesRecipe(PromenadeBlocks.SNOWY_FLOWERING_AZALEA_LEAVES, Blocks.FLOWERING_AZALEA_LEAVES); - this.offerPlanksRecipe(PromenadeBlocks.SAKURA_PLANKS, PromenadeItemTags.SAKURA_LOGS, 4); - this.offerBarkBlockRecipe(PromenadeBlocks.SAKURA_WOOD, PromenadeBlocks.SAKURA_LOG); - this.offerBarkBlockRecipe(PromenadeBlocks.STRIPPED_SAKURA_WOOD, PromenadeBlocks.STRIPPED_SAKURA_LOG); - this.offerHangingSignRecipe(PromenadeItems.SAKURA_HANGING_SIGN, PromenadeBlocks.STRIPPED_SAKURA_LOG); - this.offerShelfRecipe(PromenadeBlocks.SAKURA_SHELF, PromenadeBlocks.STRIPPED_SAKURA_LOG); + this.planksFromLogs(PromenadeBlocks.SAKURA_PLANKS, PromenadeItemTags.SAKURA_LOGS, 4); + this.woodFromLogs(PromenadeBlocks.SAKURA_WOOD, PromenadeBlocks.SAKURA_LOG); + this.woodFromLogs(PromenadeBlocks.STRIPPED_SAKURA_WOOD, PromenadeBlocks.STRIPPED_SAKURA_LOG); + this.hangingSign(PromenadeItems.SAKURA_HANGING_SIGN, PromenadeBlocks.STRIPPED_SAKURA_LOG); + this.shelf(PromenadeBlocks.SAKURA_SHELF, PromenadeBlocks.STRIPPED_SAKURA_LOG); this.offerSnowyLeavesRecipe(PromenadeBlocks.SNOWY_BLUSH_SAKURA_BLOSSOMS, PromenadeBlocks.BLUSH_SAKURA_BLOSSOMS); this.offerSnowyLeavesRecipe(PromenadeBlocks.SNOWY_COTTON_SAKURA_BLOSSOMS, PromenadeBlocks.COTTON_SAKURA_BLOSSOMS); this.offerLeafPileRecipe(PromenadeBlocks.BLUSH_SAKURA_BLOSSOM_PILE, PromenadeBlocks.BLUSH_SAKURA_BLOSSOM_PILE); this.offerLeafPileRecipe(PromenadeBlocks.COTTON_SAKURA_BLOSSOM_PILE, PromenadeBlocks.COTTON_SAKURA_BLOSSOM_PILE); - this.offerBoatRecipe(PromenadeItems.SAKURA_BOAT, PromenadeBlocks.SAKURA_PLANKS); - this.offerChestBoatRecipe(PromenadeItems.SAKURA_CHEST_BOAT, PromenadeItems.SAKURA_BOAT); - - this.offerPlanksRecipe(PromenadeBlocks.MAPLE_PLANKS, PromenadeItemTags.MAPLE_LOGS, 4); - this.offerBarkBlockRecipe(PromenadeBlocks.MAPLE_WOOD, PromenadeBlocks.MAPLE_LOG); - this.offerBarkBlockRecipe(PromenadeBlocks.STRIPPED_MAPLE_WOOD, PromenadeBlocks.STRIPPED_MAPLE_LOG); - this.offerHangingSignRecipe(PromenadeItems.MAPLE_HANGING_SIGN, PromenadeBlocks.STRIPPED_MAPLE_LOG); - this.offerShelfRecipe(PromenadeBlocks.MAPLE_SHELF, PromenadeBlocks.STRIPPED_MAPLE_LOG); + this.woodenBoat(PromenadeItems.SAKURA_BOAT, PromenadeBlocks.SAKURA_PLANKS); + this.chestBoat(PromenadeItems.SAKURA_CHEST_BOAT, PromenadeItems.SAKURA_BOAT); + + this.planksFromLogs(PromenadeBlocks.MAPLE_PLANKS, PromenadeItemTags.MAPLE_LOGS, 4); + this.woodFromLogs(PromenadeBlocks.MAPLE_WOOD, PromenadeBlocks.MAPLE_LOG); + this.woodFromLogs(PromenadeBlocks.STRIPPED_MAPLE_WOOD, PromenadeBlocks.STRIPPED_MAPLE_LOG); + this.hangingSign(PromenadeItems.MAPLE_HANGING_SIGN, PromenadeBlocks.STRIPPED_MAPLE_LOG); + this.shelf(PromenadeBlocks.MAPLE_SHELF, PromenadeBlocks.STRIPPED_MAPLE_LOG); this.offerSnowyLeavesRecipe(PromenadeBlocks.SNOWY_SAP_MAPLE_LEAVES, PromenadeBlocks.SAP_MAPLE_LEAVES); this.offerSnowyLeavesRecipe(PromenadeBlocks.SNOWY_VERMILION_MAPLE_LEAVES, PromenadeBlocks.VERMILION_MAPLE_LEAVES); this.offerSnowyLeavesRecipe(PromenadeBlocks.SNOWY_FULVOUS_MAPLE_LEAVES, PromenadeBlocks.FULVOUS_MAPLE_LEAVES); @@ -114,90 +114,88 @@ public void generate() { this.offerLeafPileRecipe(PromenadeBlocks.VERMILION_MAPLE_LEAF_PILE, PromenadeBlocks.VERMILION_MAPLE_LEAF_PILE); this.offerLeafPileRecipe(PromenadeBlocks.FULVOUS_MAPLE_LEAF_PILE, PromenadeBlocks.FULVOUS_MAPLE_LEAVES); this.offerLeafPileRecipe(PromenadeBlocks.MIKADO_MAPLE_LEAF_PILE, PromenadeBlocks.MIKADO_MAPLE_LEAVES); - this.offerBoatRecipe(PromenadeItems.MAPLE_BOAT, PromenadeBlocks.MAPLE_PLANKS); - this.offerChestBoatRecipe(PromenadeItems.MAPLE_CHEST_BOAT, PromenadeItems.MAPLE_BOAT); - - this.offerPlanksRecipe(PromenadeBlocks.PALM_PLANKS, PromenadeItemTags.PALM_LOGS, 4); - this.offerBarkBlockRecipe(PromenadeBlocks.PALM_WOOD, PromenadeBlocks.PALM_LOG); - this.offerBarkBlockRecipe(PromenadeBlocks.STRIPPED_PALM_WOOD, PromenadeBlocks.STRIPPED_PALM_LOG); - this.offerHangingSignRecipe(PromenadeItems.PALM_HANGING_SIGN, PromenadeBlocks.STRIPPED_PALM_LOG); - this.offerShelfRecipe(PromenadeBlocks.PALM_SHELF, PromenadeBlocks.STRIPPED_PALM_LOG); + this.woodenBoat(PromenadeItems.MAPLE_BOAT, PromenadeBlocks.MAPLE_PLANKS); + this.chestBoat(PromenadeItems.MAPLE_CHEST_BOAT, PromenadeItems.MAPLE_BOAT); + + this.planksFromLogs(PromenadeBlocks.PALM_PLANKS, PromenadeItemTags.PALM_LOGS, 4); + this.woodFromLogs(PromenadeBlocks.PALM_WOOD, PromenadeBlocks.PALM_LOG); + this.woodFromLogs(PromenadeBlocks.STRIPPED_PALM_WOOD, PromenadeBlocks.STRIPPED_PALM_LOG); + this.hangingSign(PromenadeItems.PALM_HANGING_SIGN, PromenadeBlocks.STRIPPED_PALM_LOG); + this.shelf(PromenadeBlocks.PALM_SHELF, PromenadeBlocks.STRIPPED_PALM_LOG); this.offerSnowyLeavesRecipe(PromenadeBlocks.SNOWY_PALM_LEAVES, PromenadeBlocks.PALM_LEAVES); this.offerLeafPileRecipe(PromenadeBlocks.PALM_LEAF_PILE, PromenadeBlocks.PALM_LEAVES); - this.offerBoatRecipe(PromenadeItems.PALM_BOAT, PromenadeBlocks.PALM_PLANKS); - this.offerChestBoatRecipe(PromenadeItems.PALM_CHEST_BOAT, PromenadeItems.PALM_BOAT); + this.woodenBoat(PromenadeItems.PALM_BOAT, PromenadeBlocks.PALM_PLANKS); + this.chestBoat(PromenadeItems.PALM_CHEST_BOAT, PromenadeItems.PALM_BOAT); - this.offerPlanksRecipe(PromenadeBlocks.DARK_AMARANTH_PLANKS, PromenadeItemTags.DARK_AMARANTH_STEMS, 4); - this.offerBarkBlockRecipe(PromenadeBlocks.DARK_AMARANTH_HYPHAE, PromenadeBlocks.DARK_AMARANTH_STEM); - this.offerBarkBlockRecipe(PromenadeBlocks.STRIPPED_DARK_AMARANTH_HYPHAE, PromenadeBlocks.STRIPPED_DARK_AMARANTH_STEM); - this.offerHangingSignRecipe(PromenadeItems.DARK_AMARANTH_HANGING_SIGN, PromenadeBlocks.STRIPPED_DARK_AMARANTH_STEM); - this.offerShelfRecipe(PromenadeBlocks.DARK_AMARANTH_SHELF, PromenadeBlocks.STRIPPED_DARK_AMARANTH_STEM); + this.planksFromLogs(PromenadeBlocks.DARK_AMARANTH_PLANKS, PromenadeItemTags.DARK_AMARANTH_STEMS, 4); + this.woodFromLogs(PromenadeBlocks.DARK_AMARANTH_HYPHAE, PromenadeBlocks.DARK_AMARANTH_STEM); + this.woodFromLogs(PromenadeBlocks.STRIPPED_DARK_AMARANTH_HYPHAE, PromenadeBlocks.STRIPPED_DARK_AMARANTH_STEM); + this.hangingSign(PromenadeItems.DARK_AMARANTH_HANGING_SIGN, PromenadeBlocks.STRIPPED_DARK_AMARANTH_STEM); + this.shelf(PromenadeBlocks.DARK_AMARANTH_SHELF, PromenadeBlocks.STRIPPED_DARK_AMARANTH_STEM); - this.offerStonecuttingRecipe(RecipeCategory.BUILDING_BLOCKS, PromenadeBlocks.MOAI, Blocks.TUFF); + this.stonecutterResultFromBase(RecipeCategory.BUILDING_BLOCKS, PromenadeBlocks.MOAI, Blocks.TUFF); - this.generateCookingRecipes("smelting", RecipeSerializer.SMELTING, SmeltingRecipe::new, 200); - this.generateCookingRecipes("smoking", RecipeSerializer.SMOKING, SmokingRecipe::new, 100); - this.generateCookingRecipes("campfire_cooking", RecipeSerializer.CAMPFIRE_COOKING, CampfireCookingRecipe::new, 600); + this.cookRecipes("smelting", SmeltingRecipe::new, 200); + this.cookRecipes("smoking", CampfireCookingRecipe::new, 100); + this.cookRecipes("campfire_cooking", CampfireCookingRecipe::new, 600); - this.offerShapelessRecipe(Items.MAGENTA_DYE, PromenadeItems.BLUEBERRIES, "magenta_dye", 1); + this.oneToOneConversionRecipe(Items.MAGENTA_DYE, PromenadeItems.BLUEBERRIES, "magenta_dye", 1); - this.createShapeless(RecipeCategory.MISC, PromenadeItems.BOVINE_BANNER_PATTERN) - .input(Items.PAPER) - .input(Items.LEATHER) - .criterion("has_leather", this.conditionsFromItem(Items.LEATHER)) - .offerTo(this.exporter); + this.shapeless(RecipeCategory.MISC, PromenadeItems.BOVINE_BANNER_PATTERN) + .requires(Items.PAPER) + .requires(Items.LEATHER) + .unlockedBy("has_leather", this.has(Items.LEATHER)) + .save(this.output); } - public void offerSnowyLeavesRecipe(ItemConvertible output, ItemConvertible input) { - this.createShaped(RecipeCategory.DECORATIONS, output, 1) - .input('_', Blocks.SNOW) - .input('#', input) + public void offerSnowyLeavesRecipe(ItemLike output, ItemLike input) { + this.shaped(RecipeCategory.DECORATIONS, output, 1) + .define('_', Blocks.SNOW) + .define('#', input) .pattern("_") .pattern("#") .group("snowy_leaves") - .criterion(hasItem(input), this.conditionsFromItem(input)) - .offerTo(this.exporter); + .unlockedBy(getHasName(input), this.has(input)) + .save(this.output); } - public void offerFallenLeavesRecipe(ItemConvertible output, ItemConvertible input) { - this.createShaped(RecipeCategory.DECORATIONS, output, 2) - .input('#', input) + public void offerFallenLeavesRecipe(ItemLike output, ItemLike input) { + this.shaped(RecipeCategory.DECORATIONS, output, 2) + .define('#', input) .pattern("##") .group("fallen_leaves") - .criterion(hasItem(input), this.conditionsFromItem(input)) - .offerTo(this.exporter); + .unlockedBy(getHasName(input), this.has(input)) + .save(this.output); } - public void offerLeafPileRecipe(ItemConvertible output, ItemConvertible input) { - this.createShaped(RecipeCategory.DECORATIONS, output, 3) - .input('#', input) + public void offerLeafPileRecipe(ItemLike output, ItemLike input) { + this.shaped(RecipeCategory.DECORATIONS, output, 3) + .define('#', input) .pattern("###") .group("leaf_pile") - .criterion(hasItem(input), this.conditionsFromItem(input)) - .offerTo(this.exporter); + .unlockedBy(getHasName(input), this.has(input)) + .save(this.output); } - public void offerFlowerPileRecipe(ItemConvertible output, ItemConvertible input) { - this.createShaped(RecipeCategory.DECORATIONS, output, 2) - .input('#', input) + public void offerFlowerPileRecipe(ItemLike output, ItemLike input) { + this.shaped(RecipeCategory.DECORATIONS, output, 2) + .define('#', input) .pattern("##") .group("flower_pile") - .criterion(hasItem(input), this.conditionsFromItem(input)) - .offerTo(this.exporter); + .unlockedBy(getHasName(input), this.has(input)) + .save(this.output); } - public void generateCookingRecipes( - String cooker, RecipeSerializer serializer, AbstractCookingRecipe.RecipeFactory recipeFactory, int cookingTime - ) { - this.offerFoodCookingRecipe(cooker, serializer, recipeFactory, cookingTime, PromenadeItems.DUCK, PromenadeItems.COOKED_DUCK, 0.35F); + public void cookRecipes(final String source, final AbstractCookingRecipe.Factory factory, final int cookingTime) { + this.simpleCookingRecipe(source, factory, cookingTime, PromenadeItems.DUCK, PromenadeItems.COOKED_DUCK, 0.35F); } - public static FabricRecipeProvider create(FabricDataOutput fabricDataOutput, CompletableFuture completableFuture) { + public static FabricRecipeProvider create(FabricPackOutput fabricDataOutput, CompletableFuture completableFuture) { return new FabricRecipeProvider(fabricDataOutput, completableFuture) { @Override - protected RecipeGenerator getRecipeGenerator(RegistryWrapper.WrapperLookup wrapperLookup, RecipeExporter recipeExporter) { + protected RecipeProvider createRecipeProvider(HolderLookup.Provider wrapperLookup, RecipeOutput recipeExporter) { return new PromenadeRecipeGenerator(wrapperLookup, recipeExporter); } diff --git a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeSnowyBlockTransformationProvider.java b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeSnowyBlockTransformationProvider.java index 64506d6c..3f20ea12 100644 --- a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeSnowyBlockTransformationProvider.java +++ b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeSnowyBlockTransformationProvider.java @@ -4,26 +4,26 @@ import fr.hugman.promenade.block.PromenadeBlocks; import fr.hugman.promenade.block.snowy.SnowyBlockTransformation; import fr.hugman.promenade.registry.PromenadeRegistryKeys; -import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; +import net.fabricmc.fabric.api.datagen.v1.FabricPackOutput; import net.fabricmc.fabric.api.datagen.v1.provider.FabricDynamicRegistryProvider; -import net.minecraft.block.Block; -import net.minecraft.block.Blocks; -import net.minecraft.registry.Registerable; -import net.minecraft.registry.Registries; -import net.minecraft.registry.RegistryKey; -import net.minecraft.registry.RegistryWrapper; +import net.minecraft.core.HolderLookup; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.data.worldgen.BootstrapContext; +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; import java.util.concurrent.CompletableFuture; //TODO: a generic class for other devs public class PromenadeSnowyBlockTransformationProvider extends FabricDynamicRegistryProvider { - public PromenadeSnowyBlockTransformationProvider(FabricDataOutput output, CompletableFuture registriesFuture) { + public PromenadeSnowyBlockTransformationProvider(FabricPackOutput output, CompletableFuture registriesFuture) { super(output, registriesFuture); } @Override - protected void configure(RegistryWrapper.WrapperLookup registries, Entries entries) { - entries.addAll(registries.getOrThrow(PromenadeRegistryKeys.SNOWY_BLOCK_TRANSFORMATION)); + protected void configure(HolderLookup.Provider registries, Entries entries) { + entries.addAll(registries.lookupOrThrow(PromenadeRegistryKeys.SNOWY_BLOCK_TRANSFORMATION)); } @Override @@ -31,7 +31,7 @@ public String getName() { return "Snowy Block Transformations"; } - public static void register(Registerable registerable) { + public static void register(BootstrapContext registerable) { of(registerable, Blocks.OAK_LEAVES, PromenadeBlocks.SNOWY_OAK_LEAVES); of(registerable, Blocks.SPRUCE_LEAVES, PromenadeBlocks.SNOWY_SPRUCE_LEAVES); of(registerable, Blocks.BIRCH_LEAVES, PromenadeBlocks.SNOWY_BIRCH_LEAVES); @@ -52,8 +52,8 @@ public static void register(Registerable registerable) of(registerable, PromenadeBlocks.PALM_LEAVES, PromenadeBlocks.SNOWY_PALM_LEAVES); } - private static void of(Registerable registry, Block baseBlock, Block snowyBlock) { - var id = RegistryKey.of(PromenadeRegistryKeys.SNOWY_BLOCK_TRANSFORMATION, Promenade.id(Registries.BLOCK.getId(snowyBlock).getPath())); - registry.register(id, new SnowyBlockTransformation(baseBlock.getRegistryEntry(), snowyBlock.getRegistryEntry())); + private static void of(BootstrapContext registry, Block baseBlock, Block snowyBlock) { + var id = ResourceKey.create(PromenadeRegistryKeys.SNOWY_BLOCK_TRANSFORMATION, Promenade.id(BuiltInRegistries.BLOCK.getKey(snowyBlock).getPath())); + registry.register(id, new SnowyBlockTransformation(baseBlock.builtInRegistryHolder(), snowyBlock.builtInRegistryHolder())); } } \ No newline at end of file diff --git a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeSoundsProvider.java b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeSoundsProvider.java index d27a7228..bbf5032f 100644 --- a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeSoundsProvider.java +++ b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeSoundsProvider.java @@ -4,15 +4,15 @@ import fr.hugman.promenade.sound.PromenadeSoundEvents; import net.fabricmc.fabric.api.client.datagen.v1.builder.SoundTypeBuilder; import net.fabricmc.fabric.api.client.datagen.v1.provider.FabricSoundsProvider; -import net.minecraft.data.DataOutput; -import net.minecraft.registry.RegistryWrapper; -import net.minecraft.sound.SoundEvent; -import net.minecraft.util.Identifier; +import net.minecraft.core.HolderLookup; +import net.minecraft.data.PackOutput; +import net.minecraft.resources.Identifier; +import net.minecraft.sounds.SoundEvent; import java.util.concurrent.CompletableFuture; public class PromenadeSoundsProvider extends FabricSoundsProvider { - public PromenadeSoundsProvider(DataOutput output, CompletableFuture registriesFuture) { + public PromenadeSoundsProvider(PackOutput output, CompletableFuture registriesFuture) { super(output, registriesFuture); } @@ -22,7 +22,7 @@ public String getName() { } @Override - protected void configure(RegistryWrapper.WrapperLookup wrapperLookup, SoundExporter soundExporter) { + protected void configure(HolderLookup.Provider wrapperLookup, SoundExporter soundExporter) { // Blocks soundExporter.add(PromenadeSoundEvents.BLOCK_SNOWY_LEAVES_BREAK, variantSoundBuilder(4, Promenade.id("block/snowy_leaves/break")).subtitle("subtitles.block.generic.break")); soundExporter.add(PromenadeSoundEvents.BLOCK_SNOWY_LEAVES_PLACE, variantSoundBuilder(4, Promenade.id("block/snowy_leaves/break")).subtitle("subtitles.block.generic.place")); @@ -47,8 +47,8 @@ protected void configure(RegistryWrapper.WrapperLookup wrapperLookup, SoundExpor soundExporter.add(PromenadeSoundEvents.DUCK_HURT, variantSoundBuilder(PromenadeSoundEvents.DUCK_HURT, 3)); soundExporter.add(PromenadeSoundEvents.DUCK_DEATH, variantSoundBuilder(PromenadeSoundEvents.DUCK_DEATH, 1)); soundExporter.add(PromenadeSoundEvents.DUCK_STEP, SoundTypeBuilder.of().subtitle("subtitles.block.generic.footsteps") - .sound(SoundTypeBuilder.EntryBuilder.ofFile(Identifier.of("mob/chicken/step1"))) - .sound(SoundTypeBuilder.EntryBuilder.ofFile(Identifier.of("mob/chicken/step2"))) + .sound(SoundTypeBuilder.RegistrationBuilder.ofFile(Identifier.parse("mob/chicken/step1"))) + .sound(SoundTypeBuilder.RegistrationBuilder.ofFile(Identifier.parse("mob/chicken/step2"))) ); soundExporter.add(PromenadeSoundEvents.CAPYBARA_AMBIENT, variantSoundBuilder(PromenadeSoundEvents.CAPYBARA_AMBIENT, 5)); @@ -63,19 +63,19 @@ protected void configure(RegistryWrapper.WrapperLookup wrapperLookup, SoundExpor // Music soundExporter.add(PromenadeSoundEvents.MUSIC_OVERWORLD_SAKURA_GROVES, SoundTypeBuilder.of() - .sound(SoundTypeBuilder.EntryBuilder.ofFile(Promenade.id("music/brise_couleur_pastel")).stream(true).volume(0.4f).weight(6)) - .sound(SoundTypeBuilder.EntryBuilder.ofFile(Identifier.of("minecraft:music/game/minecraft")).stream(true)) - .sound(SoundTypeBuilder.EntryBuilder.ofFile(Identifier.of("minecraft:music/game/sweden")).stream(true)) - .sound(SoundTypeBuilder.EntryBuilder.ofFile(Identifier.of("minecraft:music/game/clark")).stream(true)) - .sound(SoundTypeBuilder.EntryBuilder.ofFile(Identifier.of("minecraft:music/game/left_to_bloom")).stream(true).volume(0.4f)) - .sound(SoundTypeBuilder.EntryBuilder.ofFile(Identifier.of("minecraft:music/game/featherfall")).stream(true).volume(0.4f).weight(3)) - .sound(SoundTypeBuilder.EntryBuilder.ofFile(Identifier.of("minecraft:music/game/echo_in_the_wind")).stream(true).volume(0.4f).weight(3)) - .sound(SoundTypeBuilder.EntryBuilder.ofFile(Identifier.of("minecraft:music/game/bromeliad")).stream(true).volume(0.4f).weight(3)) + .sound(SoundTypeBuilder.RegistrationBuilder.ofFile(Promenade.id("music/brise_couleur_pastel")).stream(true).volume(0.4f).weight(6)) + .sound(SoundTypeBuilder.RegistrationBuilder.ofFile(Identifier.parse("minecraft:music/game/minecraft")).stream(true)) + .sound(SoundTypeBuilder.RegistrationBuilder.ofFile(Identifier.parse("minecraft:music/game/sweden")).stream(true)) + .sound(SoundTypeBuilder.RegistrationBuilder.ofFile(Identifier.parse("minecraft:music/game/clark")).stream(true)) + .sound(SoundTypeBuilder.RegistrationBuilder.ofFile(Identifier.parse("minecraft:music/game/left_to_bloom")).stream(true).volume(0.4f)) + .sound(SoundTypeBuilder.RegistrationBuilder.ofFile(Identifier.parse("minecraft:music/game/featherfall")).stream(true).volume(0.4f).weight(3)) + .sound(SoundTypeBuilder.RegistrationBuilder.ofFile(Identifier.parse("minecraft:music/game/echo_in_the_wind")).stream(true).volume(0.4f).weight(3)) + .sound(SoundTypeBuilder.RegistrationBuilder.ofFile(Identifier.parse("minecraft:music/game/bromeliad")).stream(true).volume(0.4f).weight(3)) ); } private SoundTypeBuilder variantSoundBuilder(SoundEvent soundEvent, int count) { - return variantSoundBuilder(SoundTypeBuilder.of(soundEvent), count, soundEvent.id().withPath(s -> s.replace(".", "/"))); + return variantSoundBuilder(SoundTypeBuilder.of(soundEvent), count, soundEvent.location().withPath(s -> s.replace(".", "/"))); } private SoundTypeBuilder variantSoundBuilder(SoundEvent soundEvent, int count, Identifier baseId) { @@ -89,11 +89,11 @@ private SoundTypeBuilder variantSoundBuilder(int count, Identifier baseId) { private SoundTypeBuilder variantSoundBuilder(SoundTypeBuilder builder, int count, Identifier baseId) { if (count > 1) { for (int i = 1; i <= count; i++) { - Identifier soundId = baseId.withSuffixedPath("/" + i); - builder.sound(SoundTypeBuilder.EntryBuilder.ofFile(soundId)); + Identifier soundId = baseId.withSuffix("/" + i); + builder.sound(SoundTypeBuilder.RegistrationBuilder.ofFile(soundId)); } } else { - builder.sound(SoundTypeBuilder.EntryBuilder.ofFile(baseId)); + builder.sound(SoundTypeBuilder.RegistrationBuilder.ofFile(baseId)); } return builder; } diff --git a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeStructureProvider.java b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeStructureProvider.java index 4a73c0cb..611bd339 100644 --- a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeStructureProvider.java +++ b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeStructureProvider.java @@ -3,29 +3,29 @@ import fr.hugman.promenade.tag.PromenadeBiomeTags; import fr.hugman.promenade.world.gen.structure.PromenadeStructureKeys; import fr.hugman.promenade.world.gen.structure.PromenadeStructurePoolsKeys; -import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; +import net.fabricmc.fabric.api.datagen.v1.FabricPackOutput; import net.fabricmc.fabric.api.datagen.v1.provider.FabricDynamicRegistryProvider; -import net.minecraft.registry.Registerable; -import net.minecraft.registry.RegistryKeys; -import net.minecraft.registry.RegistryWrapper; -import net.minecraft.world.Heightmap; -import net.minecraft.world.gen.GenerationStep; -import net.minecraft.world.gen.StructureTerrainAdaptation; -import net.minecraft.world.gen.YOffset; -import net.minecraft.world.gen.heightprovider.ConstantHeightProvider; -import net.minecraft.world.gen.structure.JigsawStructure; -import net.minecraft.world.gen.structure.Structure; +import net.minecraft.core.HolderLookup; +import net.minecraft.core.registries.Registries; +import net.minecraft.data.worldgen.BootstrapContext; +import net.minecraft.world.level.levelgen.GenerationStep; +import net.minecraft.world.level.levelgen.Heightmap; +import net.minecraft.world.level.levelgen.VerticalAnchor; +import net.minecraft.world.level.levelgen.heightproviders.ConstantHeight; +import net.minecraft.world.level.levelgen.structure.Structure; +import net.minecraft.world.level.levelgen.structure.TerrainAdjustment; +import net.minecraft.world.level.levelgen.structure.structures.JigsawStructure; import java.util.concurrent.CompletableFuture; public class PromenadeStructureProvider extends FabricDynamicRegistryProvider { - public PromenadeStructureProvider(FabricDataOutput output, CompletableFuture registriesFuture) { + public PromenadeStructureProvider(FabricPackOutput output, CompletableFuture registriesFuture) { super(output, registriesFuture); } @Override - protected void configure(RegistryWrapper.WrapperLookup registries, Entries entries) { - entries.addAll(registries.getOrThrow(RegistryKeys.STRUCTURE)); + protected void configure(HolderLookup.Provider registries, Entries entries) { + entries.addAll(registries.lookupOrThrow(Registries.STRUCTURE)); } @Override @@ -33,22 +33,22 @@ public String getName() { return "Structures"; } - public static void register(Registerable registerable) { - var biomes = registerable.getRegistryLookup(RegistryKeys.BIOME); - var templatePools = registerable.getRegistryLookup(RegistryKeys.TEMPLATE_POOL); + public static void register(BootstrapContext registerable) { + var biomes = registerable.lookup(Registries.BIOME); + var templatePools = registerable.lookup(Registries.TEMPLATE_POOL); registerable.register( PromenadeStructureKeys.DARK_FOREST_WITCH_HUT, new JigsawStructure( - new Structure.Config.Builder(biomes.getOrThrow(PromenadeBiomeTags.HAS_DARK_FOREST_WITCH_HUTS)) - .step(GenerationStep.Feature.SURFACE_STRUCTURES) - .terrainAdaptation(StructureTerrainAdaptation.BEARD_THIN) + new Structure.StructureSettings.Builder(biomes.getOrThrow(PromenadeBiomeTags.HAS_DARK_FOREST_WITCH_HUTS)) + .generationStep(GenerationStep.Decoration.SURFACE_STRUCTURES) + .terrainAdapation(TerrainAdjustment.BEARD_THIN) .build(), templatePools.getOrThrow(PromenadeStructurePoolsKeys.DARK_FOREST_WITCH_HUTS), 1, - ConstantHeightProvider.create(YOffset.fixed(0)), + ConstantHeight.of(VerticalAnchor.absolute(0)), false, - Heightmap.Type.WORLD_SURFACE_WG + Heightmap.Types.WORLD_SURFACE_WG ) ); } diff --git a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeStructureSetProvider.java b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeStructureSetProvider.java index d352d04f..4543a172 100644 --- a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeStructureSetProvider.java +++ b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeStructureSetProvider.java @@ -2,25 +2,25 @@ import fr.hugman.promenade.world.gen.structure.PromenadeStructureKeys; import fr.hugman.promenade.world.gen.structure.PromenadeStructureSetKeys; -import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; +import net.fabricmc.fabric.api.datagen.v1.FabricPackOutput; import net.fabricmc.fabric.api.datagen.v1.provider.FabricDynamicRegistryProvider; -import net.minecraft.registry.Registerable; -import net.minecraft.registry.RegistryKeys; -import net.minecraft.registry.RegistryWrapper; -import net.minecraft.structure.StructureSet; -import net.minecraft.world.gen.chunk.placement.RandomSpreadStructurePlacement; -import net.minecraft.world.gen.chunk.placement.SpreadType; +import net.minecraft.core.HolderLookup; +import net.minecraft.core.registries.Registries; +import net.minecraft.data.worldgen.BootstrapContext; +import net.minecraft.world.level.levelgen.structure.StructureSet; +import net.minecraft.world.level.levelgen.structure.placement.RandomSpreadStructurePlacement; +import net.minecraft.world.level.levelgen.structure.placement.RandomSpreadType; import java.util.concurrent.CompletableFuture; public class PromenadeStructureSetProvider extends FabricDynamicRegistryProvider { - public PromenadeStructureSetProvider(FabricDataOutput output, CompletableFuture registriesFuture) { + public PromenadeStructureSetProvider(FabricPackOutput output, CompletableFuture registriesFuture) { super(output, registriesFuture); } @Override - protected void configure(RegistryWrapper.WrapperLookup registries, Entries entries) { - entries.addAll(registries.getOrThrow(RegistryKeys.STRUCTURE_SET)); + protected void configure(HolderLookup.Provider registries, Entries entries) { + entries.addAll(registries.lookupOrThrow(Registries.STRUCTURE_SET)); } @Override @@ -28,14 +28,14 @@ public String getName() { return "Structure Sets"; } - public static void register(Registerable registerable) { - var structures = registerable.getRegistryLookup(RegistryKeys.STRUCTURE); + public static void register(BootstrapContext registerable) { + var structures = registerable.lookup(Registries.STRUCTURE); registerable.register( PromenadeStructureSetKeys.WITCH_HUTS, new StructureSet( structures.getOrThrow(PromenadeStructureKeys.DARK_FOREST_WITCH_HUT), - new RandomSpreadStructurePlacement(32, 8, SpreadType.LINEAR, 14357620) + new RandomSpreadStructurePlacement(32, 8, RandomSpreadType.LINEAR, 14357620) ) ); } diff --git a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeSunkenVariantProvider.java b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeSunkenVariantProvider.java index 364daaf0..50bce277 100644 --- a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeSunkenVariantProvider.java +++ b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeSunkenVariantProvider.java @@ -4,26 +4,26 @@ import fr.hugman.promenade.entity.variant.SunkenVariants; import fr.hugman.promenade.loot.PromenadeLootTables; import fr.hugman.promenade.registry.PromenadeRegistryKeys; -import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; +import net.fabricmc.fabric.api.datagen.v1.FabricPackOutput; import net.fabricmc.fabric.api.datagen.v1.provider.FabricDynamicRegistryProvider; -import net.minecraft.entity.spawn.SpawnConditionSelectors; -import net.minecraft.loot.LootTable; -import net.minecraft.registry.Registerable; -import net.minecraft.registry.RegistryKey; -import net.minecraft.registry.RegistryWrapper; -import net.minecraft.util.AssetInfo.TextureAssetInfo; +import net.minecraft.core.ClientAsset.ResourceTexture; +import net.minecraft.core.HolderLookup; +import net.minecraft.data.worldgen.BootstrapContext; +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.entity.variant.SpawnPrioritySelectors; +import net.minecraft.world.level.storage.loot.LootTable; import java.util.concurrent.CompletableFuture; //TODO: a generic class for other devs public class PromenadeSunkenVariantProvider extends FabricDynamicRegistryProvider { - public PromenadeSunkenVariantProvider(FabricDataOutput output, CompletableFuture registriesFuture) { + public PromenadeSunkenVariantProvider(FabricPackOutput output, CompletableFuture registriesFuture) { super(output, registriesFuture); } @Override - protected void configure(RegistryWrapper.WrapperLookup registries, Entries entries) { - entries.addAll(registries.getOrThrow(PromenadeRegistryKeys.SUNKEN_VARIANT)); + protected void configure(HolderLookup.Provider registries, Entries entries) { + entries.addAll(registries.lookupOrThrow(PromenadeRegistryKeys.SUNKEN_VARIANT)); } @Override @@ -31,7 +31,7 @@ public String getName() { return "Sunken Variants"; } - public static void register(Registerable registry) { + public static void register(BootstrapContext registry) { of(registry, SunkenVariants.TUBE, PromenadeLootTables.TUBE_SUNKEN); of(registry, SunkenVariants.BRAIN, PromenadeLootTables.BRAIN_SUNKEN); of(registry, SunkenVariants.BUBBLE, PromenadeLootTables.BUBBLE_SUNKEN); @@ -39,7 +39,7 @@ public static void register(Registerable registry) { of(registry, SunkenVariants.HORN, PromenadeLootTables.HORN_SUNKEN); } - private static void of(Registerable registry, RegistryKey key, RegistryKey lootTable) { - registry.register(key, new SunkenVariant(new TextureAssetInfo(key.getValue().withPrefixedPath("entity/sunken/")), lootTable, SpawnConditionSelectors.createFallback(0))); + private static void of(BootstrapContext registry, ResourceKey key, ResourceKey lootTable) { + registry.register(key, new SunkenVariant(new ResourceTexture(key.identifier().withPrefix("entity/sunken/")), lootTable, SpawnPrioritySelectors.fallback(0))); } } \ No newline at end of file diff --git a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeTemplatePoolProvider.java b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeTemplatePoolProvider.java index 61c11345..db7d7edd 100644 --- a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeTemplatePoolProvider.java +++ b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeTemplatePoolProvider.java @@ -4,25 +4,25 @@ import com.mojang.datafixers.util.Pair; import fr.hugman.promenade.Promenade; import fr.hugman.promenade.world.gen.structure.PromenadeStructurePoolsKeys; -import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; +import net.fabricmc.fabric.api.datagen.v1.FabricPackOutput; import net.fabricmc.fabric.api.datagen.v1.provider.FabricDynamicRegistryProvider; -import net.minecraft.registry.Registerable; -import net.minecraft.registry.RegistryKeys; -import net.minecraft.registry.RegistryWrapper; -import net.minecraft.structure.pool.StructurePool; -import net.minecraft.structure.pool.StructurePoolElement; -import net.minecraft.structure.pool.StructurePools; +import net.minecraft.core.HolderLookup; +import net.minecraft.core.registries.Registries; +import net.minecraft.data.worldgen.BootstrapContext; +import net.minecraft.data.worldgen.Pools; +import net.minecraft.world.level.levelgen.structure.pools.StructurePoolElement; +import net.minecraft.world.level.levelgen.structure.pools.StructureTemplatePool; import java.util.concurrent.CompletableFuture; public class PromenadeTemplatePoolProvider extends FabricDynamicRegistryProvider { - public PromenadeTemplatePoolProvider(FabricDataOutput output, CompletableFuture registriesFuture) { + public PromenadeTemplatePoolProvider(FabricPackOutput output, CompletableFuture registriesFuture) { super(output, registriesFuture); } @Override - protected void configure(RegistryWrapper.WrapperLookup registries, Entries entries) { - entries.addAll(registries.getOrThrow(RegistryKeys.TEMPLATE_POOL)); + protected void configure(HolderLookup.Provider registries, Entries entries) { + entries.addAll(registries.lookupOrThrow(Registries.TEMPLATE_POOL)); } @Override @@ -30,24 +30,24 @@ public String getName() { return "Template Pools"; } - public static void register(Registerable registerable) { - var pools = registerable.getRegistryLookup(RegistryKeys.TEMPLATE_POOL); - var empty = pools.getOrThrow(StructurePools.EMPTY); + public static void register(BootstrapContext registerable) { + var pools = registerable.lookup(Registries.TEMPLATE_POOL); + var empty = pools.getOrThrow(Pools.EMPTY); - registerable.register(PromenadeStructurePoolsKeys.DARK_FOREST_WITCH_HUTS, new StructurePool(empty, + registerable.register(PromenadeStructurePoolsKeys.DARK_FOREST_WITCH_HUTS, new StructureTemplatePool(empty, ImmutableList.of( - Pair.of(StructurePoolElement.ofSingle(Promenade.id("witch_hut").toString()), 1) + Pair.of(StructurePoolElement.single(Promenade.id("witch_hut").toString()), 1) ), - StructurePool.Projection.RIGID + StructureTemplatePool.Projection.RIGID )); - registerable.register(PromenadeStructurePoolsKeys.WITCH_HUT_INTERIORS, new StructurePool(empty, + registerable.register(PromenadeStructurePoolsKeys.WITCH_HUT_INTERIORS, new StructureTemplatePool(empty, ImmutableList.of( - Pair.of(StructurePoolElement.ofSingle(Promenade.id("witch_hut/interior/normal").toString()), 5), - Pair.of(StructurePoolElement.ofSingle(Promenade.id("witch_hut/interior/hatred").toString()), 1), - Pair.of(StructurePoolElement.ofSingle(Promenade.id("witch_hut/interior/afraid").toString()), 1) + Pair.of(StructurePoolElement.single(Promenade.id("witch_hut/interior/normal").toString()), 5), + Pair.of(StructurePoolElement.single(Promenade.id("witch_hut/interior/hatred").toString()), 1), + Pair.of(StructurePoolElement.single(Promenade.id("witch_hut/interior/afraid").toString()), 1) ), - StructurePool.Projection.RIGID + StructureTemplatePool.Projection.RIGID )); } } \ No newline at end of file diff --git a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeVillagerTradeProvider.java b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeVillagerTradeProvider.java new file mode 100644 index 00000000..5d315ca5 --- /dev/null +++ b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeVillagerTradeProvider.java @@ -0,0 +1,58 @@ +package fr.hugman.promenade.data.provider; + +import fr.hugman.promenade.block.PromenadeBlocks; +import fr.hugman.promenade.world.item.trading.PromenadeVillagerTrades; +import net.fabricmc.fabric.api.datagen.v1.FabricPackOutput; +import net.fabricmc.fabric.api.datagen.v1.provider.FabricDynamicRegistryProvider; +import net.minecraft.core.HolderLookup; +import net.minecraft.core.registries.Registries; +import net.minecraft.data.worldgen.BootstrapContext; +import net.minecraft.world.item.ItemStackTemplate; +import net.minecraft.world.item.Items; +import net.minecraft.world.item.trading.TradeCost; +import net.minecraft.world.item.trading.VillagerTrade; +import net.minecraft.world.level.block.Block; + +import java.util.List; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; + +public class PromenadeVillagerTradeProvider extends FabricDynamicRegistryProvider { + public PromenadeVillagerTradeProvider(FabricPackOutput output, CompletableFuture registriesFuture) { + super(output, registriesFuture); + } + + @Override + protected void configure(HolderLookup.Provider provider, Entries entries) { + final var wrapper = provider.lookupOrThrow(Registries.VILLAGER_TRADE); + entries.add(wrapper, PromenadeVillagerTrades.WANDERING_TRADER_VERMILION_MAPLE_SAPLING); + entries.add(wrapper, PromenadeVillagerTrades.WANDERING_TRADER_FULVOUS_MAPLE_SAPLING); + entries.add(wrapper, PromenadeVillagerTrades.WANDERING_TRADER_MIKADO_MAPLE_SAPLING); + entries.add(wrapper, PromenadeVillagerTrades.WANDERING_TRADER_SAP_MAPLE_SAPLING); + entries.add(wrapper, PromenadeVillagerTrades.WANDERING_TRADER_BLUSH_SAKURA_SAPLING); + entries.add(wrapper, PromenadeVillagerTrades.WANDERING_TRADER_COTTON_SAKURA_SAPLING); + entries.add(wrapper, PromenadeVillagerTrades.WANDERING_TRADER_PALM_SAPLING); + } + + @Override + public String getName() { + return "Villager Trades"; + } + + public static void register(BootstrapContext context) { + context.register(PromenadeVillagerTrades.WANDERING_TRADER_VERMILION_MAPLE_SAPLING, wanderingTraderSapling(PromenadeBlocks.VERMILION_MAPLE_SAPLING)); + context.register(PromenadeVillagerTrades.WANDERING_TRADER_FULVOUS_MAPLE_SAPLING, wanderingTraderSapling(PromenadeBlocks.FULVOUS_MAPLE_SAPLING)); + context.register(PromenadeVillagerTrades.WANDERING_TRADER_MIKADO_MAPLE_SAPLING, wanderingTraderSapling(PromenadeBlocks.MIKADO_MAPLE_SAPLING)); + context.register(PromenadeVillagerTrades.WANDERING_TRADER_SAP_MAPLE_SAPLING, wanderingTraderSapling(PromenadeBlocks.SAP_MAPLE_SAPLING)); + + context.register(PromenadeVillagerTrades.WANDERING_TRADER_BLUSH_SAKURA_SAPLING, wanderingTraderSapling(PromenadeBlocks.BLUSH_SAKURA_SAPLING)); + context.register(PromenadeVillagerTrades.WANDERING_TRADER_COTTON_SAKURA_SAPLING, wanderingTraderSapling(PromenadeBlocks.COTTON_SAKURA_SAPLING)); + + context.register(PromenadeVillagerTrades.WANDERING_TRADER_PALM_SAPLING, wanderingTraderSapling(PromenadeBlocks.PALM_SAPLING)); + } + + + private static VillagerTrade wanderingTraderSapling(Block sapling) { + return new VillagerTrade(new TradeCost(Items.EMERALD, 5), new ItemStackTemplate(sapling.asItem()), 8, 1, 0.05F, Optional.empty(), List.of()); + } +} \ No newline at end of file diff --git a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeVillagerTradeTagsProvider.java b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeVillagerTradeTagsProvider.java new file mode 100644 index 00000000..bfbf6a13 --- /dev/null +++ b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeVillagerTradeTagsProvider.java @@ -0,0 +1,30 @@ +package fr.hugman.promenade.data.provider; + +import fr.hugman.promenade.world.item.trading.PromenadeVillagerTrades; +import net.fabricmc.fabric.api.datagen.v1.FabricPackOutput; +import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagsProvider; +import net.minecraft.core.HolderLookup; +import net.minecraft.core.registries.Registries; +import net.minecraft.tags.VillagerTradeTags; +import net.minecraft.world.item.trading.VillagerTrade; + +import java.util.concurrent.CompletableFuture; + +public class PromenadeVillagerTradeTagsProvider extends FabricTagsProvider { + + public PromenadeVillagerTradeTagsProvider(FabricPackOutput output, CompletableFuture registryLookupFuture) { + super(output, Registries.VILLAGER_TRADE, registryLookupFuture); + } + + @Override + protected void addTags(HolderLookup.Provider wrapperLookup) { + builder(VillagerTradeTags.WANDERING_TRADER_COMMON) + .add(PromenadeVillagerTrades.WANDERING_TRADER_VERMILION_MAPLE_SAPLING) + .add(PromenadeVillagerTrades.WANDERING_TRADER_FULVOUS_MAPLE_SAPLING) + .add(PromenadeVillagerTrades.WANDERING_TRADER_MIKADO_MAPLE_SAPLING) + .add(PromenadeVillagerTrades.WANDERING_TRADER_SAP_MAPLE_SAPLING) + .add(PromenadeVillagerTrades.WANDERING_TRADER_BLUSH_SAKURA_SAPLING) + .add(PromenadeVillagerTrades.WANDERING_TRADER_COTTON_SAKURA_SAPLING) + .add(PromenadeVillagerTrades.WANDERING_TRADER_PALM_SAPLING); + } +} \ No newline at end of file diff --git a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeWolfVariantProvider.java b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeWolfVariantProvider.java index 8771d615..a008d2f0 100644 --- a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeWolfVariantProvider.java +++ b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeWolfVariantProvider.java @@ -2,28 +2,28 @@ import fr.hugman.promenade.entity.variant.PromenadeWolfVariants; import fr.hugman.promenade.tag.PromenadeBiomeTags; -import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; +import net.fabricmc.fabric.api.datagen.v1.FabricPackOutput; import net.fabricmc.fabric.api.datagen.v1.provider.FabricDynamicRegistryProvider; -import net.minecraft.entity.passive.WolfVariant; -import net.minecraft.entity.spawn.SpawnConditionSelectors; -import net.minecraft.registry.Registerable; -import net.minecraft.registry.RegistryKey; -import net.minecraft.registry.RegistryKeys; -import net.minecraft.registry.RegistryWrapper; -import net.minecraft.registry.tag.TagKey; -import net.minecraft.util.AssetInfo.TextureAssetInfo; -import net.minecraft.world.biome.Biome; +import net.minecraft.core.ClientAsset.ResourceTexture; +import net.minecraft.core.HolderLookup; +import net.minecraft.core.registries.Registries; +import net.minecraft.data.worldgen.BootstrapContext; +import net.minecraft.resources.ResourceKey; +import net.minecraft.tags.TagKey; +import net.minecraft.world.entity.animal.wolf.WolfVariant; +import net.minecraft.world.entity.variant.SpawnPrioritySelectors; +import net.minecraft.world.level.biome.Biome; import java.util.concurrent.CompletableFuture; public class PromenadeWolfVariantProvider extends FabricDynamicRegistryProvider { - public PromenadeWolfVariantProvider(FabricDataOutput output, CompletableFuture registriesFuture) { + public PromenadeWolfVariantProvider(FabricPackOutput output, CompletableFuture registriesFuture) { super(output, registriesFuture); } @Override - protected void configure(RegistryWrapper.WrapperLookup registries, Entries entries) { - var wrapper = registries.getOrThrow(RegistryKeys.WOLF_VARIANT); + protected void configure(HolderLookup.Provider registries, Entries entries) { + var wrapper = registries.lookupOrThrow(Registries.WOLF_VARIANT); entries.add(wrapper, PromenadeWolfVariants.SHIBA_INU); } @@ -32,21 +32,26 @@ public String getName() { return "Wolf Variants"; } - public static void register(Registerable registry) { + public static void register(BootstrapContext registry) { of(registry, PromenadeWolfVariants.SHIBA_INU, PromenadeBiomeTags.SAKURA_GROVES); } - private static void of(Registerable registry, RegistryKey key, TagKey biomeTag) { - of(registry, key, DataProviderUtil.createSpawnConditions(registry.getRegistryLookup(RegistryKeys.BIOME).getOrThrow(biomeTag))); + private static void of(BootstrapContext registry, ResourceKey key, TagKey biomeTag) { + of(registry, key, DataProviderUtil.createSpawnConditions(registry.lookup(Registries.BIOME).getOrThrow(biomeTag))); } - private static void of(Registerable registry, RegistryKey key, SpawnConditionSelectors spawnConditions) { - var baseId = key.getValue().withPrefixedPath("entity/wolf/"); + private static void of(BootstrapContext registry, ResourceKey key, SpawnPrioritySelectors spawnConditions) { + var baseId = key.identifier().withPrefix("entity/wolf/"); registry.register(key, new WolfVariant( - new WolfVariant.WolfAssetInfo( - new TextureAssetInfo(baseId.withSuffixedPath("/wild")), - new TextureAssetInfo(baseId.withSuffixedPath("/tame")), - new TextureAssetInfo(baseId.withSuffixedPath("/angry")) + new WolfVariant.AssetInfo( + new ResourceTexture(baseId.withSuffix("/wild")), + new ResourceTexture(baseId.withSuffix("/tame")), + new ResourceTexture(baseId.withSuffix("/angry")) + ), + new WolfVariant.AssetInfo( + new ResourceTexture(baseId.withSuffix("/wild_baby")), + new ResourceTexture(baseId.withSuffix("/tame_baby")), + new ResourceTexture(baseId.withSuffix("/angry_baby")) ), spawnConditions )); diff --git a/src/datagen/java/fr/hugman/promenade/data/provider/builders/PromenadeFeatureConfigs.java b/src/datagen/java/fr/hugman/promenade/data/provider/builders/PromenadeFeatureConfigs.java index 29179b3e..d4da9528 100644 --- a/src/datagen/java/fr/hugman/promenade/data/provider/builders/PromenadeFeatureConfigs.java +++ b/src/datagen/java/fr/hugman/promenade/data/provider/builders/PromenadeFeatureConfigs.java @@ -7,29 +7,29 @@ import fr.hugman.promenade.world.gen.tree.foliage.PalmFoliagePlacer; import fr.hugman.promenade.world.gen.tree.trunk.BranchingStraightTrunkPlacer; import fr.hugman.promenade.world.gen.tree.trunk.LeapingTrunkPlacer; -import net.minecraft.block.Block; -import net.minecraft.block.Blocks; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.intprovider.BiasedToBottomIntProvider; -import net.minecraft.util.math.intprovider.ConstantIntProvider; -import net.minecraft.util.math.intprovider.UniformIntProvider; -import net.minecraft.world.gen.blockpredicate.BlockPredicate; -import net.minecraft.world.gen.feature.HugeFungusFeatureConfig; -import net.minecraft.world.gen.feature.TreeFeatureConfig; -import net.minecraft.world.gen.feature.size.TwoLayersFeatureSize; -import net.minecraft.world.gen.foliage.AcaciaFoliagePlacer; -import net.minecraft.world.gen.foliage.MegaPineFoliagePlacer; -import net.minecraft.world.gen.stateprovider.BlockStateProvider; -import net.minecraft.world.gen.treedecorator.AttachedToLeavesTreeDecorator; -import net.minecraft.world.gen.trunk.ForkingTrunkPlacer; -import net.minecraft.world.gen.trunk.GiantTrunkPlacer; +import net.minecraft.core.Direction; +import net.minecraft.util.valueproviders.BiasedToBottomInt; +import net.minecraft.util.valueproviders.ConstantInt; +import net.minecraft.util.valueproviders.UniformInt; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.levelgen.blockpredicates.BlockPredicate; +import net.minecraft.world.level.levelgen.feature.HugeFungusConfiguration; +import net.minecraft.world.level.levelgen.feature.configurations.TreeConfiguration; +import net.minecraft.world.level.levelgen.feature.featuresize.TwoLayersFeatureSize; +import net.minecraft.world.level.levelgen.feature.foliageplacers.AcaciaFoliagePlacer; +import net.minecraft.world.level.levelgen.feature.foliageplacers.MegaPineFoliagePlacer; +import net.minecraft.world.level.levelgen.feature.stateproviders.BlockStateProvider; +import net.minecraft.world.level.levelgen.feature.treedecorators.AttachedToLeavesDecorator; +import net.minecraft.world.level.levelgen.feature.trunkplacers.ForkingTrunkPlacer; +import net.minecraft.world.level.levelgen.feature.trunkplacers.GiantTrunkPlacer; import java.util.List; import java.util.OptionalInt; public class PromenadeFeatureConfigs { //TODO: should be a tag - public static final BlockPredicate FUNGUS_REPLACEABLE = BlockPredicate.matchingBlocks( + public static final BlockPredicate FUNGUS_REPLACEABLE = BlockPredicate.matchesBlocks( Blocks.OAK_SAPLING, Blocks.SPRUCE_SAPLING, Blocks.BIRCH_SAPLING, @@ -91,60 +91,59 @@ public class PromenadeFeatureConfigs { ); - public static TreeFeatureConfig.Builder palm() { - return new TreeFeatureConfig.Builder( - BlockStateProvider.of(PromenadeBlocks.PALM_LOG), - new LeapingTrunkPlacer(6, 5, 2, BiasedToBottomIntProvider.create(3, 10), UniformIntProvider.create(-1, 0), 0.45f, 2), - BlockStateProvider.of(PromenadeBlocks.PALM_LEAVES), - new PalmFoliagePlacer(ConstantIntProvider.create(0), ConstantIntProvider.create(0)), + public static TreeConfiguration.TreeConfigurationBuilder palm() { + return new TreeConfiguration.TreeConfigurationBuilder( + BlockStateProvider.simple(PromenadeBlocks.PALM_LOG), + new LeapingTrunkPlacer(6, 5, 2, BiasedToBottomInt.of(3, 10), UniformInt.of(-1, 0), 0.45f, 2), + BlockStateProvider.simple(PromenadeBlocks.PALM_LEAVES), + new PalmFoliagePlacer(ConstantInt.of(0), ConstantInt.of(0)), new TwoLayersFeatureSize(1, 0, 1) ) - .decorators(ImmutableList.of(new AttachedToLeavesTreeDecorator(0.8f, 1, 0, BlockStateProvider.of(PromenadeBlocks.PALM_HANGING_LEAVES), 2, List.of(Direction.DOWN)))) - .dirtProvider(BlockStateProvider.of(Blocks.SAND)) - .forceDirt() + .decorators(ImmutableList.of(new AttachedToLeavesDecorator(0.8f, 1, 0, BlockStateProvider.simple(PromenadeBlocks.PALM_HANGING_LEAVES), 2, List.of(Direction.DOWN)))) + .belowTrunkProvider(BlockStateProvider.simple(Blocks.SAND)) .ignoreVines(); } - public static TreeFeatureConfig.Builder sakura(Block leaves, boolean fancy) { - return new TreeFeatureConfig.Builder( - BlockStateProvider.of(PromenadeBlocks.SAKURA_LOG), + public static TreeConfiguration.TreeConfigurationBuilder sakura(Block leaves, boolean fancy) { + return new TreeConfiguration.TreeConfigurationBuilder( + BlockStateProvider.simple(PromenadeBlocks.SAKURA_LOG), fancy ? new ForkingTrunkPlacer(5, 3, 2) : new ForkingTrunkPlacer(3, 2, 1), - BlockStateProvider.of(leaves), - new AcaciaFoliagePlacer(UniformIntProvider.create(1, 2), ConstantIntProvider.create(0)), + BlockStateProvider.simple(leaves), + new AcaciaFoliagePlacer(UniformInt.of(1, 2), ConstantInt.of(0)), new TwoLayersFeatureSize(1, 0, 1) ).ignoreVines(); } - public static TreeFeatureConfig.Builder maple(Block leaves, boolean fancy) { - return new TreeFeatureConfig.Builder( - BlockStateProvider.of(PromenadeBlocks.MAPLE_LOG.getDefaultState().with(MapleLogBlock.NATURAL, true)), + public static TreeConfiguration.TreeConfigurationBuilder maple(Block leaves, boolean fancy) { + return new TreeConfiguration.TreeConfigurationBuilder( + BlockStateProvider.simple(PromenadeBlocks.MAPLE_LOG.defaultBlockState().setValue(MapleLogBlock.NATURAL, true)), fancy ? new BranchingStraightTrunkPlacer(17, 5, 3) : new BranchingStraightTrunkPlacer(13, 4, 2), - BlockStateProvider.of(leaves), - new MapleFoliagePlacer(BiasedToBottomIntProvider.create(3, 4), UniformIntProvider.create(5, 6), BiasedToBottomIntProvider.create(17, 20)), + BlockStateProvider.simple(leaves), + new MapleFoliagePlacer(BiasedToBottomInt.of(3, 4), UniformInt.of(5, 6), BiasedToBottomInt.of(17, 20)), fancy ? new TwoLayersFeatureSize(0, 0, 0, OptionalInt.of(4)) : new TwoLayersFeatureSize(1, 0, 1, OptionalInt.empty()) ) .ignoreVines(); } - public static TreeFeatureConfig.Builder snowyMegaSpruce(Block leaves) { - return new TreeFeatureConfig.Builder( - BlockStateProvider.of(Blocks.SPRUCE_LOG), + public static TreeConfiguration.TreeConfigurationBuilder snowyMegaSpruce(Block leaves) { + return new TreeConfiguration.TreeConfigurationBuilder( + BlockStateProvider.simple(Blocks.SPRUCE_LOG), new GiantTrunkPlacer(13, 2, 14), - BlockStateProvider.of(leaves), - new MegaPineFoliagePlacer(ConstantIntProvider.create(0), ConstantIntProvider.create(0), UniformIntProvider.create(13, 17)), + BlockStateProvider.simple(leaves), + new MegaPineFoliagePlacer(ConstantInt.of(0), ConstantInt.of(0), UniformInt.of(13, 17)), new TwoLayersFeatureSize(1, 1, 2) ); } - public static HugeFungusFeatureConfig hugeDarkAmaranthFungus(boolean planted) { - return new HugeFungusFeatureConfig( - PromenadeBlocks.DARK_AMARANTH_NYLIUM.getDefaultState(), - PromenadeBlocks.DARK_AMARANTH_STEM.getDefaultState(), - PromenadeBlocks.DARK_AMARANTH_WART_BLOCK.getDefaultState(), - PromenadeBlocks.SOUL_SHROOMLIGHT.getDefaultState(), + public static HugeFungusConfiguration hugeDarkAmaranthFungus(boolean planted) { + return new HugeFungusConfiguration( + PromenadeBlocks.DARK_AMARANTH_NYLIUM.defaultBlockState(), + PromenadeBlocks.DARK_AMARANTH_STEM.defaultBlockState(), + PromenadeBlocks.DARK_AMARANTH_WART_BLOCK.defaultBlockState(), + PromenadeBlocks.SOUL_SHROOMLIGHT.defaultBlockState(), PromenadeFeatureConfigs.FUNGUS_REPLACEABLE, planted ); diff --git a/src/main/java/fr/hugman/promenade/Promenade.java b/src/main/java/fr/hugman/promenade/Promenade.java index 6c62b087..9111ddab 100644 --- a/src/main/java/fr/hugman/promenade/Promenade.java +++ b/src/main/java/fr/hugman/promenade/Promenade.java @@ -15,7 +15,6 @@ import fr.hugman.promenade.itemgroup.PromenadeItemGroups; import fr.hugman.promenade.registry.*; import fr.hugman.promenade.sound.PromenadeSoundEvents; -import fr.hugman.promenade.trade.PromenadeTrades; import fr.hugman.promenade.world.PromenadeGameRules; import fr.hugman.promenade.world.biome.PromenadeBiomes; import fr.hugman.promenade.world.gen.feature.PromenadeFeatures; @@ -24,7 +23,7 @@ import fr.hugman.promenade.world.gen.tree.foliage.PromenadeFoliagePlacerTypes; import fr.hugman.promenade.world.gen.tree.trunk.PromenadeTrunkPlacerTypes; import net.fabricmc.api.ModInitializer; -import net.minecraft.util.Identifier; +import net.minecraft.resources.Identifier; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -50,7 +49,6 @@ public void onInitialize() { Reflection.initialize(PromenadeItemGroups.class); PromenadeItemGroupAdditions.appendItemGroups(); PromenadeCompostingChances.register(); - PromenadeTrades.appendVillagerTrades(); PromenadeDispenserBehaviors.register(); Reflection.initialize(PromenadeSensorTypes.class); @@ -75,6 +73,6 @@ public void onInitialize() { } public static Identifier id(String path) { - return Identifier.of(MOD_ID, path); + return Identifier.fromNamespaceAndPath(MOD_ID, path); } } \ No newline at end of file diff --git a/src/main/java/fr/hugman/promenade/banner/PromenadeBannerPatternTags.java b/src/main/java/fr/hugman/promenade/banner/PromenadeBannerPatternTags.java index e261500e..b74f5c7d 100644 --- a/src/main/java/fr/hugman/promenade/banner/PromenadeBannerPatternTags.java +++ b/src/main/java/fr/hugman/promenade/banner/PromenadeBannerPatternTags.java @@ -1,14 +1,14 @@ package fr.hugman.promenade.banner; import fr.hugman.promenade.Promenade; -import net.minecraft.block.entity.BannerPattern; -import net.minecraft.registry.RegistryKeys; -import net.minecraft.registry.tag.TagKey; +import net.minecraft.core.registries.Registries; +import net.minecraft.tags.TagKey; +import net.minecraft.world.level.block.entity.BannerPattern; public class PromenadeBannerPatternTags { public static final TagKey BOVINE_PATTERN_ITEM = of("pattern_item/bovine"); private static TagKey of(String path) { - return TagKey.of(RegistryKeys.BANNER_PATTERN, Promenade.id(path)); + return TagKey.create(Registries.BANNER_PATTERN, Promenade.id(path)); } } diff --git a/src/main/java/fr/hugman/promenade/banner/PromenadeBannerPatterns.java b/src/main/java/fr/hugman/promenade/banner/PromenadeBannerPatterns.java index d48b0073..33dc1a50 100644 --- a/src/main/java/fr/hugman/promenade/banner/PromenadeBannerPatterns.java +++ b/src/main/java/fr/hugman/promenade/banner/PromenadeBannerPatterns.java @@ -1,14 +1,14 @@ package fr.hugman.promenade.banner; import fr.hugman.promenade.Promenade; -import net.minecraft.block.entity.BannerPattern; -import net.minecraft.registry.RegistryKey; -import net.minecraft.registry.RegistryKeys; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.level.block.entity.BannerPattern; public class PromenadeBannerPatterns { - public static final RegistryKey BOVINE = of("bovine"); + public static final ResourceKey BOVINE = of("bovine"); - private static RegistryKey of(String path) { - return RegistryKey.of(RegistryKeys.BANNER_PATTERN, Promenade.id(path)); + private static ResourceKey of(String path) { + return ResourceKey.create(Registries.BANNER_PATTERN, Promenade.id(path)); } } diff --git a/src/main/java/fr/hugman/promenade/block/AbstractFacingPlantBlock.java b/src/main/java/fr/hugman/promenade/block/AbstractFacingPlantBlock.java index 6990d2e3..0a0348a5 100644 --- a/src/main/java/fr/hugman/promenade/block/AbstractFacingPlantBlock.java +++ b/src/main/java/fr/hugman/promenade/block/AbstractFacingPlantBlock.java @@ -1,99 +1,98 @@ package fr.hugman.promenade.block; import com.mojang.serialization.MapCodec; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Fertilizable; -import net.minecraft.fluid.Fluids; -import net.minecraft.item.ItemPlacementContext; -import net.minecraft.item.ItemStack; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.random.Random; -import net.minecraft.util.shape.VoxelShape; -import net.minecraft.world.BlockLocating; -import net.minecraft.world.BlockView; -import net.minecraft.world.World; -import net.minecraft.world.WorldView; -import net.minecraft.world.tick.ScheduledTickView; - import java.util.Optional; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.util.BlockUtil; +import net.minecraft.util.RandomSource; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.ScheduledTickAccess; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.BonemealableBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.Fluids; +import net.minecraft.world.phys.shapes.VoxelShape; -public abstract class AbstractFacingPlantBlock extends AbstractFacingPlantPartBlock implements Fertilizable { - protected AbstractFacingPlantBlock(Settings settings, VoxelShape[] outlineShapes, boolean bl) { +public abstract class AbstractFacingPlantBlock extends AbstractFacingPlantPartBlock implements BonemealableBlock { + protected AbstractFacingPlantBlock(Properties settings, VoxelShape[] outlineShapes, boolean bl) { super(settings, outlineShapes, bl); } @Override - protected abstract MapCodec getCodec(); + protected abstract MapCodec codec(); protected BlockState copyState(BlockState from, BlockState to) { - return to.with(FACING, from.get(FACING)); + return to.setValue(FACING, from.getValue(FACING)); } @Override - protected BlockState getStateForNeighborUpdate( + protected BlockState updateShape( BlockState state, - WorldView world, - ScheduledTickView tickView, + LevelReader world, + ScheduledTickAccess tickView, BlockPos pos, Direction direction, BlockPos neighborPos, BlockState neighborState, - Random random + RandomSource random ) { - var facing = state.get(FACING); - if (direction == facing.getOpposite() && !state.canPlaceAt(world, pos)) { - tickView.scheduleBlockTick(pos, this, 1); + var facing = state.getValue(FACING); + if (direction == facing.getOpposite() && !state.canSurvive(world, pos)) { + tickView.scheduleTick(pos, this, 1); } AbstractFacingPlantStemBlock stem = this.getStem(); - if (direction == facing && !((neighborState.isOf(this) || neighborState.isOf(stem)) && neighborState.get(FACING) == facing)) { + if (direction == facing && !((neighborState.is(this) || neighborState.is(stem)) && neighborState.getValue(FACING) == facing)) { return this.copyState(state, stem.getRandomGrowthState(random)); } else { if (this.tickWater) { - tickView.scheduleFluidTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)); + tickView.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world)); } - return super.getStateForNeighborUpdate(state, world, tickView, pos, direction, neighborPos, neighborState, random); + return super.updateShape(state, world, tickView, pos, direction, neighborPos, neighborState, random); } } @Override - protected ItemStack getPickStack(WorldView world, BlockPos pos, BlockState state, boolean includeData) { + protected ItemStack getCloneItemStack(LevelReader world, BlockPos pos, BlockState state, boolean includeData) { return new ItemStack(this.getStem()); } @Override - public boolean isFertilizable(WorldView world, BlockPos pos, BlockState state) { - var facing = state.get(FACING); + public boolean isValidBonemealTarget(LevelReader world, BlockPos pos, BlockState state) { + var facing = state.getValue(FACING); Optional optional = this.getStemHeadPos(world, pos, state.getBlock(), facing); - return optional.isPresent() && this.getStem().canGrowAt(world.getBlockState(optional.get().offset(facing))); + return optional.isPresent() && this.getStem().canGrowAt(world.getBlockState(optional.get().relative(facing))); } @Override - public boolean canGrow(World world, Random random, BlockPos pos, BlockState state) { + public boolean isBonemealSuccess(Level world, RandomSource random, BlockPos pos, BlockState state) { return true; } @Override - public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) { - Optional optional = this.getStemHeadPos(world, pos, state.getBlock(), state.get(FACING)); + public void performBonemeal(ServerLevel world, RandomSource random, BlockPos pos, BlockState state) { + Optional optional = this.getStemHeadPos(world, pos, state.getBlock(), state.getValue(FACING)); if (optional.isPresent()) { BlockState blockState = world.getBlockState(optional.get()); - ((AbstractFacingPlantStemBlock) blockState.getBlock()).grow(world, random, optional.get(), blockState); + ((AbstractFacingPlantStemBlock) blockState.getBlock()).performBonemeal(world, random, optional.get(), blockState); } } - private Optional getStemHeadPos(BlockView world, BlockPos pos, Block block, Direction direction) { - return BlockLocating.findColumnEnd(world, pos, block, direction, this.getStem()); + private Optional getStemHeadPos(BlockGetter world, BlockPos pos, Block block, Direction direction) { + return BlockUtil.getTopConnectedBlock(world, pos, block, direction, this.getStem()); } @Override - protected boolean canReplace(BlockState state, ItemPlacementContext context) { - boolean bl = super.canReplace(state, context); - return (!bl || !context.getStack().isOf(this.getStem().asItem())) && bl; + protected boolean canBeReplaced(BlockState state, BlockPlaceContext context) { + boolean bl = super.canBeReplaced(state, context); + return (!bl || !context.getItemInHand().is(this.getStem().asItem())) && bl; } @Override diff --git a/src/main/java/fr/hugman/promenade/block/AbstractFacingPlantPartBlock.java b/src/main/java/fr/hugman/promenade/block/AbstractFacingPlantPartBlock.java index 41e91204..e49615cb 100644 --- a/src/main/java/fr/hugman/promenade/block/AbstractFacingPlantPartBlock.java +++ b/src/main/java/fr/hugman/promenade/block/AbstractFacingPlantPartBlock.java @@ -1,31 +1,31 @@ package fr.hugman.promenade.block; import com.mojang.serialization.MapCodec; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.FacingBlock; -import net.minecraft.block.ShapeContext; -import net.minecraft.item.ItemPlacementContext; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.state.StateManager; -import net.minecraft.state.property.EnumProperty; -import net.minecraft.state.property.Properties; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.random.Random; -import net.minecraft.util.shape.VoxelShape; -import net.minecraft.world.BlockView; -import net.minecraft.world.WorldView; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.util.RandomSource; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.DirectionalBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.StateDefinition; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; import org.jetbrains.annotations.Nullable; -public abstract class AbstractFacingPlantPartBlock extends FacingBlock { - public static final EnumProperty FACING = Properties.FACING; +public abstract class AbstractFacingPlantPartBlock extends DirectionalBlock { + public static final EnumProperty FACING = BlockStateProperties.FACING; protected final VoxelShape[] outlineShapes; protected final boolean tickWater; public AbstractFacingPlantPartBlock( - Settings settings, + Properties settings, VoxelShape[] outlineShapes, boolean tickWater ) { @@ -35,57 +35,57 @@ public AbstractFacingPlantPartBlock( } @Override - protected abstract MapCodec getCodec(); + protected abstract MapCodec codec(); @Override - protected void appendProperties(StateManager.Builder builder) { - super.appendProperties(builder); + protected void createBlockStateDefinition(StateDefinition.Builder builder) { + super.createBlockStateDefinition(builder); builder.add(FACING); } @Nullable @Override - public BlockState getPlacementState(ItemPlacementContext ctx) { - var placementDirections = ctx.getPlacementDirections(); + public BlockState getStateForPlacement(BlockPlaceContext ctx) { + var placementDirections = ctx.getNearestLookingDirections(); //TODO: make it prefer existing stems if not sneaking for (var direction : placementDirections) { var opposite = direction.getOpposite(); - var otherState = ctx.getWorld().getBlockState(ctx.getBlockPos().offset(opposite)); - var newState = !otherState.isOf(this.getStem()) && !otherState.isOf(this.getPlant()) - ? this.getRandomGrowthState(ctx.getWorld().random) - : this.getPlant().getDefaultState(); - if (newState.contains(FACING)) { - newState = newState.with(FACING, opposite); + var otherState = ctx.getLevel().getBlockState(ctx.getClickedPos().relative(opposite)); + var newState = !otherState.is(this.getStem()) && !otherState.is(this.getPlant()) + ? this.getRandomGrowthState(ctx.getLevel().getRandom()) + : this.getPlant().defaultBlockState(); + if (newState.hasProperty(FACING)) { + newState = newState.setValue(FACING, opposite); } - if (newState.canPlaceAt(ctx.getWorld(), ctx.getBlockPos())) { + if (newState.canSurvive(ctx.getLevel(), ctx.getClickedPos())) { return newState; } } return null; } - public BlockState getRandomGrowthState(Random random) { - return this.getDefaultState(); + public BlockState getRandomGrowthState(RandomSource random) { + return this.defaultBlockState(); } @Override - protected boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { - var facing = state.get(FACING); - var blockPos = pos.offset(facing.getOpposite()); + protected boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) { + var facing = state.getValue(FACING); + var blockPos = pos.relative(facing.getOpposite()); var blockState = world.getBlockState(blockPos); if (!this.canAttachTo(blockState)) return false; - if (blockState.isOf(this.getStem()) || blockState.isOf(this.getPlant())) { - if (blockState.contains(FACING) && blockState.get(FACING) == facing) { + if (blockState.is(this.getStem()) || blockState.is(this.getPlant())) { + if (blockState.hasProperty(FACING) && blockState.getValue(FACING) == facing) { return true; } } - return blockState.isSideSolidFullSquare(world, blockPos, facing); + return blockState.isFaceSturdy(world, blockPos, facing); } @Override - protected void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { - if (!state.canPlaceAt(world, pos)) { - world.breakBlock(pos, true); + protected void tick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) { + if (!state.canSurvive(world, pos)) { + world.destroyBlock(pos, true); } } @@ -94,8 +94,8 @@ protected boolean canAttachTo(BlockState state) { } @Override - protected VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) { - return this.outlineShapes[state.get(FACING).getIndex()]; + protected VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) { + return this.outlineShapes[state.getValue(FACING).get3DDataValue()]; } protected abstract AbstractFacingPlantStemBlock getStem(); diff --git a/src/main/java/fr/hugman/promenade/block/AbstractFacingPlantStemBlock.java b/src/main/java/fr/hugman/promenade/block/AbstractFacingPlantStemBlock.java index 3cc0b263..46722556 100644 --- a/src/main/java/fr/hugman/promenade/block/AbstractFacingPlantStemBlock.java +++ b/src/main/java/fr/hugman/promenade/block/AbstractFacingPlantStemBlock.java @@ -1,136 +1,136 @@ package fr.hugman.promenade.block; import com.mojang.serialization.MapCodec; -import net.minecraft.block.AbstractBlock; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Fertilizable; -import net.minecraft.fluid.Fluids; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.state.StateManager; -import net.minecraft.state.property.IntProperty; -import net.minecraft.state.property.Properties; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.random.Random; -import net.minecraft.util.shape.VoxelShape; -import net.minecraft.world.World; -import net.minecraft.world.WorldView; -import net.minecraft.world.tick.ScheduledTickView; - -public abstract class AbstractFacingPlantStemBlock extends AbstractFacingPlantPartBlock implements Fertilizable { - public static final IntProperty AGE = Properties.AGE_25; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.util.RandomSource; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.ScheduledTickAccess; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.BonemealableBlock; +import net.minecraft.world.level.block.state.BlockBehaviour; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.StateDefinition; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import net.minecraft.world.level.material.Fluids; +import net.minecraft.world.phys.shapes.VoxelShape; + +public abstract class AbstractFacingPlantStemBlock extends AbstractFacingPlantPartBlock implements BonemealableBlock { + public static final IntegerProperty AGE = BlockStateProperties.AGE_25; public static final int MAX_AGE = 25; private final double growthChance; public AbstractFacingPlantStemBlock( - AbstractBlock.Settings settings, + BlockBehaviour.Properties settings, VoxelShape[] outlineShapes, boolean tickWater, double growthChance ) { super(settings, outlineShapes, tickWater); this.growthChance = growthChance; - this.setDefaultState(this.stateManager.getDefaultState().with(AGE, Integer.valueOf(0))); + this.registerDefaultState(this.stateDefinition.any().setValue(AGE, Integer.valueOf(0))); } @Override - protected abstract MapCodec getCodec(); + protected abstract MapCodec codec(); @Override - public BlockState getRandomGrowthState(Random random) { - return this.getDefaultState().with(AGE, Integer.valueOf(random.nextInt(MAX_AGE))); + public BlockState getRandomGrowthState(RandomSource random) { + return this.defaultBlockState().setValue(AGE, Integer.valueOf(random.nextInt(MAX_AGE))); } @Override - protected boolean hasRandomTicks(BlockState state) { - return state.get(AGE) < MAX_AGE; + protected boolean isRandomlyTicking(BlockState state) { + return state.getValue(AGE) < MAX_AGE; } @Override - protected void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { - if (state.get(AGE) < 25 && random.nextDouble() < this.growthChance) { - BlockPos blockPos = pos.offset(state.get(FACING)); + protected void randomTick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) { + if (state.getValue(AGE) < 25 && random.nextDouble() < this.growthChance) { + BlockPos blockPos = pos.relative(state.getValue(FACING)); if (this.canGrowAt(world.getBlockState(blockPos))) { - world.setBlockState(blockPos, this.age(state, world.random)); + world.setBlockAndUpdate(blockPos, this.age(state, world.getRandom())); } } } - protected BlockState age(BlockState state, Random random) { + protected BlockState age(BlockState state, RandomSource random) { return state.cycle(AGE); } public BlockState withMaxAge(BlockState state) { - return state.with(AGE, Integer.valueOf(MAX_AGE)); + return state.setValue(AGE, Integer.valueOf(MAX_AGE)); } public boolean hasMaxAge(BlockState state) { - return state.get(AGE) == MAX_AGE; + return state.getValue(AGE) == MAX_AGE; } protected BlockState copyState(BlockState from, BlockState to) { - return to.with(FACING, from.get(FACING)); + return to.setValue(FACING, from.getValue(FACING)); } @Override - protected BlockState getStateForNeighborUpdate( + protected BlockState updateShape( BlockState state, - WorldView world, - ScheduledTickView tickView, + LevelReader world, + ScheduledTickAccess tickView, BlockPos pos, Direction direction, BlockPos neighborPos, BlockState neighborState, - Random random + RandomSource random ) { - var facing = state.get(FACING); - if (direction == facing.getOpposite() && !state.canPlaceAt(world, pos)) { - tickView.scheduleBlockTick(pos, this, 1); + var facing = state.getValue(FACING); + if (direction == facing.getOpposite() && !state.canSurvive(world, pos)) { + tickView.scheduleTick(pos, this, 1); } - if (direction != facing || !((neighborState.isOf(this) || neighborState.isOf(this.getPlant())) && neighborState.get(FACING) == facing)) { + if (direction != facing || !((neighborState.is(this) || neighborState.is(this.getPlant())) && neighborState.getValue(FACING) == facing)) { if (this.tickWater) { - tickView.scheduleFluidTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)); + tickView.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world)); } - return super.getStateForNeighborUpdate(state, world, tickView, pos, direction, neighborPos, neighborState, random); + return super.updateShape(state, world, tickView, pos, direction, neighborPos, neighborState, random); } else { - return this.copyState(state, this.getPlant().getDefaultState()); + return this.copyState(state, this.getPlant().defaultBlockState()); } } @Override - protected void appendProperties(StateManager.Builder builder) { - super.appendProperties(builder); + protected void createBlockStateDefinition(StateDefinition.Builder builder) { + super.createBlockStateDefinition(builder); builder.add(AGE); } @Override - public boolean isFertilizable(WorldView world, BlockPos pos, BlockState state) { - return this.canGrowAt(world.getBlockState(pos.offset(state.get(FACING)))); + public boolean isValidBonemealTarget(LevelReader world, BlockPos pos, BlockState state) { + return this.canGrowAt(world.getBlockState(pos.relative(state.getValue(FACING)))); } @Override - public boolean canGrow(World world, Random random, BlockPos pos, BlockState state) { + public boolean isBonemealSuccess(Level world, RandomSource random, BlockPos pos, BlockState state) { return true; } @Override - public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) { - var facing = state.get(FACING); - var blockPos = pos.offset(facing); - var i = Math.min(state.get(AGE) + 1, MAX_AGE); + public void performBonemeal(ServerLevel world, RandomSource random, BlockPos pos, BlockState state) { + var facing = state.getValue(FACING); + var blockPos = pos.relative(facing); + var i = Math.min(state.getValue(AGE) + 1, MAX_AGE); var j = this.getGrowthLength(random); for (int k = 0; k < j && this.canGrowAt(world.getBlockState(blockPos)); k++) { - world.setBlockState(blockPos, state.with(AGE, Integer.valueOf(i)).with(FACING, facing)); - blockPos = blockPos.offset(facing); + world.setBlockAndUpdate(blockPos, state.setValue(AGE, Integer.valueOf(i)).setValue(FACING, facing)); + blockPos = blockPos.relative(facing); i = Math.min(i + 1, MAX_AGE); } } - protected abstract int getGrowthLength(Random random); + protected abstract int getGrowthLength(RandomSource random); protected abstract boolean canGrowAt(BlockState state); diff --git a/src/main/java/fr/hugman/promenade/block/BerryBushBlock.java b/src/main/java/fr/hugman/promenade/block/BerryBushBlock.java index 13595040..e54c6de7 100644 --- a/src/main/java/fr/hugman/promenade/block/BerryBushBlock.java +++ b/src/main/java/fr/hugman/promenade/block/BerryBushBlock.java @@ -4,108 +4,113 @@ import com.mojang.serialization.Codec; import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; -import net.minecraft.block.*; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityCollisionHandler; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.registry.RegistryKey; -import net.minecraft.registry.RegistryKeys; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.sound.SoundCategory; -import net.minecraft.sound.SoundEvents; -import net.minecraft.state.StateManager; -import net.minecraft.state.property.IntProperty; -import net.minecraft.state.property.Properties; -import net.minecraft.util.ActionResult; -import net.minecraft.util.Hand; -import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Vec3d; -import net.minecraft.util.math.random.Random; -import net.minecraft.util.shape.VoxelShape; -import net.minecraft.world.BlockView; -import net.minecraft.world.World; -import net.minecraft.world.WorldView; -import net.minecraft.world.event.GameEvent; - -public class BerryBushBlock extends PlantBlock implements Fertilizable { +import net.minecraft.core.BlockPos; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceKey; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.sounds.SoundSource; +import net.minecraft.util.RandomSource; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.InsideBlockEffectApplier; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.BonemealableBlock; +import net.minecraft.world.level.block.VegetationBlock; +import net.minecraft.world.level.block.state.BlockBehaviour; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.StateDefinition; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import net.minecraft.world.level.gameevent.GameEvent; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; + +public class BerryBushBlock extends VegetationBlock implements BonemealableBlock { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> instance.group( - RegistryKey.createCodec(RegistryKeys.ITEM).fieldOf("berry").forGetter(block -> block.berry), + ResourceKey.codec(Registries.ITEM).fieldOf("berry").forGetter(block -> block.berry), Codec.BOOL.fieldOf("is_spiny").forGetter(block -> block.isSpiny), - createSettingsCodec()) + propertiesCodec()) .apply(instance, BerryBushBlock::new)); private static final float MIN_MOVEMENT_FOR_DAMAGE = 0.003f; public static final int MAX_AGE = 3; - public static final IntProperty AGE = Properties.AGE_3; - private static final VoxelShape SMALL_SHAPE = Block.createCuboidShape(3.0, 0.0, 3.0, 13.0, 8.0, 13.0); - private static final VoxelShape LARGE_SHAPE = Block.createCuboidShape(1.0, 0.0, 1.0, 15.0, 16.0, 15.0); + public static final IntegerProperty AGE = BlockStateProperties.AGE_3; + private static final VoxelShape SMALL_SHAPE = Block.box(3.0, 0.0, 3.0, 13.0, 8.0, 13.0); + private static final VoxelShape LARGE_SHAPE = Block.box(1.0, 0.0, 1.0, 15.0, 16.0, 15.0); - private final RegistryKey berry; + private final ResourceKey berry; private final boolean isSpiny; - public BerryBushBlock(RegistryKey berry, boolean isSpiny, AbstractBlock.Settings settings) { + public BerryBushBlock(ResourceKey berry, boolean isSpiny, BlockBehaviour.Properties settings) { super(settings); this.berry = berry; this.isSpiny = isSpiny; - this.setDefaultState(this.stateManager.getDefaultState().with(AGE, 0)); + this.registerDefaultState(this.stateDefinition.any().setValue(AGE, 0)); } @Override - public MapCodec getCodec() { + public MapCodec codec() { return CODEC; } @Override - protected ItemStack getPickStack(WorldView world, BlockPos pos, BlockState state, boolean includeData) { - return new ItemStack(DataFixUtils.orElse(world.getRegistryManager().getOrThrow(RegistryKeys.ITEM).getOptionalValue(this.berry), this)); + protected ItemStack getCloneItemStack(LevelReader world, BlockPos pos, BlockState state, boolean includeData) { + return new ItemStack(DataFixUtils.orElse(world.registryAccess().lookupOrThrow(Registries.ITEM).getOptional(this.berry), this)); } @Override - protected VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) { - if (state.get(AGE) == 0) { + protected VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) { + if (state.getValue(AGE) == 0) { return SMALL_SHAPE; } - if (state.get(AGE) < MAX_AGE) { + if (state.getValue(AGE) < MAX_AGE) { return LARGE_SHAPE; } - return super.getOutlineShape(state, world, pos, context); + return super.getShape(state, world, pos, context); } @Override - protected boolean hasRandomTicks(BlockState state) { - return state.get(AGE) < MAX_AGE; + protected boolean isRandomlyTicking(BlockState state) { + return state.getValue(AGE) < MAX_AGE; } @Override - protected void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { - int age = state.get(AGE); - if (age < MAX_AGE && random.nextInt(5) == 0 && world.getBaseLightLevel(pos.up(), 0) >= 9) { - BlockState blockState = state.with(AGE, age + 1); - world.setBlockState(pos, blockState, Block.NOTIFY_LISTENERS); - world.emitGameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Emitter.of(blockState)); + protected void randomTick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) { + int age = state.getValue(AGE); + if (age < MAX_AGE && random.nextInt(5) == 0 && world.getRawBrightness(pos.above(), 0) >= 9) { + BlockState blockState = state.setValue(AGE, age + 1); + world.setBlock(pos, blockState, Block.UPDATE_CLIENTS); + world.gameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Context.of(blockState)); } } @Override - protected void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity, EntityCollisionHandler handler, boolean bl) { + protected void entityInside(BlockState state, Level world, BlockPos pos, Entity entity, InsideBlockEffectApplier handler, boolean bl) { if (!(entity instanceof LivingEntity) || entity.getType() == EntityType.FOX || entity.getType() == EntityType.BEE) { return; } - entity.slowMovement(state, new Vec3d(0.8f, 0.75, 0.8f)); + entity.makeStuckInBlock(state, new Vec3(0.8f, 0.75, 0.8f)); if (this.isSpiny) { - if (world instanceof ServerWorld serverWorld && state.get(AGE) != 0) { - Vec3d vec3d = entity.isControlledByPlayer() ? entity.getMovement() : entity.getLastRenderPos().subtract(entity.getEntityPos()); - if (vec3d.horizontalLengthSquared() > 0.0) { - double d = Math.abs(vec3d.getX()); - double e = Math.abs(vec3d.getZ()); + if (world instanceof ServerLevel serverWorld && state.getValue(AGE) != 0) { + Vec3 vec3d = entity.isClientAuthoritative() ? entity.getKnownMovement() : entity.oldPosition().subtract(entity.position()); + if (vec3d.horizontalDistanceSqr() > 0.0) { + double d = Math.abs(vec3d.x()); + double e = Math.abs(vec3d.z()); if (d >= MIN_MOVEMENT_FOR_DAMAGE || e >= MIN_MOVEMENT_FOR_DAMAGE) { - entity.damage(serverWorld, world.getDamageSources().sweetBerryBush(), 1.0F); + entity.hurtServer(serverWorld, world.damageSources().sweetBerryBush(), 1.0F); } } } @@ -113,43 +118,43 @@ protected void onEntityCollision(BlockState state, World world, BlockPos pos, En } @Override - protected ActionResult onUseWithItem(ItemStack stack, BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { - return state.get(AGE) != 3 && stack.isOf(Items.BONE_MEAL) ? ActionResult.PASS : super.onUseWithItem(stack, state, world, pos, player, hand, hit); + protected InteractionResult useItemOn(ItemStack stack, BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) { + return state.getValue(AGE) != 3 && stack.is(Items.BONE_MEAL) ? InteractionResult.PASS : super.useItemOn(stack, state, world, pos, player, hand, hit); } @Override - protected ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, BlockHitResult hit) { - int age = state.get(AGE); + protected InteractionResult useWithoutItem(BlockState state, Level world, BlockPos pos, Player player, BlockHitResult hit) { + int age = state.getValue(AGE); if (age > 1) { - int j = 1 + world.random.nextInt(2); - dropStack(world, pos, new ItemStack(DataFixUtils.orElse(world.getRegistryManager().getOrThrow(RegistryKeys.ITEM).getOptionalValue(this.berry), this), j + (age == MAX_AGE ? 1 : 0))); - world.playSound(null, pos, SoundEvents.BLOCK_SWEET_BERRY_BUSH_PICK_BERRIES, SoundCategory.BLOCKS, 1.0f, 0.8f + world.random.nextFloat() * 0.4f); - BlockState blockState = state.with(AGE, 1); - world.setBlockState(pos, blockState, Block.NOTIFY_LISTENERS); - world.emitGameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Emitter.of(player, blockState)); - return ActionResult.SUCCESS; + int j = 1 + world.getRandom().nextInt(2); + popResource(world, pos, new ItemStack(DataFixUtils.orElse(world.registryAccess().lookupOrThrow(Registries.ITEM).getOptional(this.berry), this), j + (age == MAX_AGE ? 1 : 0))); + world.playSound(null, pos, SoundEvents.SWEET_BERRY_BUSH_PICK_BERRIES, SoundSource.BLOCKS, 1.0f, 0.8f + world.getRandom().nextFloat() * 0.4f); + BlockState blockState = state.setValue(AGE, 1); + world.setBlock(pos, blockState, Block.UPDATE_CLIENTS); + world.gameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Context.of(player, blockState)); + return InteractionResult.SUCCESS; } - return super.onUse(state, world, pos, player, hit); + return super.useWithoutItem(state, world, pos, player, hit); } @Override - protected void appendProperties(StateManager.Builder builder) { + protected void createBlockStateDefinition(StateDefinition.Builder builder) { builder.add(AGE); } @Override - public boolean isFertilizable(WorldView world, BlockPos pos, BlockState state) { - return state.get(AGE) < 3; + public boolean isValidBonemealTarget(LevelReader world, BlockPos pos, BlockState state) { + return state.getValue(AGE) < 3; } @Override - public boolean canGrow(World world, Random random, BlockPos pos, BlockState state) { + public boolean isBonemealSuccess(Level world, RandomSource random, BlockPos pos, BlockState state) { return true; } @Override - public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) { - int i = Math.min(MAX_AGE, state.get(AGE) + 1); - world.setBlockState(pos, state.with(AGE, i), Block.NOTIFY_LISTENERS); + public void performBonemeal(ServerLevel world, RandomSource random, BlockPos pos, BlockState state) { + int i = Math.min(MAX_AGE, state.getValue(AGE) + 1); + world.setBlock(pos, state.setValue(AGE, i), Block.UPDATE_CLIENTS); } } \ No newline at end of file diff --git a/src/main/java/fr/hugman/promenade/block/BlockSettings.java b/src/main/java/fr/hugman/promenade/block/BlockSettings.java index bc119e63..1068d41c 100644 --- a/src/main/java/fr/hugman/promenade/block/BlockSettings.java +++ b/src/main/java/fr/hugman/promenade/block/BlockSettings.java @@ -1,26 +1,26 @@ package fr.hugman.promenade.block; -import net.minecraft.block.AbstractBlock; -import net.minecraft.block.MapColor; -import net.minecraft.block.enums.NoteBlockInstrument; -import net.minecraft.sound.BlockSoundGroup; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.world.level.block.state.BlockBehaviour; +import net.minecraft.world.level.block.state.properties.NoteBlockInstrument; +import net.minecraft.world.level.material.MapColor; public final class BlockSettings { - public static AbstractBlock.Settings rock() { - return AbstractBlock.Settings.create().instrument(NoteBlockInstrument.BASEDRUM).requiresTool().strength(1.5F, 6.0f); + public static BlockBehaviour.Properties rock() { + return BlockBehaviour.Properties.of().instrument(NoteBlockInstrument.BASEDRUM).requiresCorrectToolForDrops().strength(1.5F, 6.0f); } - public static AbstractBlock.Settings rock(MapColor mapColor, BlockSoundGroup sounds) { - return rock().mapColor(mapColor).sounds(sounds); + public static BlockBehaviour.Properties rock(MapColor mapColor, SoundType sounds) { + return rock().mapColor(mapColor).sound(sounds); } - public static AbstractBlock.Settings planks(MapColor color, BlockSoundGroup sounds, boolean flammable) { - AbstractBlock.Settings settings = AbstractBlock.Settings.create() + public static BlockBehaviour.Properties planks(MapColor color, SoundType sounds, boolean flammable) { + BlockBehaviour.Properties settings = BlockBehaviour.Properties.of() .mapColor(color) .instrument(NoteBlockInstrument.BASS) .strength(2.0f, 3.0f) - .sounds(sounds); - if (flammable) settings.burnable(); + .sound(sounds); + if (flammable) settings.ignitedByLava(); return settings; } } diff --git a/src/main/java/fr/hugman/promenade/block/CoiledVinesBlock.java b/src/main/java/fr/hugman/promenade/block/CoiledVinesBlock.java index 9e3ec12e..5c9ea20f 100644 --- a/src/main/java/fr/hugman/promenade/block/CoiledVinesBlock.java +++ b/src/main/java/fr/hugman/promenade/block/CoiledVinesBlock.java @@ -1,29 +1,29 @@ package fr.hugman.promenade.block; import com.mojang.serialization.MapCodec; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.VineLogic; -import net.minecraft.util.math.random.Random; -import net.minecraft.util.shape.VoxelShape; +import net.minecraft.util.RandomSource; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.NetherVines; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.phys.shapes.VoxelShape; public class CoiledVinesBlock extends AbstractFacingPlantStemBlock { - public static final MapCodec CODEC = createCodec(CoiledVinesBlock::new); + public static final MapCodec CODEC = simpleCodec(CoiledVinesBlock::new); public static final VoxelShape[] SHAPES = new VoxelShape[]{ - Block.createCuboidShape(2.0, 2.0, 2.0, 14.0, 16.0, 14.0), // DOWN - Block.createCuboidShape(2.0, 0.0, 2.0, 14.0, 14.0, 14.0), // UP - Block.createCuboidShape(2.0, 2.0, 2.0, 14.0, 14.0, 16.0), // NORTH - Block.createCuboidShape(2.0, 2.0, 0.0, 14.0, 14.0, 14.0), // SOUTH - Block.createCuboidShape(2.0, 2.0, 2.0, 16.0, 14.0, 14.0), // WEST - Block.createCuboidShape(0.0, 2.0, 2.0, 14.0, 14.0, 14.0) // EAST + Block.box(2.0, 2.0, 2.0, 14.0, 16.0, 14.0), // DOWN + Block.box(2.0, 0.0, 2.0, 14.0, 14.0, 14.0), // UP + Block.box(2.0, 2.0, 2.0, 14.0, 14.0, 16.0), // NORTH + Block.box(2.0, 2.0, 0.0, 14.0, 14.0, 14.0), // SOUTH + Block.box(2.0, 2.0, 2.0, 16.0, 14.0, 14.0), // WEST + Block.box(0.0, 2.0, 2.0, 14.0, 14.0, 14.0) // EAST }; - public CoiledVinesBlock(Settings settings) { + public CoiledVinesBlock(Properties settings) { super(settings, SHAPES, false, 0.1); } @Override - protected MapCodec getCodec() { + protected MapCodec codec() { return CODEC; } @@ -33,12 +33,12 @@ protected Block getPlant() { } @Override - protected int getGrowthLength(Random random) { - return VineLogic.getGrowthLength(random); + protected int getGrowthLength(RandomSource random) { + return NetherVines.getBlocksToGrowWhenBonemealed(random); } @Override protected boolean canGrowAt(BlockState state) { - return VineLogic.isValidForWeepingStem(state); + return NetherVines.isValidGrowthState(state); } } diff --git a/src/main/java/fr/hugman/promenade/block/CoiledVinesPlantBlock.java b/src/main/java/fr/hugman/promenade/block/CoiledVinesPlantBlock.java index c8762588..b714b825 100644 --- a/src/main/java/fr/hugman/promenade/block/CoiledVinesPlantBlock.java +++ b/src/main/java/fr/hugman/promenade/block/CoiledVinesPlantBlock.java @@ -1,26 +1,26 @@ package fr.hugman.promenade.block; import com.mojang.serialization.MapCodec; -import net.minecraft.block.Block; -import net.minecraft.util.shape.VoxelShape; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.phys.shapes.VoxelShape; public class CoiledVinesPlantBlock extends AbstractFacingPlantBlock { - public static final MapCodec CODEC = createCodec(CoiledVinesPlantBlock::new); + public static final MapCodec CODEC = simpleCodec(CoiledVinesPlantBlock::new); public static final VoxelShape[] SHAPES = new VoxelShape[]{ - Block.createCuboidShape(2.0, 0.0, 2.0, 14.0, 16.0, 14.0), // DOWN - Block.createCuboidShape(2.0, 0.0, 2.0, 14.0, 16.0, 14.0), // UP - Block.createCuboidShape(2.0, 2.0, 0.0, 14.0, 14.0, 16.0), // NORTH - Block.createCuboidShape(2.0, 2.0, 0.0, 14.0, 14.0, 16.0), // SOUTH - Block.createCuboidShape(0.0, 2.0, 2.0, 16.0, 14.0, 14.0), // WEST - Block.createCuboidShape(0.0, 2.0, 2.0, 16.0, 14.0, 14.0) // EAST + Block.box(2.0, 0.0, 2.0, 14.0, 16.0, 14.0), // DOWN + Block.box(2.0, 0.0, 2.0, 14.0, 16.0, 14.0), // UP + Block.box(2.0, 2.0, 0.0, 14.0, 14.0, 16.0), // NORTH + Block.box(2.0, 2.0, 0.0, 14.0, 14.0, 16.0), // SOUTH + Block.box(0.0, 2.0, 2.0, 16.0, 14.0, 14.0), // WEST + Block.box(0.0, 2.0, 2.0, 16.0, 14.0, 14.0) // EAST }; - public CoiledVinesPlantBlock(Settings settings) { + public CoiledVinesPlantBlock(Properties settings) { super(settings, SHAPES, false); } @Override - protected MapCodec getCodec() { + protected MapCodec codec() { return CODEC; } diff --git a/src/main/java/fr/hugman/promenade/block/ExtendedLeavesBlock.java b/src/main/java/fr/hugman/promenade/block/ExtendedLeavesBlock.java index 0458773f..93fcf50b 100644 --- a/src/main/java/fr/hugman/promenade/block/ExtendedLeavesBlock.java +++ b/src/main/java/fr/hugman/promenade/block/ExtendedLeavesBlock.java @@ -1,160 +1,164 @@ package fr.hugman.promenade.block; -import net.minecraft.block.*; -import net.minecraft.fluid.FluidState; -import net.minecraft.fluid.Fluids; -import net.minecraft.item.ItemPlacementContext; -import net.minecraft.particle.ParticleTypes; -import net.minecraft.particle.ParticleUtil; -import net.minecraft.registry.tag.BlockTags; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.state.StateManager; -import net.minecraft.state.property.BooleanProperty; -import net.minecraft.state.property.IntProperty; -import net.minecraft.state.property.Properties; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.random.Random; -import net.minecraft.util.shape.VoxelShape; -import net.minecraft.util.shape.VoxelShapes; -import net.minecraft.world.BlockView; -import net.minecraft.world.World; -import net.minecraft.world.WorldAccess; -import net.minecraft.world.WorldView; -import net.minecraft.world.tick.ScheduledTickView; - -public abstract class ExtendedLeavesBlock extends Block implements Waterloggable { +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.tags.BlockTags; +import net.minecraft.util.ParticleUtils; +import net.minecraft.util.RandomSource; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.ScheduledTickAccess; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.LeavesBlock; +import net.minecraft.world.level.block.SimpleWaterloggedBlock; +import net.minecraft.world.level.block.state.BlockBehaviour; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.StateDefinition; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.world.level.material.Fluids; +import net.minecraft.world.phys.shapes.Shapes; +import net.minecraft.world.phys.shapes.VoxelShape; + +public abstract class ExtendedLeavesBlock extends Block implements SimpleWaterloggedBlock { public static final int MAX_DISTANCE = 14; - public static final IntProperty DISTANCE = IntProperty.of("distance", 1, MAX_DISTANCE); - public static final BooleanProperty PERSISTENT = Properties.PERSISTENT; - public static final BooleanProperty WATERLOGGED = Properties.WATERLOGGED; + public static final IntegerProperty DISTANCE = IntegerProperty.create("distance", 1, MAX_DISTANCE); + public static final BooleanProperty PERSISTENT = BlockStateProperties.PERSISTENT; + public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; protected final float leafParticleChance; - public ExtendedLeavesBlock(float leafParticleChance, AbstractBlock.Settings settings) { + public ExtendedLeavesBlock(float leafParticleChance, BlockBehaviour.Properties settings) { super(settings); this.leafParticleChance = leafParticleChance; - this.setDefaultState(this.stateManager.getDefaultState() - .with(DISTANCE, MAX_DISTANCE) - .with(PERSISTENT, false) - .with(WATERLOGGED, false)); + this.registerDefaultState(this.stateDefinition.any() + .setValue(DISTANCE, MAX_DISTANCE) + .setValue(PERSISTENT, false) + .setValue(WATERLOGGED, false)); } @Override - protected VoxelShape getSidesShape(BlockState state, BlockView world, BlockPos pos) { - return VoxelShapes.empty(); + protected VoxelShape getBlockSupportShape(BlockState state, BlockGetter world, BlockPos pos) { + return Shapes.empty(); } @Override - public boolean hasRandomTicks(BlockState state) { - return state.get(DISTANCE) == MAX_DISTANCE && !state.get(PERSISTENT); + public boolean isRandomlyTicking(BlockState state) { + return state.getValue(DISTANCE) == MAX_DISTANCE && !state.getValue(PERSISTENT); } @Override - public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { + public void randomTick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) { if (this.shouldDecay(state)) { - ExtendedLeavesBlock.dropStacks(state, world, pos); + ExtendedLeavesBlock.dropResources(state, world, pos); world.removeBlock(pos, false); } } protected boolean shouldDecay(BlockState state) { - return !state.get(PERSISTENT) && state.get(DISTANCE) == MAX_DISTANCE; + return !state.getValue(PERSISTENT) && state.getValue(DISTANCE) == MAX_DISTANCE; } @Override - public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { - world.setBlockState(pos, ExtendedLeavesBlock.updateDistanceFromLogs(state, world, pos), 3); + public void tick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) { + world.setBlock(pos, ExtendedLeavesBlock.updateDistanceFromLogs(state, world, pos), 3); } @Override - protected int getOpacity(BlockState state) { + protected int getLightDampening(BlockState state) { return 1; } @Override - protected BlockState getStateForNeighborUpdate(BlockState state, WorldView world, ScheduledTickView tickView, BlockPos pos, Direction direction, BlockPos neighborPos, BlockState neighborState, Random random) { - if (state.get(WATERLOGGED)) { - tickView.scheduleFluidTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)); + protected BlockState updateShape(BlockState state, LevelReader world, ScheduledTickAccess tickView, BlockPos pos, Direction direction, BlockPos neighborPos, BlockState neighborState, RandomSource random) { + if (state.getValue(WATERLOGGED)) { + tickView.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world)); } int distance = ExtendedLeavesBlock.getDistanceFromLog(neighborState) + 1; - if (distance != 1 || state.get(DISTANCE) != distance) { - tickView.scheduleBlockTick(pos, this, 1); + if (distance != 1 || state.getValue(DISTANCE) != distance) { + tickView.scheduleTick(pos, this, 1); } return state; } - private static BlockState updateDistanceFromLogs(BlockState state, WorldAccess world, BlockPos pos) { + private static BlockState updateDistanceFromLogs(BlockState state, LevelAccessor world, BlockPos pos) { int distance = MAX_DISTANCE; - BlockPos.Mutable mutable = new BlockPos.Mutable(); + BlockPos.MutableBlockPos mutable = new BlockPos.MutableBlockPos(); for (Direction direction : Direction.values()) { - mutable.set(pos, direction); + mutable.setWithOffset(pos, direction); distance = Math.min(distance, ExtendedLeavesBlock.getDistanceFromLog(world.getBlockState(mutable)) + 1); if (distance == 1) { break; } } - return state.with(DISTANCE, distance); + return state.setValue(DISTANCE, distance); } private static int getDistanceFromLog(BlockState state) { - if (state.isIn(BlockTags.LOGS)) { + if (state.is(BlockTags.LOGS)) { return 0; } Block block = state.getBlock(); if (block instanceof ExtendedLeavesBlock) { - return state.get(DISTANCE); + return state.getValue(DISTANCE); } else if (block instanceof LeavesBlock) { - int distance = state.get(LeavesBlock.DISTANCE); - return distance < LeavesBlock.MAX_DISTANCE ? distance : MAX_DISTANCE; + int distance = state.getValue(LeavesBlock.DISTANCE); + return distance < LeavesBlock.DECAY_DISTANCE ? distance : MAX_DISTANCE; } return MAX_DISTANCE; } @Override - public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random random) { - super.randomDisplayTick(state, world, pos, random); - BlockPos blockPos = pos.down(); + public void animateTick(BlockState state, Level world, BlockPos pos, RandomSource random) { + super.animateTick(state, world, pos, random); + BlockPos blockPos = pos.below(); BlockState blockState = world.getBlockState(blockPos); spawnWaterParticle(world, pos, random, blockState, blockPos); this.spawnLeafParticle(world, pos, random, blockState, blockPos); } - private static void spawnWaterParticle(World world, BlockPos pos, Random random, BlockState state, BlockPos posBelow) { - if (world.hasRain(pos.up())) { + private static void spawnWaterParticle(Level world, BlockPos pos, RandomSource random, BlockState state, BlockPos posBelow) { + if (world.isRainingAt(pos.above())) { if (random.nextInt(15) == 1) { - if (!state.isOpaque() || !state.isSideSolidFullSquare(world, posBelow, Direction.UP)) { - ParticleUtil.spawnParticle(world, pos, random, ParticleTypes.DRIPPING_WATER); + if (!state.canOcclude() || !state.isFaceSturdy(world, posBelow, Direction.UP)) { + ParticleUtils.spawnParticleBelow(world, pos, random, ParticleTypes.DRIPPING_WATER); } } } } - private void spawnLeafParticle(World world, BlockPos pos, Random random, BlockState state, BlockPos posBelow) { + private void spawnLeafParticle(Level world, BlockPos pos, RandomSource random, BlockState state, BlockPos posBelow) { if (!(random.nextFloat() >= this.leafParticleChance)) { - if (!isFaceFullSquare(state.getCollisionShape(world, posBelow), Direction.UP)) { + if (!isFaceFull(state.getCollisionShape(world, posBelow), Direction.UP)) { this.spawnLeafParticle(world, pos, random); } } } - protected abstract void spawnLeafParticle(World world, BlockPos pos, Random random); + protected abstract void spawnLeafParticle(Level world, BlockPos pos, RandomSource random); @Override - protected void appendProperties(StateManager.Builder builder) { + protected void createBlockStateDefinition(StateDefinition.Builder builder) { builder.add(DISTANCE, PERSISTENT, WATERLOGGED); } @Override - public BlockState getPlacementState(ItemPlacementContext context) { - FluidState fluidState = context.getWorld().getFluidState(context.getBlockPos()); - BlockState blockState = this.getDefaultState().with(PERSISTENT, true).with(WATERLOGGED, fluidState.getFluid() == Fluids.WATER); + public BlockState getStateForPlacement(BlockPlaceContext context) { + FluidState fluidState = context.getLevel().getFluidState(context.getClickedPos()); + BlockState blockState = this.defaultBlockState().setValue(PERSISTENT, true).setValue(WATERLOGGED, fluidState.getType() == Fluids.WATER); - return ExtendedLeavesBlock.updateDistanceFromLogs(blockState, context.getWorld(), context.getBlockPos()); + return ExtendedLeavesBlock.updateDistanceFromLogs(blockState, context.getLevel(), context.getClickedPos()); } } \ No newline at end of file diff --git a/src/main/java/fr/hugman/promenade/block/FungusBlock.java b/src/main/java/fr/hugman/promenade/block/FungusBlock.java index c3b70b41..ad985348 100644 --- a/src/main/java/fr/hugman/promenade/block/FungusBlock.java +++ b/src/main/java/fr/hugman/promenade/block/FungusBlock.java @@ -1,37 +1,37 @@ package fr.hugman.promenade.block; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.registry.RegistryKey; -import net.minecraft.registry.tag.TagKey; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.BlockView; -import net.minecraft.world.WorldView; -import net.minecraft.world.gen.feature.ConfiguredFeature; - import java.util.function.Predicate; +import net.minecraft.core.BlockPos; +import net.minecraft.resources.ResourceKey; +import net.minecraft.tags.TagKey; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.NetherFungusBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; -public class FungusBlock extends net.minecraft.block.FungusBlock { +public class FungusBlock extends NetherFungusBlock { private final Predicate canPlantOn; private final Predicate canGrowOn; - public FungusBlock(RegistryKey> featureKey, TagKey canPlantOn, TagKey canGrowOn, Settings settings) { - this(featureKey, s -> s.isIn(canPlantOn), s -> s.isIn(canGrowOn), settings); + public FungusBlock(ResourceKey> featureKey, TagKey canPlantOn, TagKey canGrowOn, Properties settings) { + this(featureKey, s -> s.is(canPlantOn), s -> s.is(canGrowOn), settings); } - public FungusBlock(RegistryKey> featureKey, Predicate canPlantOn, Predicate canGrowOn, Settings settings) { - super(featureKey, null, settings); + public FungusBlock(ResourceKey> featureKey, Predicate canPlantOn, Predicate canGrowOn, Properties settings) { + super(featureKey, null, null, settings); this.canPlantOn = canPlantOn; this.canGrowOn = canGrowOn; } @Override - public boolean isFertilizable(WorldView world, BlockPos pos, BlockState state) { - return this.canGrowOn.test(world.getBlockState(pos.down())); + public boolean isValidBonemealTarget(LevelReader world, BlockPos pos, BlockState state) { + return this.canGrowOn.test(world.getBlockState(pos.below())); } @Override - protected boolean canPlantOnTop(BlockState floor, BlockView world, BlockPos pos) { + protected boolean mayPlaceOn(BlockState floor, BlockGetter world, BlockPos pos) { return this.canPlantOn.test(floor); } } \ No newline at end of file diff --git a/src/main/java/fr/hugman/promenade/block/HangingLeavesBlock.java b/src/main/java/fr/hugman/promenade/block/HangingLeavesBlock.java index c2551b78..ec55f3d2 100644 --- a/src/main/java/fr/hugman/promenade/block/HangingLeavesBlock.java +++ b/src/main/java/fr/hugman/promenade/block/HangingLeavesBlock.java @@ -1,80 +1,85 @@ package fr.hugman.promenade.block; import com.mojang.serialization.MapCodec; -import net.minecraft.block.*; -import net.minecraft.fluid.FluidState; -import net.minecraft.fluid.Fluids; -import net.minecraft.item.ItemPlacementContext; -import net.minecraft.registry.tag.BlockTags; -import net.minecraft.state.StateManager; -import net.minecraft.state.property.BooleanProperty; -import net.minecraft.state.property.Properties; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.random.Random; -import net.minecraft.util.shape.VoxelShape; -import net.minecraft.world.BlockView; -import net.minecraft.world.WorldView; -import net.minecraft.world.tick.ScheduledTickView; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.tags.BlockTags; +import net.minecraft.util.RandomSource; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.ScheduledTickAccess; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.SimpleWaterloggedBlock; +import net.minecraft.world.level.block.state.BlockBehaviour; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.StateDefinition; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.world.level.material.Fluids; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; import org.jetbrains.annotations.Nullable; -public class HangingLeavesBlock extends Block implements Waterloggable { - private static final BooleanProperty WATERLOGGED = Properties.WATERLOGGED; - protected static final VoxelShape SHAPE = Block.createCuboidShape(2.0, 10.0, 2.0, 14.0, 16.0, 14.0); - public static final MapCodec CODEC = createCodec(HangingLeavesBlock::new); +public class HangingLeavesBlock extends Block implements SimpleWaterloggedBlock { + private static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; + protected static final VoxelShape SHAPE = Block.box(2.0, 10.0, 2.0, 14.0, 16.0, 14.0); + public static final MapCodec CODEC = simpleCodec(HangingLeavesBlock::new); - public HangingLeavesBlock(AbstractBlock.Settings settings) { + public HangingLeavesBlock(BlockBehaviour.Properties settings) { super(settings); - this.setDefaultState(this.stateManager.getDefaultState().with(WATERLOGGED, false)); + this.registerDefaultState(this.stateDefinition.any().setValue(WATERLOGGED, false)); } @Override - public MapCodec getCodec() { + public MapCodec codec() { return CODEC; } @Override - protected void appendProperties(StateManager.Builder builder) { + protected void createBlockStateDefinition(StateDefinition.Builder builder) { builder.add(WATERLOGGED); } @Override public FluidState getFluidState(BlockState state) { - return state.get(WATERLOGGED) ? Fluids.WATER.getStill(false) : super.getFluidState(state); + return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(state); } @Nullable @Override - public BlockState getPlacementState(ItemPlacementContext ctx) { - BlockState blockState = super.getPlacementState(ctx); + public BlockState getStateForPlacement(BlockPlaceContext ctx) { + BlockState blockState = super.getStateForPlacement(ctx); if (blockState != null) { - FluidState fluidState = ctx.getWorld().getFluidState(ctx.getBlockPos()); - return blockState.with(WATERLOGGED, fluidState.getFluid() == Fluids.WATER); + FluidState fluidState = ctx.getLevel().getFluidState(ctx.getClickedPos()); + return blockState.setValue(WATERLOGGED, fluidState.getType() == Fluids.WATER); } else { return null; } } @Override - public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { - BlockPos blockPos = pos.up(); + public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) { + BlockPos blockPos = pos.above(); BlockState blockState = world.getBlockState(blockPos); - return (blockState.isIn(BlockTags.LEAVES) && blockState.isSolid()) || blockState.isSideSolidFullSquare(world, blockPos, Direction.DOWN); + return (blockState.is(BlockTags.LEAVES) && blockState.isSolid()) || blockState.isFaceSturdy(world, blockPos, Direction.DOWN); } @Override - public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) { + public VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) { return SHAPE; } @Override - protected BlockState getStateForNeighborUpdate(BlockState state, WorldView world, ScheduledTickView tickView, BlockPos pos, Direction direction, BlockPos neighborPos, BlockState neighborState, Random random) { - if (direction == Direction.UP && !this.canPlaceAt(state, world, pos)) { - return Blocks.AIR.getDefaultState(); + protected BlockState updateShape(BlockState state, LevelReader world, ScheduledTickAccess tickView, BlockPos pos, Direction direction, BlockPos neighborPos, BlockState neighborState, RandomSource random) { + if (direction == Direction.UP && !this.canSurvive(state, world, pos)) { + return Blocks.AIR.defaultBlockState(); } - if (state.get(WATERLOGGED)) { - tickView.scheduleFluidTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)); + if (state.getValue(WATERLOGGED)) { + tickView.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world)); } - return super.getStateForNeighborUpdate(state, world, tickView, pos, direction, neighborPos, neighborState, random); + return super.updateShape(state, world, tickView, pos, direction, neighborPos, neighborState, random); } } diff --git a/src/main/java/fr/hugman/promenade/block/MapleLogBlock.java b/src/main/java/fr/hugman/promenade/block/MapleLogBlock.java index 51e2e841..4c73b00c 100644 --- a/src/main/java/fr/hugman/promenade/block/MapleLogBlock.java +++ b/src/main/java/fr/hugman/promenade/block/MapleLogBlock.java @@ -2,29 +2,29 @@ import com.mojang.serialization.MapCodec; import fr.hugman.promenade.block.property.PromenadeBlockProperties; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.PillarBlock; -import net.minecraft.state.StateManager; -import net.minecraft.state.property.BooleanProperty; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.RotatedPillarBlock; +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; -public class MapleLogBlock extends PillarBlock { +public class MapleLogBlock extends RotatedPillarBlock { public static final BooleanProperty NATURAL = PromenadeBlockProperties.NATURAL; - public static final MapCodec CODEC = createCodec(MapleLogBlock::new); + public static final MapCodec CODEC = simpleCodec(MapleLogBlock::new); - public MapleLogBlock(Settings settings) { + public MapleLogBlock(Properties settings) { super(settings); - this.setDefaultState(this.getDefaultState().with(NATURAL, false)); + this.registerDefaultState(this.defaultBlockState().setValue(NATURAL, false)); } @Override - public MapCodec getCodec() { + public MapCodec codec() { return CODEC; } @Override - protected void appendProperties(StateManager.Builder builder) { - super.appendProperties(builder); + protected void createBlockStateDefinition(StateDefinition.Builder builder) { + super.createBlockStateDefinition(builder); builder.add(NATURAL); } } diff --git a/src/main/java/fr/hugman/promenade/block/MoaiBlock.java b/src/main/java/fr/hugman/promenade/block/MoaiBlock.java index 4ec7350c..6e34f683 100644 --- a/src/main/java/fr/hugman/promenade/block/MoaiBlock.java +++ b/src/main/java/fr/hugman/promenade/block/MoaiBlock.java @@ -2,51 +2,51 @@ import com.mojang.serialization.MapCodec; import fr.hugman.promenade.block.property.PromenadeBlockProperties; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.HorizontalFacingBlock; -import net.minecraft.entity.LivingEntity; -import net.minecraft.item.ItemPlacementContext; -import net.minecraft.item.ItemStack; -import net.minecraft.state.StateManager; -import net.minecraft.state.property.EnumProperty; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.random.Random; -import net.minecraft.world.World; -import net.minecraft.world.WorldView; -import net.minecraft.world.tick.ScheduledTickView; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.util.RandomSource; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.ScheduledTickAccess; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.HorizontalDirectionalBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.StateDefinition; +import net.minecraft.world.level.block.state.properties.EnumProperty; import org.jetbrains.annotations.Nullable; -public class MoaiBlock extends HorizontalFacingBlock { - public static final MapCodec CODEC = createCodec(MoaiBlock::new); +public class MoaiBlock extends HorizontalDirectionalBlock { + public static final MapCodec CODEC = simpleCodec(MoaiBlock::new); public static final EnumProperty TYPE = PromenadeBlockProperties.MOAI_TYPE; - public MoaiBlock(Settings settings) { + public MoaiBlock(Properties settings) { super(settings); - this.setDefaultState(this.stateManager.getDefaultState().with(TYPE, MoaiType.SINGLE).with(FACING, Direction.NORTH)); + this.registerDefaultState(this.stateDefinition.any().setValue(TYPE, MoaiType.SINGLE).setValue(FACING, Direction.NORTH)); } @Override - protected MapCodec getCodec() { + protected MapCodec codec() { return CODEC; } @Override - protected void appendProperties(StateManager.Builder builder) { - super.appendProperties(builder); + protected void createBlockStateDefinition(StateDefinition.Builder builder) { + super.createBlockStateDefinition(builder); builder.add(TYPE, FACING); } @Override - public BlockState getPlacementState(ItemPlacementContext context) { - var world = context.getWorld(); - boolean sneaking = context.shouldCancelInteraction(); // stupid yarn name - var direction = context.getHorizontalPlayerFacing().getOpposite(); - var hitSide = context.getSide(); + public BlockState getStateForPlacement(BlockPlaceContext context) { + var world = context.getLevel(); + boolean sneaking = context.isSecondaryUseActive(); // stupid yarn name + var direction = context.getHorizontalDirection().getOpposite(); + var hitSide = context.getClickedFace(); - var posBelow = context.getBlockPos().down(); - var posAbove = context.getBlockPos().up(); + var posBelow = context.getClickedPos().below(); + var posAbove = context.getClickedPos().above(); boolean mergeWithBelow = isSingleMoai(direction, world.getBlockState(posBelow)); boolean mergeWithAbove = isSingleMoai(direction, world.getBlockState(posAbove)); @@ -65,41 +65,41 @@ public BlockState getPlacementState(ItemPlacementContext context) { } if (mergeWithBelow) { - return this.getDefaultState().with(TYPE, MoaiType.TOP).with(FACING, direction); + return this.defaultBlockState().setValue(TYPE, MoaiType.TOP).setValue(FACING, direction); } else if (mergeWithAbove) { - return this.getDefaultState().with(TYPE, MoaiType.BOTTOM).with(FACING, direction); + return this.defaultBlockState().setValue(TYPE, MoaiType.BOTTOM).setValue(FACING, direction); } else { - return this.getDefaultState().with(TYPE, MoaiType.SINGLE).with(FACING, direction); + return this.defaultBlockState().setValue(TYPE, MoaiType.SINGLE).setValue(FACING, direction); } } @Override - public void onPlaced(World world, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack itemStack) { - super.onPlaced(world, pos, state, placer, itemStack); - var type = state.get(TYPE); - var direction = state.get(FACING); - var posBelow = pos.down(); - var posAbove = pos.up(); + public void setPlacedBy(Level world, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack itemStack) { + super.setPlacedBy(world, pos, state, placer, itemStack); + var type = state.getValue(TYPE); + var direction = state.getValue(FACING); + var posBelow = pos.below(); + var posAbove = pos.above(); if (isSingleMoai(direction, world.getBlockState(posBelow)) && type == MoaiType.TOP) { - world.setBlockState(posBelow, world.getBlockState(posBelow).with(TYPE, MoaiType.BOTTOM), Block.NOTIFY_ALL); + world.setBlock(posBelow, world.getBlockState(posBelow).setValue(TYPE, MoaiType.BOTTOM), Block.UPDATE_ALL); } else if (isSingleMoai(direction, world.getBlockState(posAbove)) && type == MoaiType.BOTTOM) { - world.setBlockState(posAbove, world.getBlockState(posAbove).with(TYPE, MoaiType.TOP), Block.NOTIFY_ALL); + world.setBlock(posAbove, world.getBlockState(posAbove).setValue(TYPE, MoaiType.TOP), Block.UPDATE_ALL); } } @Override - protected BlockState getStateForNeighborUpdate(BlockState state, WorldView world, ScheduledTickView tickView, BlockPos pos, Direction direction, BlockPos neighborPos, BlockState neighborState, Random random) { - var type = state.get(TYPE); + protected BlockState updateShape(BlockState state, LevelReader world, ScheduledTickAccess tickView, BlockPos pos, Direction direction, BlockPos neighborPos, BlockState neighborState, RandomSource random) { + var type = state.getValue(TYPE); if ((type == MoaiType.TOP && direction == Direction.DOWN) || (type == MoaiType.BOTTOM && direction == Direction.UP)) { - if (!(neighborState.isOf(this) && neighborState.get(TYPE) == (type == MoaiType.TOP ? MoaiType.BOTTOM : MoaiType.TOP))) { - return state.with(TYPE, MoaiType.SINGLE); + if (!(neighborState.is(this) && neighborState.getValue(TYPE) == (type == MoaiType.TOP ? MoaiType.BOTTOM : MoaiType.TOP))) { + return state.setValue(TYPE, MoaiType.SINGLE); } } return state; } public boolean isSingleMoai(Direction direction, BlockState state) { - return state.isOf(this) && state.get(TYPE) == MoaiType.SINGLE && state.get(FACING) == direction; + return state.is(this) && state.getValue(TYPE) == MoaiType.SINGLE && state.getValue(FACING) == direction; } } diff --git a/src/main/java/fr/hugman/promenade/block/MoaiType.java b/src/main/java/fr/hugman/promenade/block/MoaiType.java index c87cfd79..09cc5d38 100644 --- a/src/main/java/fr/hugman/promenade/block/MoaiType.java +++ b/src/main/java/fr/hugman/promenade/block/MoaiType.java @@ -1,8 +1,8 @@ package fr.hugman.promenade.block; -import net.minecraft.util.StringIdentifiable; +import net.minecraft.util.StringRepresentable; -public enum MoaiType implements StringIdentifiable { +public enum MoaiType implements StringRepresentable { SINGLE("single"), TOP("top"), BOTTOM("bottom"); @@ -14,7 +14,7 @@ public enum MoaiType implements StringIdentifiable { } @Override - public String asString() { + public String getSerializedName() { return this.name; } } \ No newline at end of file diff --git a/src/main/java/fr/hugman/promenade/block/NyliumBlock.java b/src/main/java/fr/hugman/promenade/block/NyliumBlock.java index 1ba4d29c..f8096e93 100644 --- a/src/main/java/fr/hugman/promenade/block/NyliumBlock.java +++ b/src/main/java/fr/hugman/promenade/block/NyliumBlock.java @@ -2,82 +2,82 @@ import com.mojang.serialization.MapCodec; import fr.hugman.promenade.world.gen.feature.PromenadeConfiguredFeatures; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.Fertilizable; -import net.minecraft.registry.Registry; -import net.minecraft.registry.RegistryKey; -import net.minecraft.registry.RegistryKeys; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.random.Random; -import net.minecraft.world.World; -import net.minecraft.world.WorldView; -import net.minecraft.world.chunk.light.ChunkLightProvider; -import net.minecraft.world.gen.chunk.ChunkGenerator; -import net.minecraft.world.gen.feature.ConfiguredFeature; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.core.Registry; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceKey; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.util.RandomSource; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.BonemealableBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.chunk.ChunkGenerator; +import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; +import net.minecraft.world.level.lighting.LightEngine; -public class NyliumBlock extends Block implements Fertilizable { - public static final MapCodec CODEC = createCodec(NyliumBlock::new); +public class NyliumBlock extends Block implements BonemealableBlock { + public static final MapCodec CODEC = simpleCodec(NyliumBlock::new); @Override - public MapCodec getCodec() { + public MapCodec codec() { return CODEC; } - public NyliumBlock(Settings settings) { + public NyliumBlock(Properties settings) { super(settings); } - private static boolean stayAlive(BlockState state, WorldView world, BlockPos pos) { - BlockPos blockPos = pos.up(); + private static boolean stayAlive(BlockState state, LevelReader world, BlockPos pos) { + BlockPos blockPos = pos.above(); BlockState blockState = world.getBlockState(blockPos); - int i = ChunkLightProvider.getRealisticOpacity(state, blockState, Direction.UP, blockState.getOpacity()); + int i = LightEngine.getLightBlockInto(state, blockState, Direction.UP, blockState.getLightDampening()); return i < 15; } @Override - protected void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { + protected void randomTick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) { if (!stayAlive(state, world, pos)) { //TODO: make this configurable - world.setBlockState(pos, Blocks.NETHERRACK.getDefaultState()); + world.setBlockAndUpdate(pos, Blocks.NETHERRACK.defaultBlockState()); } } @Override - public boolean isFertilizable(WorldView world, BlockPos pos, BlockState state) { - return world.getBlockState(pos.up()).isAir(); + public boolean isValidBonemealTarget(LevelReader world, BlockPos pos, BlockState state) { + return world.getBlockState(pos.above()).isAir(); } @Override - public boolean canGrow(World world, Random random, BlockPos pos, BlockState state) { + public boolean isBonemealSuccess(Level world, RandomSource random, BlockPos pos, BlockState state) { return true; } @Override - public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) { - BlockPos blockPos = pos.up(); - ChunkGenerator chunkGenerator = world.getChunkManager().getChunkGenerator(); - Registry> registry = world.getRegistryManager().getOrThrow(RegistryKeys.CONFIGURED_FEATURE); + public void performBonemeal(ServerLevel world, RandomSource random, BlockPos pos, BlockState state) { + BlockPos blockPos = pos.above(); + ChunkGenerator chunkGenerator = world.getChunkSource().getGenerator(); + Registry> registry = world.registryAccess().lookupOrThrow(Registries.CONFIGURED_FEATURE); //TODO: make this configurable this.generate(registry, PromenadeConfiguredFeatures.DARK_AMARANTH_FOREST_BONEMEAL_VEGETATION, world, chunkGenerator, random, blockPos); } private void generate( Registry> registry, - RegistryKey> key, - ServerWorld world, + ResourceKey> key, + ServerLevel world, ChunkGenerator chunkGenerator, - Random random, + RandomSource random, BlockPos pos ) { - registry.getOptional(key).ifPresent(entry -> entry.value().generate(world, chunkGenerator, random, pos)); + registry.get(key).ifPresent(entry -> entry.value().place(world, chunkGenerator, random, pos)); } @Override - public FertilizableType getFertilizableType() { - return FertilizableType.NEIGHBOR_SPREADER; + public Type getType() { + return Type.NEIGHBOR_SPREADER; } } diff --git a/src/main/java/fr/hugman/promenade/block/PileBlock.java b/src/main/java/fr/hugman/promenade/block/PileBlock.java index b9c51e36..2c36c138 100644 --- a/src/main/java/fr/hugman/promenade/block/PileBlock.java +++ b/src/main/java/fr/hugman/promenade/block/PileBlock.java @@ -1,47 +1,51 @@ package fr.hugman.promenade.block; import com.mojang.serialization.MapCodec; -import net.minecraft.block.*; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.random.Random; -import net.minecraft.util.shape.VoxelShape; -import net.minecraft.world.BlockView; -import net.minecraft.world.WorldView; -import net.minecraft.world.tick.ScheduledTickView; - -public class PileBlock extends PlantBlock { - public static final MapCodec CODEC = createCodec(PileBlock::new); - protected static final VoxelShape SHAPE = Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 1.0D, 16.0D); - - public PileBlock(Settings settings) { +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.util.RandomSource; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.ScheduledTickAccess; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.VegetationBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; + +public class PileBlock extends VegetationBlock { + public static final MapCodec CODEC = simpleCodec(PileBlock::new); + protected static final VoxelShape SHAPE = Block.box(0.0D, 0.0D, 0.0D, 16.0D, 1.0D, 16.0D); + + public PileBlock(Properties settings) { super(settings); } @Override - protected MapCodec getCodec() { + protected MapCodec codec() { return CODEC; } @Override - public VoxelShape getOutlineShape(BlockState state, BlockView worldIn, BlockPos pos, ShapeContext context) { + public VoxelShape getShape(BlockState state, BlockGetter worldIn, BlockPos pos, CollisionContext context) { return SHAPE; } @Override - protected int getOpacity(BlockState state) { + protected int getLightDampening(BlockState state) { return 1; } @Override - protected BlockState getStateForNeighborUpdate(BlockState state, WorldView world, ScheduledTickView tickView, BlockPos pos, Direction direction, BlockPos neighborPos, BlockState neighborState, Random random) { - return !state.canPlaceAt(world, pos) ? Blocks.AIR.getDefaultState() : super.getStateForNeighborUpdate(state, world, tickView, pos, direction, neighborPos, neighborState, random); + protected BlockState updateShape(BlockState state, LevelReader world, ScheduledTickAccess tickView, BlockPos pos, Direction direction, BlockPos neighborPos, BlockState neighborState, RandomSource random) { + return !state.canSurvive(world, pos) ? Blocks.AIR.defaultBlockState() : super.updateShape(state, world, tickView, pos, direction, neighborPos, neighborState, random); } @Override - public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { - BlockPos blockpos = pos.offset(Direction.DOWN); + public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) { + BlockPos blockpos = pos.relative(Direction.DOWN); BlockState blockState = world.getBlockState(blockpos); - return Block.isFaceFullSquare(blockState.getCollisionShape(world, blockpos), Direction.UP); + return Block.isFaceFull(blockState.getCollisionShape(world, blockpos), Direction.UP); } } \ No newline at end of file diff --git a/src/main/java/fr/hugman/promenade/block/PromenadeBlockTypes.java b/src/main/java/fr/hugman/promenade/block/PromenadeBlockTypes.java index b427e11d..61c4f4a2 100644 --- a/src/main/java/fr/hugman/promenade/block/PromenadeBlockTypes.java +++ b/src/main/java/fr/hugman/promenade/block/PromenadeBlockTypes.java @@ -2,9 +2,9 @@ import com.mojang.serialization.MapCodec; import fr.hugman.promenade.Promenade; -import net.minecraft.block.Block; -import net.minecraft.registry.Registries; -import net.minecraft.registry.Registry; +import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.world.level.block.Block; public class PromenadeBlockTypes { public static final MapCodec BERRY_BUSH = of("berry_bush", BerryBushBlock.CODEC); @@ -23,6 +23,6 @@ public class PromenadeBlockTypes { public static final MapCodec NYLIUM = of("nylium", NyliumBlock.CODEC); private static MapCodec of(String path, MapCodec blockType) { - return Registry.register(Registries.BLOCK_TYPE, Promenade.id(path), blockType); + return Registry.register(BuiltInRegistries.BLOCK_TYPE, Promenade.id(path), blockType); } } diff --git a/src/main/java/fr/hugman/promenade/block/PromenadeBlocks.java b/src/main/java/fr/hugman/promenade/block/PromenadeBlocks.java index f78b6d79..134a4466 100644 --- a/src/main/java/fr/hugman/promenade/block/PromenadeBlocks.java +++ b/src/main/java/fr/hugman/promenade/block/PromenadeBlocks.java @@ -12,21 +12,24 @@ import fr.hugman.promenade.tag.PromenadeBlockTags; import fr.hugman.promenade.world.PromenadeSaplingGenerators; import fr.hugman.promenade.world.gen.feature.PromenadeConfiguredFeatures; -import net.minecraft.block.*; -import net.minecraft.block.enums.NoteBlockInstrument; -import net.minecraft.block.piston.PistonBehavior; -import net.minecraft.entity.EquipmentSlot; -import net.minecraft.particle.ParticleTypes; -import net.minecraft.registry.RegistryKey; -import net.minecraft.registry.RegistryKeys; -import net.minecraft.registry.tag.BlockTags; -import net.minecraft.sound.BlockSoundGroup; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceKey; +import net.minecraft.tags.BlockTags; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.world.level.block.state.BlockBehaviour; +import net.minecraft.world.level.block.state.properties.NoteBlockInstrument; +import net.minecraft.world.level.material.MapColor; +import net.minecraft.world.level.material.PushReaction; public class PromenadeBlocks { /* ========= */ /* ROCKS */ /* ========= */ - public static final Block ASPHALT = register("asphalt", BlockFactory.of(BlockSettings.rock(MapColor.DEEPSLATE_GRAY, BlockSoundGroup.BASALT))); + public static final Block ASPHALT = register("asphalt", BlockFactory.of(BlockSettings.rock(MapColor.DEEPSLATE, SoundType.BASALT))); public static final Block ASPHALT_SLAB = register("asphalt_slab", BlockFactory.slab(ASPHALT)); public static final Block ASPHALT_STAIRS = register("asphalt_stairs", BlockFactory.stairs(ASPHALT)); public static final Block ASPHALT_WALL = register("asphalt_wall", BlockFactory.wall(ASPHALT)); @@ -35,7 +38,7 @@ public class PromenadeBlocks { public static final Block POLISHED_ASPHALT_SLAB = register("polished_asphalt_slab", BlockFactory.slab(POLISHED_ASPHALT)); public static final Block POLISHED_ASPHALT_STAIRS = register("polished_asphalt_stairs", BlockFactory.stairs(POLISHED_ASPHALT)); - public static final Block BLUNITE = register("blunite", BlockFactory.of(BlockSettings.rock(MapColor.TERRACOTTA_CYAN, BlockSoundGroup.TUFF))); + public static final Block BLUNITE = register("blunite", BlockFactory.of(BlockSettings.rock(MapColor.TERRACOTTA_CYAN, SoundType.TUFF))); public static final Block BLUNITE_SLAB = register("blunite_slab", BlockFactory.slab(BLUNITE)); public static final Block BLUNITE_STAIRS = register("blunite_stairs", BlockFactory.stairs(BLUNITE)); public static final Block BLUNITE_WALL = register("blunite_wall", BlockFactory.wall(BLUNITE)); @@ -53,26 +56,26 @@ public class PromenadeBlocks { public static final Block BIRCH_LEAF_PILE = register("birch_leaf_pile", BlockFactory.pile()); public static final Block JUNGLE_LEAF_PILE = register("jungle_leaf_pile", BlockFactory.pile()); public static final Block ACACIA_LEAF_PILE = register("acacia_leaf_pile", BlockFactory.pile()); - public static final Block CHERRY_LEAF_PILE = register("cherry_leaf_pile", BlockFactory.pile(MapColor.PINK).settings(s -> s.sounds(BlockSoundGroup.CHERRY_LEAVES))); + public static final Block CHERRY_LEAF_PILE = register("cherry_leaf_pile", BlockFactory.pile(MapColor.COLOR_PINK).settings(s -> s.sound(SoundType.CHERRY_LEAVES))); public static final Block DARK_OAK_LEAF_PILE = register("dark_oak_leaf_pile", BlockFactory.pile()); public static final Block PALE_OAK_LEAF_PILE = register("pale_oak_leaf_pile", BlockFactory.pile()); public static final Block MANGROVE_LEAF_PILE = register("mangrove_leaf_pile", BlockFactory.pile()); - public static final Block AZALEA_LEAF_PILE = register("azalea_leaf_pile", BlockFactory.pile().settings(s -> s.sounds(BlockSoundGroup.AZALEA_LEAVES))); - public static final Block FLOWERING_AZALEA_LEAF_PILE = register("flowering_azalea_leaf_pile", BlockFactory.pile().settings(s -> s.sounds(BlockSoundGroup.AZALEA_LEAVES))); + public static final Block AZALEA_LEAF_PILE = register("azalea_leaf_pile", BlockFactory.pile().settings(s -> s.sound(SoundType.AZALEA_LEAVES))); + public static final Block FLOWERING_AZALEA_LEAF_PILE = register("flowering_azalea_leaf_pile", BlockFactory.pile().settings(s -> s.sound(SoundType.AZALEA_LEAVES))); public static final Block DANDELION_PILE = register("dandelion_pile", BlockFactory.pile(MapColor.GOLD)); - public static final Block POPPY_PILE = register("poppy_pile", BlockFactory.pile(MapColor.DULL_RED)); - public static final Block BLUE_ORCHID_PILE = register("blue_orchid_pile", BlockFactory.pile(MapColor.LIGHT_BLUE)); - public static final Block ALLIUM_PILE = register("allium_pile", BlockFactory.pile(MapColor.MAGENTA)); - public static final Block AZURE_BLUET_PILE = register("azure_bluet_pile", BlockFactory.pile(MapColor.PALE_YELLOW)); - public static final Block RED_TULIP_PILE = register("red_tulip_pile", BlockFactory.pile(MapColor.DULL_RED)); - public static final Block ORANGE_TULIP_PILE = register("orange_tulip_pile", BlockFactory.pile(MapColor.ORANGE)); - public static final Block WHITE_TULIP_PILE = register("white_tulip_pile", BlockFactory.pile(MapColor.WHITE)); - public static final Block PINK_TULIP_PILE = register("pink_tulip_pile", BlockFactory.pile(MapColor.PINK)); + public static final Block POPPY_PILE = register("poppy_pile", BlockFactory.pile(MapColor.CRIMSON_NYLIUM)); + public static final Block BLUE_ORCHID_PILE = register("blue_orchid_pile", BlockFactory.pile(MapColor.COLOR_LIGHT_BLUE)); + public static final Block ALLIUM_PILE = register("allium_pile", BlockFactory.pile(MapColor.COLOR_MAGENTA)); + public static final Block AZURE_BLUET_PILE = register("azure_bluet_pile", BlockFactory.pile(MapColor.SAND)); + public static final Block RED_TULIP_PILE = register("red_tulip_pile", BlockFactory.pile(MapColor.CRIMSON_NYLIUM)); + public static final Block ORANGE_TULIP_PILE = register("orange_tulip_pile", BlockFactory.pile(MapColor.COLOR_ORANGE)); + public static final Block WHITE_TULIP_PILE = register("white_tulip_pile", BlockFactory.pile(MapColor.SNOW)); + public static final Block PINK_TULIP_PILE = register("pink_tulip_pile", BlockFactory.pile(MapColor.COLOR_PINK)); public static final Block OXEYE_DAISY_PILE = register("oxeye_daisy_pile", BlockFactory.pile(MapColor.GOLD)); - public static final Block CORNFLOWER_PILE = register("cornflower_pile", BlockFactory.pile(MapColor.LAPIS_BLUE)); - public static final Block LILY_OF_THE_VALLEY_PILE = register("lily_of_the_valley_pile", BlockFactory.pile(MapColor.WHITE)); - public static final Block WITHER_ROSE_PILE = register("wither_rose_pile", BlockFactory.pile(MapColor.BLACK).factory(WitherRosePileBlock::new)); + public static final Block CORNFLOWER_PILE = register("cornflower_pile", BlockFactory.pile(MapColor.LAPIS)); + public static final Block LILY_OF_THE_VALLEY_PILE = register("lily_of_the_valley_pile", BlockFactory.pile(MapColor.SNOW)); + public static final Block WITHER_ROSE_PILE = register("wither_rose_pile", BlockFactory.pile(MapColor.COLOR_BLACK).factory(WitherRosePileBlock::new)); /* ======================== */ @@ -110,21 +113,21 @@ public class PromenadeBlocks { public static final Block SAKURA_PRESSURE_PLATE = register("sakura_pressure_plate", BlockFactory.pressurePlate(SAKURA_PLANKS, PromenadeBlockSetTypes.SAKURA)); public static final Block SAKURA_SIGN = register("sakura_sign", BlockFactory.sign(SAKURA_PLANKS, PromenadeWoodTypes.SAKURA)); public static final Block SAKURA_WALL_SIGN = register("sakura_wall_sign", BlockFactory.wallSign(SAKURA_PLANKS, PromenadeWoodTypes.SAKURA)); - public static final Block SAKURA_HANGING_SIGN = register("sakura_hanging_sign", BlockFactory.hangingSign(SAKURA_PLANKS, PromenadeWoodTypes.SAKURA, BlockSoundGroup.CHERRY_WOOD_HANGING_SIGN)); - public static final Block SAKURA_WALL_HANGING_SIGN = register("sakura_wall_hanging_sign", BlockFactory.wallHangingSign(SAKURA_PLANKS, PromenadeWoodTypes.SAKURA, BlockSoundGroup.CHERRY_WOOD_HANGING_SIGN)); + public static final Block SAKURA_HANGING_SIGN = register("sakura_hanging_sign", BlockFactory.hangingSign(SAKURA_PLANKS, PromenadeWoodTypes.SAKURA, SoundType.CHERRY_WOOD_HANGING_SIGN)); + public static final Block SAKURA_WALL_HANGING_SIGN = register("sakura_wall_hanging_sign", BlockFactory.wallHangingSign(SAKURA_PLANKS, PromenadeWoodTypes.SAKURA, SoundType.CHERRY_WOOD_HANGING_SIGN)); public static final Block SAKURA_SHELF = register("sakura_shelf", BlockFactory.shelf(SAKURA_PLANKS)); public static final Block BLUSH_SAKURA_SAPLING = register("blush_sakura_sapling", BlockFactory.sapling(PromenadeMapColors.BLUSH_BLOSSOMS, PromenadeSaplingGenerators.BLUSH_SAKURA)); public static final Block POTTED_BLUSH_SAKURA_SAPLING = register("potted_blush_sakura_sapling", BlockFactory.pot(BLUSH_SAKURA_SAPLING)); - public static final Block BLUSH_SAKURA_BLOSSOMS = register("blush_sakura_blossoms", BlockFactory.leaves(PromenadeMapColors.BLUSH_BLOSSOMS, BlockSoundGroup.CHERRY_LEAVES, 0.1f, PromenadeParticleTypes.BLUSH_SAKURA_BLOSSOM)); + public static final Block BLUSH_SAKURA_BLOSSOMS = register("blush_sakura_blossoms", BlockFactory.leaves(PromenadeMapColors.BLUSH_BLOSSOMS, SoundType.CHERRY_LEAVES, 0.1f, PromenadeParticleTypes.BLUSH_SAKURA_BLOSSOM)); public static final Block SNOWY_BLUSH_SAKURA_BLOSSOMS = register("snowy_blush_sakura_blossoms", BlockFactory.snowyLeaves(0.1f, PromenadeParticleTypes.BLUSH_SAKURA_BLOSSOM, PromenadeBlockSounds.SNOWY_CHERRY_LEAVES)); - public static final Block BLUSH_SAKURA_BLOSSOM_PILE = register("blush_sakura_blossom_pile", BlockFactory.pile(PromenadeMapColors.BLUSH_BLOSSOMS, BlockSoundGroup.CHERRY_LEAVES)); + public static final Block BLUSH_SAKURA_BLOSSOM_PILE = register("blush_sakura_blossom_pile", BlockFactory.pile(PromenadeMapColors.BLUSH_BLOSSOMS, SoundType.CHERRY_LEAVES)); public static final Block COTTON_SAKURA_SAPLING = register("cotton_sakura_sapling", BlockFactory.sapling(PromenadeMapColors.COTTON_BLOSSOMS, PromenadeSaplingGenerators.COTTON_SAKURA)); public static final Block POTTED_COTTON_SAKURA_SAPLING = register("potted_cotton_sakura_sapling", BlockFactory.pot(COTTON_SAKURA_SAPLING)); - public static final Block COTTON_SAKURA_BLOSSOMS = register("cotton_sakura_blossoms", BlockFactory.leaves(PromenadeMapColors.COTTON_BLOSSOMS, BlockSoundGroup.CHERRY_LEAVES, 0.1f, PromenadeParticleTypes.COTTON_SAKURA_BLOSSOM)); + public static final Block COTTON_SAKURA_BLOSSOMS = register("cotton_sakura_blossoms", BlockFactory.leaves(PromenadeMapColors.COTTON_BLOSSOMS, SoundType.CHERRY_LEAVES, 0.1f, PromenadeParticleTypes.COTTON_SAKURA_BLOSSOM)); public static final Block SNOWY_COTTON_SAKURA_BLOSSOMS = register("snowy_cotton_sakura_blossoms", BlockFactory.snowyLeaves(0.1f, PromenadeParticleTypes.COTTON_SAKURA_BLOSSOM, PromenadeBlockSounds.SNOWY_CHERRY_LEAVES)); - public static final Block COTTON_SAKURA_BLOSSOM_PILE = register("cotton_sakura_blossom_pile", BlockFactory.pile(PromenadeMapColors.COTTON_BLOSSOMS, BlockSoundGroup.CHERRY_LEAVES)); + public static final Block COTTON_SAKURA_BLOSSOM_PILE = register("cotton_sakura_blossom_pile", BlockFactory.pile(PromenadeMapColors.COTTON_BLOSSOMS, SoundType.CHERRY_LEAVES)); /* ========= */ @@ -146,8 +149,8 @@ public class PromenadeBlocks { public static final Block MAPLE_PRESSURE_PLATE = register("maple_pressure_plate", BlockFactory.pressurePlate(MAPLE_PLANKS, PromenadeBlockSetTypes.MAPLE)); public static final Block MAPLE_SIGN = register("maple_sign", BlockFactory.sign(MAPLE_PLANKS, PromenadeWoodTypes.MAPLE)); public static final Block MAPLE_WALL_SIGN = register("maple_wall_sign", BlockFactory.wallSign(MAPLE_PLANKS, PromenadeWoodTypes.MAPLE)); - public static final Block MAPLE_HANGING_SIGN = register("maple_hanging_sign", BlockFactory.hangingSign(MAPLE_PLANKS, PromenadeWoodTypes.MAPLE, BlockSoundGroup.CHERRY_WOOD_HANGING_SIGN)); - public static final Block MAPLE_WALL_HANGING_SIGN = register("maple_wall_hanging_sign", BlockFactory.wallHangingSign(MAPLE_PLANKS, PromenadeWoodTypes.MAPLE, BlockSoundGroup.CHERRY_WOOD_HANGING_SIGN)); + public static final Block MAPLE_HANGING_SIGN = register("maple_hanging_sign", BlockFactory.hangingSign(MAPLE_PLANKS, PromenadeWoodTypes.MAPLE, SoundType.CHERRY_WOOD_HANGING_SIGN)); + public static final Block MAPLE_WALL_HANGING_SIGN = register("maple_wall_hanging_sign", BlockFactory.wallHangingSign(MAPLE_PLANKS, PromenadeWoodTypes.MAPLE, SoundType.CHERRY_WOOD_HANGING_SIGN)); public static final Block MAPLE_SHELF = register("maple_shelf", BlockFactory.shelf(MAPLE_PLANKS)); public static final Block SAP_MAPLE_SAPLING = register("sap_maple_sapling", BlockFactory.sapling(PromenadeMapColors.SAP_MAPLE_LEAVES, PromenadeSaplingGenerators.SAP_MAPLE)); @@ -155,28 +158,28 @@ public class PromenadeBlocks { public static final Block SAP_MAPLE_LEAVES = register("sap_maple_leaves", BlockFactory.leaves(PromenadeMapColors.SAP_MAPLE_LEAVES)); public static final Block SNOWY_SAP_MAPLE_LEAVES = register("snowy_sap_maple_leaves", BlockFactory.snowyLeaves()); public static final Block FALLEN_SAP_MAPLE_LEAVES = register("fallen_sap_maple_leaves", BlockFactory.fallenLeaves(PromenadeMapColors.SAP_MAPLE_LEAVES)); - public static final Block SAP_MAPLE_LEAF_PILE = register("sap_maple_leaf_pile", BlockFactory.pile(PromenadeMapColors.SAP_MAPLE_LEAVES, BlockSoundGroup.GRASS)); + public static final Block SAP_MAPLE_LEAF_PILE = register("sap_maple_leaf_pile", BlockFactory.pile(PromenadeMapColors.SAP_MAPLE_LEAVES, SoundType.GRASS)); public static final Block VERMILION_MAPLE_SAPLING = register("vermilion_maple_sapling", BlockFactory.sapling(PromenadeMapColors.VERMILION_MAPLE_LEAVES, PromenadeSaplingGenerators.VERMILION_MAPLE)); public static final Block POTTED_VERMILION_MAPLE_SAPLING = register("potted_vermilion_maple_sapling", BlockFactory.pot(VERMILION_MAPLE_SAPLING)); - public static final Block VERMILION_MAPLE_LEAVES = register("vermilion_maple_leaves", BlockFactory.leaves(PromenadeMapColors.VERMILION_MAPLE_LEAVES, BlockSoundGroup.GRASS, 0.01F, PromenadeParticleTypes.VERMILION_MAPLE_LEAF)); + public static final Block VERMILION_MAPLE_LEAVES = register("vermilion_maple_leaves", BlockFactory.leaves(PromenadeMapColors.VERMILION_MAPLE_LEAVES, SoundType.GRASS, 0.01F, PromenadeParticleTypes.VERMILION_MAPLE_LEAF)); public static final Block SNOWY_VERMILION_MAPLE_LEAVES = register("snowy_vermilion_maple_leaves", BlockFactory.snowyLeaves(0.01F, PromenadeParticleTypes.VERMILION_MAPLE_LEAF)); public static final Block FALLEN_VERMILION_MAPLE_LEAVES = register("fallen_vermilion_maple_leaves", BlockFactory.fallenLeaves(PromenadeMapColors.VERMILION_MAPLE_LEAVES)); - public static final Block VERMILION_MAPLE_LEAF_PILE = register("vermilion_maple_leaf_pile", BlockFactory.pile(PromenadeMapColors.VERMILION_MAPLE_LEAVES, BlockSoundGroup.GRASS)); + public static final Block VERMILION_MAPLE_LEAF_PILE = register("vermilion_maple_leaf_pile", BlockFactory.pile(PromenadeMapColors.VERMILION_MAPLE_LEAVES, SoundType.GRASS)); public static final Block FULVOUS_MAPLE_SAPLING = register("fulvous_maple_sapling", BlockFactory.sapling(PromenadeMapColors.FULVOUS_MAPLE_LEAVES, PromenadeSaplingGenerators.FULVOUS_MAPLE)); public static final Block POTTED_FULVOUS_MAPLE_SAPLING = register("potted_fulvous_maple_sapling", BlockFactory.pot(FULVOUS_MAPLE_SAPLING)); - public static final Block FULVOUS_MAPLE_LEAVES = register("fulvous_maple_leaves", BlockFactory.leaves(PromenadeMapColors.FULVOUS_MAPLE_LEAVES, BlockSoundGroup.GRASS, 0.01F, PromenadeParticleTypes.FULVOUS_MAPLE_LEAF)); + public static final Block FULVOUS_MAPLE_LEAVES = register("fulvous_maple_leaves", BlockFactory.leaves(PromenadeMapColors.FULVOUS_MAPLE_LEAVES, SoundType.GRASS, 0.01F, PromenadeParticleTypes.FULVOUS_MAPLE_LEAF)); public static final Block SNOWY_FULVOUS_MAPLE_LEAVES = register("snowy_fulvous_maple_leaves", BlockFactory.snowyLeaves(0.01F, PromenadeParticleTypes.FULVOUS_MAPLE_LEAF)); public static final Block FALLEN_FULVOUS_MAPLE_LEAVES = register("fallen_fulvous_maple_leaves", BlockFactory.fallenLeaves(PromenadeMapColors.FULVOUS_MAPLE_LEAVES)); - public static final Block FULVOUS_MAPLE_LEAF_PILE = register("fulvous_maple_leaf_pile", BlockFactory.pile(PromenadeMapColors.FULVOUS_MAPLE_LEAVES, BlockSoundGroup.GRASS)); + public static final Block FULVOUS_MAPLE_LEAF_PILE = register("fulvous_maple_leaf_pile", BlockFactory.pile(PromenadeMapColors.FULVOUS_MAPLE_LEAVES, SoundType.GRASS)); public static final Block MIKADO_MAPLE_SAPLING = register("mikado_maple_sapling", BlockFactory.sapling(PromenadeMapColors.MIKADO_MAPLE_LEAVES, PromenadeSaplingGenerators.MIKADO_MAPLE)); public static final Block POTTED_MIKADO_MAPLE_SAPLING = register("potted_mikado_maple_sapling", BlockFactory.pot(MIKADO_MAPLE_SAPLING)); - public static final Block MIKADO_MAPLE_LEAVES = register("mikado_maple_leaves", BlockFactory.leaves(PromenadeMapColors.MIKADO_MAPLE_LEAVES, BlockSoundGroup.GRASS, 0.01F, PromenadeParticleTypes.MIKADO_MAPLE_LEAF)); + public static final Block MIKADO_MAPLE_LEAVES = register("mikado_maple_leaves", BlockFactory.leaves(PromenadeMapColors.MIKADO_MAPLE_LEAVES, SoundType.GRASS, 0.01F, PromenadeParticleTypes.MIKADO_MAPLE_LEAF)); public static final Block SNOWY_MIKADO_MAPLE_LEAVES = register("snowy_mikado_maple_leaves", BlockFactory.snowyLeaves(0.01F, PromenadeParticleTypes.MIKADO_MAPLE_LEAF)); public static final Block FALLEN_MIKADO_MAPLE_LEAVES = register("fallen_mikado_maple_leaves", BlockFactory.fallenLeaves(PromenadeMapColors.MIKADO_MAPLE_LEAVES)); - public static final Block MIKADO_MAPLE_LEAF_PILE = register("mikado_maple_leaf_pile", BlockFactory.pile(PromenadeMapColors.MIKADO_MAPLE_LEAVES, BlockSoundGroup.GRASS)); + public static final Block MIKADO_MAPLE_LEAF_PILE = register("mikado_maple_leaf_pile", BlockFactory.pile(PromenadeMapColors.MIKADO_MAPLE_LEAVES, SoundType.GRASS)); /* ======== */ @@ -198,41 +201,41 @@ public class PromenadeBlocks { public static final Block PALM_PRESSURE_PLATE = register("palm_pressure_plate", BlockFactory.pressurePlate(PALM_PLANKS, PromenadeBlockSetTypes.PALM)); public static final Block PALM_SIGN = register("palm_sign", BlockFactory.sign(PALM_PLANKS, PromenadeWoodTypes.PALM)); public static final Block PALM_WALL_SIGN = register("palm_wall_sign", BlockFactory.wallSign(PALM_PLANKS, PromenadeWoodTypes.PALM)); - public static final Block PALM_HANGING_SIGN = register("palm_hanging_sign", BlockFactory.hangingSign(PALM_PLANKS, PromenadeWoodTypes.PALM, BlockSoundGroup.HANGING_SIGN)); - public static final Block PALM_WALL_HANGING_SIGN = register("palm_wall_hanging_sign", BlockFactory.wallHangingSign(PALM_PLANKS, PromenadeWoodTypes.PALM, BlockSoundGroup.HANGING_SIGN)); + public static final Block PALM_HANGING_SIGN = register("palm_hanging_sign", BlockFactory.hangingSign(PALM_PLANKS, PromenadeWoodTypes.PALM, SoundType.HANGING_SIGN)); + public static final Block PALM_WALL_HANGING_SIGN = register("palm_wall_hanging_sign", BlockFactory.wallHangingSign(PALM_PLANKS, PromenadeWoodTypes.PALM, SoundType.HANGING_SIGN)); public static final Block PALM_SHELF = register("palm_shelf", BlockFactory.shelf(PALM_PLANKS)); - public static final Block PALM_SAPLING = register("palm_sapling", BlockFactory.sapling(PromenadeMapColors.PALM_LEAVES, PromenadeSaplingGenerators.PALM, state -> state.isIn(BlockTags.SAND))); + public static final Block PALM_SAPLING = register("palm_sapling", BlockFactory.sapling(PromenadeMapColors.PALM_LEAVES, PromenadeSaplingGenerators.PALM, state -> state.is(BlockTags.SAND))); public static final Block POTTED_PALM_SAPLING = register("potted_palm_sapling", BlockFactory.pot(PALM_SAPLING)); public static final Block PALM_LEAVES = register("palm_leaves", BlockFactory.leaves(PromenadeMapColors.PALM_LEAVES).factory(s -> new TintedParticleExtendedLeavesBlock(0.01F, s))); public static final Block SNOWY_PALM_LEAVES = register("snowy_palm_leaves", BlockFactory.snowyLeaves().factory(s -> new TintedParticleSnowyExtendedLeavesBlock(0.01F, s))); public static final Block PALM_HANGING_LEAVES = register("palm_hanging_leaves", BlockFactory.hangingLeaves(PromenadeMapColors.PALM_LEAVES)); - public static final Block PALM_LEAF_PILE = register("palm_leaf_pile", BlockFactory.pile(PromenadeMapColors.PALM_LEAVES, BlockSoundGroup.GRASS)); + public static final Block PALM_LEAF_PILE = register("palm_leaf_pile", BlockFactory.pile(PromenadeMapColors.PALM_LEAVES, SoundType.GRASS)); /* ============ */ /* AMARANTH */ /* ============ */ public static final Block DARK_AMARANTH_NYLIUM = register("dark_amaranth_nylium", BlockFactory.of(NyliumBlock::new, - AbstractBlock.Settings.create() - .mapColor(MapColor.BLACK) + BlockBehaviour.Properties.of() + .mapColor(MapColor.COLOR_BLACK) .instrument(NoteBlockInstrument.BASEDRUM) - .requiresTool() + .requiresCorrectToolForDrops() .strength(0.4F) - .sounds(BlockSoundGroup.NYLIUM) - .ticksRandomly())); + .sound(SoundType.NYLIUM) + .randomTicks())); public static final Block DARK_AMARANTH_WART_BLOCK = register("dark_amaranth_wart_block", - BlockFactory.of(AbstractBlock.Settings.create() - .mapColor(MapColor.PURPLE) + BlockFactory.of(BlockBehaviour.Properties.of() + .mapColor(MapColor.COLOR_PURPLE) .strength(1.0F) - .sounds(BlockSoundGroup.WART_BLOCK))); - public static final Block DARK_AMARANTH_ROOTS = register("dark_amaranth_roots", BlockFactory.of(s -> new RootsBlock(state -> state.isIn(PromenadeBlockTags.DARK_AMARANTH_ROOTS_PLACEABLE_ON), s), - AbstractBlock.Settings.create() - .mapColor(MapColor.PURPLE) + .sound(SoundType.WART_BLOCK))); + public static final Block DARK_AMARANTH_ROOTS = register("dark_amaranth_roots", BlockFactory.of(s -> new RootsBlock(state -> state.is(PromenadeBlockTags.DARK_AMARANTH_ROOTS_PLACEABLE_ON), s), + BlockBehaviour.Properties.of() + .mapColor(MapColor.COLOR_PURPLE) .replaceable() - .breakInstantly() + .instabreak() .noCollision() - .sounds(BlockSoundGroup.ROOTS))); + .sound(SoundType.ROOTS))); public static final Block POTTED_DARK_AMARANTH_ROOTS = register("potted_dark_amaranth_roots", BlockFactory.pot(DARK_AMARANTH_ROOTS)); public static final Block DARK_AMARANTH_STEM = register("dark_amaranth_stem", BlockFactory.log(PromenadeMapColors.AMARANTH_BARK, PromenadeBlockSounds.AMARANTH_WOOD, false)); @@ -251,49 +254,49 @@ public class PromenadeBlocks { public static final Block DARK_AMARANTH_PRESSURE_PLATE = register("dark_amaranth_pressure_plate", BlockFactory.pressurePlate(DARK_AMARANTH_PLANKS, PromenadeBlockSetTypes.DARK_AMARANTH)); public static final Block DARK_AMARANTH_SIGN = register("dark_amaranth_sign", BlockFactory.sign(DARK_AMARANTH_PLANKS, PromenadeWoodTypes.DARK_AMARANTH)); public static final Block DARK_AMARANTH_WALL_SIGN = register("dark_amaranth_wall_sign", BlockFactory.wallSign(DARK_AMARANTH_PLANKS, PromenadeWoodTypes.DARK_AMARANTH)); - public static final Block DARK_AMARANTH_HANGING_SIGN = register("dark_amaranth_hanging_sign", BlockFactory.hangingSign(DARK_AMARANTH_PLANKS, PromenadeWoodTypes.DARK_AMARANTH, BlockSoundGroup.NETHER_WOOD_HANGING_SIGN)); - public static final Block DARK_AMARANTH_WALL_HANGING_SIGN = register("dark_amaranth_wall_hanging_sign", BlockFactory.wallHangingSign(DARK_AMARANTH_PLANKS, PromenadeWoodTypes.DARK_AMARANTH, BlockSoundGroup.NETHER_WOOD_HANGING_SIGN)); + public static final Block DARK_AMARANTH_HANGING_SIGN = register("dark_amaranth_hanging_sign", BlockFactory.hangingSign(DARK_AMARANTH_PLANKS, PromenadeWoodTypes.DARK_AMARANTH, SoundType.NETHER_WOOD_HANGING_SIGN)); + public static final Block DARK_AMARANTH_WALL_HANGING_SIGN = register("dark_amaranth_wall_hanging_sign", BlockFactory.wallHangingSign(DARK_AMARANTH_PLANKS, PromenadeWoodTypes.DARK_AMARANTH, SoundType.NETHER_WOOD_HANGING_SIGN)); public static final Block DARK_AMARANTH_SHELF = register("dark_amaranth_shelf", BlockFactory.shelf(DARK_AMARANTH_PLANKS)); - public static final Block DARK_AMARANTH_FUNGUS = register("dark_amaranth_fungus", BlockFactory.fungus(MapColor.PURPLE, PromenadeConfiguredFeatures.PLANTED_DARK_AMARANTH_FUNGUS, PromenadeBlockTags.DARK_AMARANTH_FUNGUS_PLACEABLE_ON, PromenadeBlockTags.DARK_AMARANTH_FUNGUS_GROWABLE_ON)); + public static final Block DARK_AMARANTH_FUNGUS = register("dark_amaranth_fungus", BlockFactory.fungus(MapColor.COLOR_PURPLE, PromenadeConfiguredFeatures.PLANTED_DARK_AMARANTH_FUNGUS, PromenadeBlockTags.DARK_AMARANTH_FUNGUS_PLACEABLE_ON, PromenadeBlockTags.DARK_AMARANTH_FUNGUS_GROWABLE_ON)); public static final Block POTTED_DARK_AMARANTH_FUNGUS = register("potted_dark_amaranth_fungus", BlockFactory.pot(DARK_AMARANTH_FUNGUS)); - public static final Block SOUL_SHROOMLIGHT = register("soul_shroomlight", BlockFactory.of(AbstractBlock.Settings.create().mapColor(MapColor.LIGHT_BLUE).strength(1.0F).sounds(BlockSoundGroup.SHROOMLIGHT).luminance(state -> 10))); + public static final Block SOUL_SHROOMLIGHT = register("soul_shroomlight", BlockFactory.of(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_LIGHT_BLUE).strength(1.0F).sound(SoundType.SHROOMLIGHT).lightLevel(state -> 10))); public static final Block COILED_VINES = register("coiled_vines", BlockFactory.of( CoiledVinesBlock::new, - AbstractBlock.Settings.create() - .mapColor(MapColor.PURPLE) - .ticksRandomly() + BlockBehaviour.Properties.of() + .mapColor(MapColor.COLOR_PURPLE) + .randomTicks() .noCollision() - .breakInstantly() - .sounds(BlockSoundGroup.WEEPING_VINES) - .pistonBehavior(PistonBehavior.DESTROY) + .instabreak() + .sound(SoundType.WEEPING_VINES) + .pushReaction(PushReaction.DESTROY) )); public static final Block COILED_VINES_PLANT = register("coiled_vines_plant", BlockFactory.of( CoiledVinesPlantBlock::new, - AbstractBlock.Settings.create() - .mapColor(MapColor.PURPLE) + BlockBehaviour.Properties.of() + .mapColor(MapColor.COLOR_PURPLE) .noCollision() - .breakInstantly() - .sounds(BlockSoundGroup.WEEPING_VINES) - .pistonBehavior(PistonBehavior.DESTROY) + .instabreak() + .sound(SoundType.WEEPING_VINES) + .pushReaction(PushReaction.DESTROY) ).noItem()); - public static final Block MOAI = register("moai", BlockFactory.of(MoaiBlock::new, AbstractBlock.Settings.copy(Blocks.TUFF).mapColor(MapColor.TERRACOTTA_LIGHT_GRAY)).itemSettings(s -> s.equipmentSlot((entity, stack) -> EquipmentSlot.HEAD))); + public static final Block MOAI = register("moai", BlockFactory.of(MoaiBlock::new, BlockBehaviour.Properties.ofFullCopy(Blocks.TUFF).mapColor(MapColor.TERRACOTTA_LIGHT_GRAY)).itemSettings(s -> s.equipmentSlot((entity, stack) -> EquipmentSlot.HEAD))); - public static final Block BLUEBERRY_BUSH = register("blueberry_bush", BlockFactory.of(s -> new BerryBushBlock(PromenadeItemKeys.BLUEBERRIES, false, s), AbstractBlock.Settings.create() - .mapColor(MapColor.DARK_GREEN) - .ticksRandomly() + public static final Block BLUEBERRY_BUSH = register("blueberry_bush", BlockFactory.of(s -> new BerryBushBlock(PromenadeItemKeys.BLUEBERRIES, false, s), BlockBehaviour.Properties.of() + .mapColor(MapColor.PLANT) + .randomTicks() .noCollision() - .sounds(BlockSoundGroup.SWEET_BERRY_BUSH) - .pistonBehavior(PistonBehavior.DESTROY)).noItem()); + .sound(SoundType.SWEET_BERRY_BUSH) + .pushReaction(PushReaction.DESTROY)).noItem()); - private static RegistryKey keyOf(String id) { - return RegistryKey.of(RegistryKeys.BLOCK, Promenade.id(id)); + private static ResourceKey keyOf(String id) { + return ResourceKey.create(Registries.BLOCK, Promenade.id(id)); } - private static Block register(RegistryKey key, BlockBuilder builder) { + private static Block register(ResourceKey key, BlockBuilder builder) { return builder.register(key); } diff --git a/src/main/java/fr/hugman/promenade/block/RootsBlock.java b/src/main/java/fr/hugman/promenade/block/RootsBlock.java index dcf06334..a9093824 100644 --- a/src/main/java/fr/hugman/promenade/block/RootsBlock.java +++ b/src/main/java/fr/hugman/promenade/block/RootsBlock.java @@ -1,21 +1,21 @@ package fr.hugman.promenade.block; -import net.minecraft.block.BlockState; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.BlockView; - import java.util.function.Predicate; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.block.NetherRootsBlock; +import net.minecraft.world.level.block.state.BlockState; //TODO: codec -public class RootsBlock extends net.minecraft.block.RootsBlock { +public class RootsBlock extends NetherRootsBlock { private final Predicate canPlantOn; - public RootsBlock(Predicate canPlantOn, Settings settings) { - super(settings); + public RootsBlock(Predicate canPlantOn, Properties settings) { + super(null, settings); this.canPlantOn = canPlantOn; } - protected boolean canPlantOnTop(BlockState floor, BlockView world, BlockPos pos) { + protected boolean mayPlaceOn(BlockState floor, BlockGetter world, BlockPos pos) { return this.canPlantOn.test(floor); } } \ No newline at end of file diff --git a/src/main/java/fr/hugman/promenade/block/SaplingBlock.java b/src/main/java/fr/hugman/promenade/block/SaplingBlock.java index dec55b23..c5fa81ca 100644 --- a/src/main/java/fr/hugman/promenade/block/SaplingBlock.java +++ b/src/main/java/fr/hugman/promenade/block/SaplingBlock.java @@ -1,24 +1,23 @@ package fr.hugman.promenade.block; -import net.minecraft.block.BlockState; -import net.minecraft.block.SaplingGenerator; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.BlockView; - import java.util.function.Predicate; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.block.grower.TreeGrower; +import net.minecraft.world.level.block.state.BlockState; //TODO: codec -public class SaplingBlock extends net.minecraft.block.SaplingBlock { +public class SaplingBlock extends net.minecraft.world.level.block.SaplingBlock { private final Predicate predicate; - public SaplingBlock(SaplingGenerator saplingGenerator, Predicate predicate, Settings settings) { + public SaplingBlock(TreeGrower saplingGenerator, Predicate predicate, Properties settings) { super(saplingGenerator, settings); this.predicate = predicate; } @Override - protected boolean canPlantOnTop(BlockState floor, BlockView world, BlockPos pos) { + protected boolean mayPlaceOn(BlockState floor, BlockGetter world, BlockPos pos) { if (predicate != null) return predicate.test(floor); - return super.canPlantOnTop(floor, world, pos); + return super.mayPlaceOn(floor, world, pos); } } \ No newline at end of file diff --git a/src/main/java/fr/hugman/promenade/block/SnowyLeavesBlock.java b/src/main/java/fr/hugman/promenade/block/SnowyLeavesBlock.java index dbf3498a..3c167f0f 100644 --- a/src/main/java/fr/hugman/promenade/block/SnowyLeavesBlock.java +++ b/src/main/java/fr/hugman/promenade/block/SnowyLeavesBlock.java @@ -2,71 +2,71 @@ import fr.hugman.promenade.registry.PromenadeRegistryKeys; import fr.hugman.promenade.tag.PromenadeBiomeTags; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.LeavesBlock; -import net.minecraft.item.ItemPlacementContext; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.state.StateManager; -import net.minecraft.state.property.BooleanProperty; -import net.minecraft.state.property.Properties; -import net.minecraft.state.property.Property; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.random.Random; -import net.minecraft.world.LightType; -import net.minecraft.world.WorldView; -import net.minecraft.world.tick.ScheduledTickView; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.util.RandomSource; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.LightLayer; +import net.minecraft.world.level.ScheduledTickAccess; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.LeavesBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.StateDefinition; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.Property; public abstract class SnowyLeavesBlock extends LeavesBlock { - public static final BooleanProperty BOTTOM = Properties.BOTTOM; + public static final BooleanProperty BOTTOM = BlockStateProperties.BOTTOM; - public SnowyLeavesBlock(float leafParticleChance, Settings settings) { + public SnowyLeavesBlock(float leafParticleChance, Properties settings) { super(leafParticleChance, settings); - this.setDefaultState(this.getDefaultState().with(BOTTOM, false)); + this.registerDefaultState(this.defaultBlockState().setValue(BOTTOM, false)); } @Override - protected void appendProperties(StateManager.Builder builder) { - super.appendProperties(builder); + protected void createBlockStateDefinition(StateDefinition.Builder builder) { + super.createBlockStateDefinition(builder); builder.add(BOTTOM); } @Override - public BlockState getPlacementState(ItemPlacementContext context) { - BlockState state = super.getPlacementState(context); + public BlockState getStateForPlacement(BlockPlaceContext context) { + BlockState state = super.getStateForPlacement(context); if (state == null) return null; - BlockState stateBelow = context.getWorld().getBlockState(context.getBlockPos().down()); - return state.with(BOTTOM, !isSnow(stateBelow)); + BlockState stateBelow = context.getLevel().getBlockState(context.getClickedPos().below()); + return state.setValue(BOTTOM, !isSnow(stateBelow)); } @Override - protected boolean hasRandomTicks(BlockState state) { + protected boolean isRandomlyTicking(BlockState state) { return true; } @Override - protected void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { + protected void randomTick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) { super.randomTick(state, world, pos, random); - if (world.getLightLevel(LightType.BLOCK, pos) > 11 && !world.getBiome(pos).isIn(PromenadeBiomeTags.CAN_FREEZE_DURING_SNOWFALL)) { - var normalLeaves = world.getRegistryManager().getOrThrow(PromenadeRegistryKeys.SNOWY_BLOCK_TRANSFORMATION).stream().filter( + if (world.getBrightness(LightLayer.BLOCK, pos) > 11 && !world.getBiome(pos).is(PromenadeBiomeTags.CAN_FREEZE_DURING_SNOWFALL)) { + var normalLeaves = world.registryAccess().lookupOrThrow(PromenadeRegistryKeys.SNOWY_BLOCK_TRANSFORMATION).stream().filter( entry -> entry.snowyBlock().value() == state.getBlock() ).findFirst().map(sbt -> sbt.baseBlock().value()).orElse(null); - var newLeavesState = normalLeaves.getDefaultState(); + var newLeavesState = normalLeaves.defaultBlockState(); // copy properties of snowy block for (Property property : state.getProperties()) { - newLeavesState = newLeavesState.contains(property) ? newLeavesState.with(property, state.get(property)) : newLeavesState; + newLeavesState = newLeavesState.hasProperty(property) ? newLeavesState.setValue(property, state.getValue(property)) : newLeavesState; } - world.setBlockState(pos, newLeavesState); + world.setBlockAndUpdate(pos, newLeavesState); } } @Override - protected BlockState getStateForNeighborUpdate(BlockState state, WorldView world, ScheduledTickView tickView, BlockPos pos, Direction direction, BlockPos neighborPos, BlockState neighborState, Random random) { - BlockState stateBelow = world.getBlockState(pos.down()); - return super.getStateForNeighborUpdate(state, world, tickView, pos, direction, neighborPos, neighborState, random).with(BOTTOM, !isSnow(stateBelow)); + protected BlockState updateShape(BlockState state, LevelReader world, ScheduledTickAccess tickView, BlockPos pos, Direction direction, BlockPos neighborPos, BlockState neighborState, RandomSource random) { + BlockState stateBelow = world.getBlockState(pos.below()); + return super.updateShape(state, world, tickView, pos, direction, neighborPos, neighborState, random).setValue(BOTTOM, !isSnow(stateBelow)); } public static boolean isSnow(BlockState state) { diff --git a/src/main/java/fr/hugman/promenade/block/StrippedMapleLogBlock.java b/src/main/java/fr/hugman/promenade/block/StrippedMapleLogBlock.java index 3aef8336..de567a52 100644 --- a/src/main/java/fr/hugman/promenade/block/StrippedMapleLogBlock.java +++ b/src/main/java/fr/hugman/promenade/block/StrippedMapleLogBlock.java @@ -3,65 +3,65 @@ import com.mojang.serialization.MapCodec; import fr.hugman.promenade.block.property.PromenadeBlockProperties; import fr.hugman.promenade.item.PromenadeItems; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.PillarBlock; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.sound.SoundCategory; -import net.minecraft.sound.SoundEvents; -import net.minecraft.stat.Stats; -import net.minecraft.state.StateManager; -import net.minecraft.state.property.BooleanProperty; -import net.minecraft.util.ActionResult; -import net.minecraft.util.Hand; -import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraft.world.event.GameEvent; +import net.minecraft.core.BlockPos; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.sounds.SoundSource; +import net.minecraft.stats.Stats; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.RotatedPillarBlock; +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.level.gameevent.GameEvent; +import net.minecraft.world.phys.BlockHitResult; //TODO make generic -public class StrippedMapleLogBlock extends PillarBlock { - public static final MapCodec CODEC = createCodec(StrippedMapleLogBlock::new); +public class StrippedMapleLogBlock extends RotatedPillarBlock { + public static final MapCodec CODEC = simpleCodec(StrippedMapleLogBlock::new); public static final BooleanProperty DRIP = PromenadeBlockProperties.DRIP; //TODO : add dispenser behavior - public StrippedMapleLogBlock(Settings settings) { + public StrippedMapleLogBlock(Properties settings) { super(settings); - this.setDefaultState(this.getDefaultState().with(DRIP, false)); + this.registerDefaultState(this.defaultBlockState().setValue(DRIP, false)); } @Override - public MapCodec getCodec() { + public MapCodec codec() { return CODEC; } @Override - protected void appendProperties(StateManager.Builder builder) { - super.appendProperties(builder); + protected void createBlockStateDefinition(StateDefinition.Builder builder) { + super.createBlockStateDefinition(builder); builder.add(DRIP); } @Override - protected ActionResult onUseWithItem(ItemStack stack, BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { + protected InteractionResult useItemOn(ItemStack stack, BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) { // if the player is holding a bottle, they can collect the syrup - if (state.get(DRIP)) { + if (state.getValue(DRIP)) { if (stack.getItem() == Items.GLASS_BOTTLE) { - stack.decrement(1); - world.playSound(player, player.getX(), player.getY(), player.getZ(), SoundEvents.ITEM_BOTTLE_FILL, SoundCategory.NEUTRAL, 1.0F, 1.0F); + stack.shrink(1); + world.playSound(player, player.getX(), player.getY(), player.getZ(), SoundEvents.BOTTLE_FILL, SoundSource.NEUTRAL, 1.0F, 1.0F); if (stack.isEmpty()) { - player.setStackInHand(hand, new ItemStack(PromenadeItems.MAPLE_SYRUP_BOTTLE)); - } else if (!player.getInventory().insertStack(new ItemStack(PromenadeItems.MAPLE_SYRUP_BOTTLE))) { - player.dropItem(new ItemStack(PromenadeItems.MAPLE_SYRUP_BOTTLE), false); + player.setItemInHand(hand, new ItemStack(PromenadeItems.MAPLE_SYRUP_BOTTLE)); + } else if (!player.getInventory().add(new ItemStack(PromenadeItems.MAPLE_SYRUP_BOTTLE))) { + player.drop(new ItemStack(PromenadeItems.MAPLE_SYRUP_BOTTLE), false); } - world.emitGameEvent(player, GameEvent.FLUID_PICKUP, pos); - player.incrementStat(Stats.USED.getOrCreateStat(stack.getItem())); - world.setBlockState(pos, state.with(DRIP, false)); - return ActionResult.SUCCESS; + world.gameEvent(player, GameEvent.FLUID_PICKUP, pos); + player.awardStat(Stats.ITEM_USED.get(stack.getItem())); + world.setBlockAndUpdate(pos, state.setValue(DRIP, false)); + return InteractionResult.SUCCESS; } } - return super.onUseWithItem(stack, state, world, pos, player, hand, hit); + return super.useItemOn(stack, state, world, pos, player, hand, hit); } } diff --git a/src/main/java/fr/hugman/promenade/block/TintedParticleExtendedLeavesBlock.java b/src/main/java/fr/hugman/promenade/block/TintedParticleExtendedLeavesBlock.java index 594b4f22..bd768687 100644 --- a/src/main/java/fr/hugman/promenade/block/TintedParticleExtendedLeavesBlock.java +++ b/src/main/java/fr/hugman/promenade/block/TintedParticleExtendedLeavesBlock.java @@ -2,31 +2,31 @@ import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; -import net.minecraft.particle.ParticleTypes; -import net.minecraft.particle.ParticleUtil; -import net.minecraft.particle.TintedParticleEffect; -import net.minecraft.util.dynamic.Codecs; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.random.Random; -import net.minecraft.world.World; +import net.minecraft.core.BlockPos; +import net.minecraft.core.particles.ColorParticleOption; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.util.ExtraCodecs; +import net.minecraft.util.ParticleUtils; +import net.minecraft.util.RandomSource; +import net.minecraft.world.level.Level; public class TintedParticleExtendedLeavesBlock extends ExtendedLeavesBlock { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> instance.group( - Codecs.rangedInclusiveFloat(0.0F, 1.0F).fieldOf("leaf_particle_chance").forGetter(tintedParticleLeavesBlock -> tintedParticleLeavesBlock.leafParticleChance), - createSettingsCodec() + ExtraCodecs.floatRange(0.0F, 1.0F).fieldOf("leaf_particle_chance").forGetter(tintedParticleLeavesBlock -> tintedParticleLeavesBlock.leafParticleChance), + propertiesCodec() ).apply(instance, TintedParticleExtendedLeavesBlock::new)); - public TintedParticleExtendedLeavesBlock(float f, Settings settings) { + public TintedParticleExtendedLeavesBlock(float f, Properties settings) { super(f, settings); } @Override - protected void spawnLeafParticle(World world, BlockPos pos, Random random) { - ParticleUtil.spawnParticle(world, pos, random, TintedParticleEffect.create(ParticleTypes.TINTED_LEAVES, world.getBlockColor(pos))); + protected void spawnLeafParticle(Level world, BlockPos pos, RandomSource random) { + ParticleUtils.spawnParticleBelow(world, pos, random, ColorParticleOption.create(ParticleTypes.TINTED_LEAVES, world.getClientLeafTintColor(pos))); } @Override - public MapCodec getCodec() { + public MapCodec codec() { return CODEC; } } diff --git a/src/main/java/fr/hugman/promenade/block/TintedParticleSnowyExtendedLeavesBlock.java b/src/main/java/fr/hugman/promenade/block/TintedParticleSnowyExtendedLeavesBlock.java index 91fd6bbd..aa43753e 100644 --- a/src/main/java/fr/hugman/promenade/block/TintedParticleSnowyExtendedLeavesBlock.java +++ b/src/main/java/fr/hugman/promenade/block/TintedParticleSnowyExtendedLeavesBlock.java @@ -2,58 +2,58 @@ import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.item.ItemPlacementContext; -import net.minecraft.particle.ParticleTypes; -import net.minecraft.particle.ParticleUtil; -import net.minecraft.particle.TintedParticleEffect; -import net.minecraft.state.StateManager; -import net.minecraft.state.property.BooleanProperty; -import net.minecraft.state.property.Properties; -import net.minecraft.util.dynamic.Codecs; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.random.Random; -import net.minecraft.world.World; -import net.minecraft.world.WorldView; -import net.minecraft.world.tick.ScheduledTickView; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.core.particles.ColorParticleOption; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.util.ExtraCodecs; +import net.minecraft.util.ParticleUtils; +import net.minecraft.util.RandomSource; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.ScheduledTickAccess; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.StateDefinition; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.state.properties.BooleanProperty; public class TintedParticleSnowyExtendedLeavesBlock extends ExtendedLeavesBlock { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> instance.group( - Codecs.rangedInclusiveFloat(0.0F, 1.0F).fieldOf("leaf_particle_chance").forGetter(untintedParticleLeavesBlock -> untintedParticleLeavesBlock.leafParticleChance), - createSettingsCodec() + ExtraCodecs.floatRange(0.0F, 1.0F).fieldOf("leaf_particle_chance").forGetter(untintedParticleLeavesBlock -> untintedParticleLeavesBlock.leafParticleChance), + propertiesCodec() ).apply(instance, TintedParticleSnowyExtendedLeavesBlock::new)); - public static final BooleanProperty BOTTOM = Properties.BOTTOM; + public static final BooleanProperty BOTTOM = BlockStateProperties.BOTTOM; - public TintedParticleSnowyExtendedLeavesBlock(float leafParticleChance, Settings settings) { + public TintedParticleSnowyExtendedLeavesBlock(float leafParticleChance, Properties settings) { super(leafParticleChance, settings); - this.setDefaultState(this.getDefaultState().with(BOTTOM, false)); + this.registerDefaultState(this.defaultBlockState().setValue(BOTTOM, false)); } @Override - public MapCodec getCodec() { + public MapCodec codec() { return CODEC; } @Override - protected void appendProperties(StateManager.Builder builder) { - super.appendProperties(builder); + protected void createBlockStateDefinition(StateDefinition.Builder builder) { + super.createBlockStateDefinition(builder); builder.add(BOTTOM); } @Override - public BlockState getPlacementState(ItemPlacementContext context) { - BlockState state = super.getPlacementState(context); + public BlockState getStateForPlacement(BlockPlaceContext context) { + BlockState state = super.getStateForPlacement(context); if (state == null) return null; - BlockState stateBelow = context.getWorld().getBlockState(context.getBlockPos().down()); - return state.with(BOTTOM, !isSnow(stateBelow)); + BlockState stateBelow = context.getLevel().getBlockState(context.getClickedPos().below()); + return state.setValue(BOTTOM, !isSnow(stateBelow)); } @Override - protected BlockState getStateForNeighborUpdate(BlockState state, WorldView world, ScheduledTickView tickView, BlockPos pos, Direction direction, BlockPos neighborPos, BlockState neighborState, Random random) { - BlockState stateBelow = world.getBlockState(pos.down()); - return super.getStateForNeighborUpdate(state, world, tickView, pos, direction, neighborPos, neighborState, random).with(BOTTOM, !isSnow(stateBelow)); + protected BlockState updateShape(BlockState state, LevelReader world, ScheduledTickAccess tickView, BlockPos pos, Direction direction, BlockPos neighborPos, BlockState neighborState, RandomSource random) { + BlockState stateBelow = world.getBlockState(pos.below()); + return super.updateShape(state, world, tickView, pos, direction, neighborPos, neighborState, random).setValue(BOTTOM, !isSnow(stateBelow)); } public static boolean isSnow(BlockState state) { @@ -61,7 +61,7 @@ public static boolean isSnow(BlockState state) { } @Override - protected void spawnLeafParticle(World world, BlockPos pos, Random random) { - ParticleUtil.spawnParticle(world, pos, random, TintedParticleEffect.create(ParticleTypes.TINTED_LEAVES, world.getBlockColor(pos))); + protected void spawnLeafParticle(Level world, BlockPos pos, RandomSource random) { + ParticleUtils.spawnParticleBelow(world, pos, random, ColorParticleOption.create(ParticleTypes.TINTED_LEAVES, world.getClientLeafTintColor(pos))); } } diff --git a/src/main/java/fr/hugman/promenade/block/TintedParticleSnowyLeavesBlock.java b/src/main/java/fr/hugman/promenade/block/TintedParticleSnowyLeavesBlock.java index cdd8114e..8951da1c 100644 --- a/src/main/java/fr/hugman/promenade/block/TintedParticleSnowyLeavesBlock.java +++ b/src/main/java/fr/hugman/promenade/block/TintedParticleSnowyLeavesBlock.java @@ -2,31 +2,31 @@ import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; -import net.minecraft.particle.ParticleTypes; -import net.minecraft.particle.ParticleUtil; -import net.minecraft.particle.TintedParticleEffect; -import net.minecraft.util.dynamic.Codecs; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.random.Random; -import net.minecraft.world.World; +import net.minecraft.core.BlockPos; +import net.minecraft.core.particles.ColorParticleOption; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.util.ExtraCodecs; +import net.minecraft.util.ParticleUtils; +import net.minecraft.util.RandomSource; +import net.minecraft.world.level.Level; public class TintedParticleSnowyLeavesBlock extends SnowyLeavesBlock { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> instance.group( - Codecs.rangedInclusiveFloat(0.0F, 1.0F).fieldOf("leaf_particle_chance").forGetter(tintedParticleLeavesBlock -> tintedParticleLeavesBlock.leafParticleChance), - createSettingsCodec() + ExtraCodecs.floatRange(0.0F, 1.0F).fieldOf("leaf_particle_chance").forGetter(tintedParticleLeavesBlock -> tintedParticleLeavesBlock.leafParticleChance), + propertiesCodec() ).apply(instance, TintedParticleSnowyLeavesBlock::new)); - public TintedParticleSnowyLeavesBlock(float f, Settings settings) { + public TintedParticleSnowyLeavesBlock(float f, Properties settings) { super(f, settings); } @Override - protected void spawnLeafParticle(World world, BlockPos pos, Random random) { - ParticleUtil.spawnParticle(world, pos, random, TintedParticleEffect.create(ParticleTypes.TINTED_LEAVES, world.getBlockColor(pos))); + protected void spawnFallingLeavesParticle(Level world, BlockPos pos, RandomSource random) { + ParticleUtils.spawnParticleBelow(world, pos, random, ColorParticleOption.create(ParticleTypes.TINTED_LEAVES, world.getClientLeafTintColor(pos))); } @Override - public MapCodec getCodec() { + public MapCodec codec() { return CODEC; } } diff --git a/src/main/java/fr/hugman/promenade/block/UntintedParticleExtendedLeavesBlock.java b/src/main/java/fr/hugman/promenade/block/UntintedParticleExtendedLeavesBlock.java index 85da809e..52c01900 100644 --- a/src/main/java/fr/hugman/promenade/block/UntintedParticleExtendedLeavesBlock.java +++ b/src/main/java/fr/hugman/promenade/block/UntintedParticleExtendedLeavesBlock.java @@ -2,39 +2,39 @@ import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; -import net.minecraft.particle.ParticleEffect; -import net.minecraft.particle.ParticleTypes; -import net.minecraft.particle.ParticleUtil; -import net.minecraft.util.dynamic.Codecs; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.random.Random; -import net.minecraft.world.World; +import net.minecraft.core.BlockPos; +import net.minecraft.core.particles.ParticleOptions; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.util.ExtraCodecs; +import net.minecraft.util.ParticleUtils; +import net.minecraft.util.RandomSource; +import net.minecraft.world.level.Level; public class UntintedParticleExtendedLeavesBlock extends ExtendedLeavesBlock { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec( instance -> instance.group( - Codecs.rangedInclusiveFloat(0.0F, 1.0F) + ExtraCodecs.floatRange(0.0F, 1.0F) .fieldOf("leaf_particle_chance") .forGetter(untintedParticleLeavesBlock -> untintedParticleLeavesBlock.leafParticleChance), - ParticleTypes.TYPE_CODEC.fieldOf("leaf_particle").forGetter(untintedParticleLeavesBlock -> untintedParticleLeavesBlock.leafParticleEffect), - createSettingsCodec() + ParticleTypes.CODEC.fieldOf("leaf_particle").forGetter(untintedParticleLeavesBlock -> untintedParticleLeavesBlock.leafParticleEffect), + propertiesCodec() ) .apply(instance, UntintedParticleExtendedLeavesBlock::new) ); - protected final ParticleEffect leafParticleEffect; + protected final ParticleOptions leafParticleEffect; - public UntintedParticleExtendedLeavesBlock(float leafParticleChance, ParticleEffect leafParticleEffect, Settings settings) { + public UntintedParticleExtendedLeavesBlock(float leafParticleChance, ParticleOptions leafParticleEffect, Properties settings) { super(leafParticleChance, settings); this.leafParticleEffect = leafParticleEffect; } @Override - protected void spawnLeafParticle(World world, BlockPos pos, Random random) { - ParticleUtil.spawnParticle(world, pos, random, this.leafParticleEffect); + protected void spawnLeafParticle(Level world, BlockPos pos, RandomSource random) { + ParticleUtils.spawnParticleBelow(world, pos, random, this.leafParticleEffect); } @Override - public MapCodec getCodec() { + public MapCodec codec() { return CODEC; } } diff --git a/src/main/java/fr/hugman/promenade/block/UntintedParticleSnowyExtendedLeavesBlock.java b/src/main/java/fr/hugman/promenade/block/UntintedParticleSnowyExtendedLeavesBlock.java index 975ee686..f39408ea 100644 --- a/src/main/java/fr/hugman/promenade/block/UntintedParticleSnowyExtendedLeavesBlock.java +++ b/src/main/java/fr/hugman/promenade/block/UntintedParticleSnowyExtendedLeavesBlock.java @@ -2,62 +2,62 @@ import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.item.ItemPlacementContext; -import net.minecraft.particle.ParticleEffect; -import net.minecraft.particle.ParticleTypes; -import net.minecraft.particle.ParticleUtil; -import net.minecraft.state.StateManager; -import net.minecraft.state.property.BooleanProperty; -import net.minecraft.state.property.Properties; -import net.minecraft.util.dynamic.Codecs; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.random.Random; -import net.minecraft.world.World; -import net.minecraft.world.WorldView; -import net.minecraft.world.tick.ScheduledTickView; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.core.particles.ParticleOptions; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.util.ExtraCodecs; +import net.minecraft.util.ParticleUtils; +import net.minecraft.util.RandomSource; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.ScheduledTickAccess; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.StateDefinition; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.state.properties.BooleanProperty; public class UntintedParticleSnowyExtendedLeavesBlock extends ExtendedLeavesBlock { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> instance.group( - Codecs.rangedInclusiveFloat(0.0F, 1.0F).fieldOf("leaf_particle_chance").forGetter(untintedParticleLeavesBlock -> untintedParticleLeavesBlock.leafParticleChance), - ParticleTypes.TYPE_CODEC.fieldOf("leaf_particle").forGetter(untintedParticleLeavesBlock -> untintedParticleLeavesBlock.leafParticleEffect), - createSettingsCodec() + ExtraCodecs.floatRange(0.0F, 1.0F).fieldOf("leaf_particle_chance").forGetter(untintedParticleLeavesBlock -> untintedParticleLeavesBlock.leafParticleChance), + ParticleTypes.CODEC.fieldOf("leaf_particle").forGetter(untintedParticleLeavesBlock -> untintedParticleLeavesBlock.leafParticleEffect), + propertiesCodec() ).apply(instance, UntintedParticleSnowyExtendedLeavesBlock::new)); - public static final BooleanProperty BOTTOM = Properties.BOTTOM; + public static final BooleanProperty BOTTOM = BlockStateProperties.BOTTOM; - protected final ParticleEffect leafParticleEffect; + protected final ParticleOptions leafParticleEffect; - public UntintedParticleSnowyExtendedLeavesBlock(float leafParticleChance, ParticleEffect leafParticleEffect, Settings settings) { + public UntintedParticleSnowyExtendedLeavesBlock(float leafParticleChance, ParticleOptions leafParticleEffect, Properties settings) { super(leafParticleChance, settings); - this.setDefaultState(this.getDefaultState().with(BOTTOM, false)); + this.registerDefaultState(this.defaultBlockState().setValue(BOTTOM, false)); this.leafParticleEffect = leafParticleEffect; } @Override - public MapCodec getCodec() { + public MapCodec codec() { return CODEC; } @Override - protected void appendProperties(StateManager.Builder builder) { - super.appendProperties(builder); + protected void createBlockStateDefinition(StateDefinition.Builder builder) { + super.createBlockStateDefinition(builder); builder.add(BOTTOM); } @Override - public BlockState getPlacementState(ItemPlacementContext context) { - BlockState state = super.getPlacementState(context); + public BlockState getStateForPlacement(BlockPlaceContext context) { + BlockState state = super.getStateForPlacement(context); if (state == null) return null; - BlockState stateBelow = context.getWorld().getBlockState(context.getBlockPos().down()); - return state.with(BOTTOM, !isSnow(stateBelow)); + BlockState stateBelow = context.getLevel().getBlockState(context.getClickedPos().below()); + return state.setValue(BOTTOM, !isSnow(stateBelow)); } @Override - protected BlockState getStateForNeighborUpdate(BlockState state, WorldView world, ScheduledTickView tickView, BlockPos pos, Direction direction, BlockPos neighborPos, BlockState neighborState, Random random) { - BlockState stateBelow = world.getBlockState(pos.down()); - return super.getStateForNeighborUpdate(state, world, tickView, pos, direction, neighborPos, neighborState, random).with(BOTTOM, !isSnow(stateBelow)); + protected BlockState updateShape(BlockState state, LevelReader world, ScheduledTickAccess tickView, BlockPos pos, Direction direction, BlockPos neighborPos, BlockState neighborState, RandomSource random) { + BlockState stateBelow = world.getBlockState(pos.below()); + return super.updateShape(state, world, tickView, pos, direction, neighborPos, neighborState, random).setValue(BOTTOM, !isSnow(stateBelow)); } public static boolean isSnow(BlockState state) { @@ -65,7 +65,7 @@ public static boolean isSnow(BlockState state) { } @Override - protected void spawnLeafParticle(World world, BlockPos pos, Random random) { - ParticleUtil.spawnParticle(world, pos, random, this.leafParticleEffect); + protected void spawnLeafParticle(Level world, BlockPos pos, RandomSource random) { + ParticleUtils.spawnParticleBelow(world, pos, random, this.leafParticleEffect); } } diff --git a/src/main/java/fr/hugman/promenade/block/UntintedParticleSnowyLeavesBlock.java b/src/main/java/fr/hugman/promenade/block/UntintedParticleSnowyLeavesBlock.java index b8ddabc2..71c67088 100644 --- a/src/main/java/fr/hugman/promenade/block/UntintedParticleSnowyLeavesBlock.java +++ b/src/main/java/fr/hugman/promenade/block/UntintedParticleSnowyLeavesBlock.java @@ -2,34 +2,34 @@ import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; -import net.minecraft.particle.ParticleEffect; -import net.minecraft.particle.ParticleTypes; -import net.minecraft.particle.ParticleUtil; -import net.minecraft.util.dynamic.Codecs; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.random.Random; -import net.minecraft.world.World; +import net.minecraft.core.BlockPos; +import net.minecraft.core.particles.ParticleOptions; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.util.ExtraCodecs; +import net.minecraft.util.ParticleUtils; +import net.minecraft.util.RandomSource; +import net.minecraft.world.level.Level; public class UntintedParticleSnowyLeavesBlock extends SnowyLeavesBlock { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> instance.group( - Codecs.rangedInclusiveFloat(0.0F, 1.0F).fieldOf("leaf_particle_chance").forGetter(untintedParticleLeavesBlock -> untintedParticleLeavesBlock.leafParticleChance), - ParticleTypes.TYPE_CODEC.fieldOf("leaf_particle").forGetter(untintedParticleLeavesBlock -> untintedParticleLeavesBlock.leafParticleEffect), - createSettingsCodec() + ExtraCodecs.floatRange(0.0F, 1.0F).fieldOf("leaf_particle_chance").forGetter(untintedParticleLeavesBlock -> untintedParticleLeavesBlock.leafParticleChance), + ParticleTypes.CODEC.fieldOf("leaf_particle").forGetter(untintedParticleLeavesBlock -> untintedParticleLeavesBlock.leafParticleEffect), + propertiesCodec() ).apply(instance, UntintedParticleSnowyLeavesBlock::new)); - protected final ParticleEffect leafParticleEffect; + protected final ParticleOptions leafParticleEffect; - public UntintedParticleSnowyLeavesBlock(float leafParticleChance, ParticleEffect leafParticleEffect, Settings settings) { + public UntintedParticleSnowyLeavesBlock(float leafParticleChance, ParticleOptions leafParticleEffect, Properties settings) { super(leafParticleChance, settings); this.leafParticleEffect = leafParticleEffect; } @Override - protected void spawnLeafParticle(World world, BlockPos pos, Random random) { - ParticleUtil.spawnParticle(world, pos, random, this.leafParticleEffect); + protected void spawnFallingLeavesParticle(Level world, BlockPos pos, RandomSource random) { + ParticleUtils.spawnParticleBelow(world, pos, random, this.leafParticleEffect); } @Override - public MapCodec getCodec() { + public MapCodec codec() { return CODEC; } } diff --git a/src/main/java/fr/hugman/promenade/block/WitherRosePileBlock.java b/src/main/java/fr/hugman/promenade/block/WitherRosePileBlock.java index 873d9041..1041c159 100644 --- a/src/main/java/fr/hugman/promenade/block/WitherRosePileBlock.java +++ b/src/main/java/fr/hugman/promenade/block/WitherRosePileBlock.java @@ -3,60 +3,60 @@ import com.mojang.serialization.MapCodec; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityCollisionHandler; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.effect.StatusEffectInstance; -import net.minecraft.entity.effect.StatusEffects; -import net.minecraft.particle.ParticleTypes; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.random.Random; -import net.minecraft.world.BlockView; +import net.minecraft.core.BlockPos; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.util.RandomSource; import net.minecraft.world.Difficulty; -import net.minecraft.world.World; +import net.minecraft.world.effect.MobEffectInstance; +import net.minecraft.world.effect.MobEffects; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.InsideBlockEffectApplier; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.state.BlockState; public class WitherRosePileBlock extends PileBlock { - public static final MapCodec CODEC = createCodec(WitherRosePileBlock::new); + public static final MapCodec CODEC = simpleCodec(WitherRosePileBlock::new); - public WitherRosePileBlock(Settings builder) { + public WitherRosePileBlock(Properties builder) { super(builder); } @Override - protected MapCodec getCodec() { + protected MapCodec codec() { return CODEC; } @Override - public boolean canPlantOnTop(BlockState state, BlockView world, BlockPos pos) { - return super.canPlantOnTop(state, world, pos) || state.getBlock() == Blocks.SOUL_SAND; + public boolean mayPlaceOn(BlockState state, BlockGetter world, BlockPos pos) { + return super.mayPlaceOn(state, world, pos) || state.getBlock() == Blocks.SOUL_SAND; } @Override @Environment(EnvType.CLIENT) - public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random rand) { + public void animateTick(BlockState state, Level world, BlockPos pos, RandomSource rand) { for (int i = 0; i < 5; ++i) { if (rand.nextBoolean()) { - world.addParticleClient(ParticleTypes.SMOKE, (double) pos.getX() + (double) (rand.nextInt(17) / 16), (double) pos.getY() + (0.5D - (double) rand.nextFloat()), (double) pos.getZ() + (double) (rand.nextInt(17) / 16), 0.0D, 0.0D, 0.0D); + world.addParticle(ParticleTypes.SMOKE, (double) pos.getX() + (double) (rand.nextInt(17) / 16), (double) pos.getY() + (0.5D - (double) rand.nextFloat()), (double) pos.getZ() + (double) (rand.nextInt(17) / 16), 0.0D, 0.0D, 0.0D); } } } @Override - protected void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity, EntityCollisionHandler handler, boolean bl) { - if (world instanceof ServerWorld serverWorld + protected void entityInside(BlockState state, Level world, BlockPos pos, Entity entity, InsideBlockEffectApplier handler, boolean bl) { + if (world instanceof ServerLevel serverWorld && world.getDifficulty() != Difficulty.PEACEFUL && entity instanceof LivingEntity livingEntity - && !livingEntity.isInvulnerableTo(serverWorld, world.getDamageSources().wither())) { - livingEntity.addStatusEffect(this.getContactEffect()); + && !livingEntity.isInvulnerableTo(serverWorld, world.damageSources().wither())) { + livingEntity.addEffect(this.getContactEffect()); } - super.onEntityCollision(state, world, pos, entity, handler, bl); + super.entityInside(state, world, pos, entity, handler, bl); } - public StatusEffectInstance getContactEffect() { - return new StatusEffectInstance(StatusEffects.WITHER, 40); + public MobEffectInstance getContactEffect() { + return new MobEffectInstance(MobEffects.WITHER, 40); } } diff --git a/src/main/java/fr/hugman/promenade/block/dispenser/PromenadeDispenserBehaviors.java b/src/main/java/fr/hugman/promenade/block/dispenser/PromenadeDispenserBehaviors.java index 5dfb5d02..6684ff10 100644 --- a/src/main/java/fr/hugman/promenade/block/dispenser/PromenadeDispenserBehaviors.java +++ b/src/main/java/fr/hugman/promenade/block/dispenser/PromenadeDispenserBehaviors.java @@ -2,49 +2,24 @@ import fr.hugman.promenade.entity.PromenadeEntityTypes; import fr.hugman.promenade.item.PromenadeItems; -import net.minecraft.block.DispenserBlock; -import net.minecraft.block.dispenser.BoatDispenserBehavior; -import net.minecraft.block.dispenser.ItemDispenserBehavior; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.SpawnReason; -import net.minecraft.item.ItemStack; -import net.minecraft.item.SpawnEggItem; -import net.minecraft.util.math.BlockPointer; -import net.minecraft.util.math.Direction; -import net.minecraft.world.event.GameEvent; +import net.minecraft.core.Direction; +import net.minecraft.core.dispenser.BlockSource; +import net.minecraft.core.dispenser.BoatDispenseItemBehavior; +import net.minecraft.core.dispenser.DefaultDispenseItemBehavior; +import net.minecraft.world.entity.EntitySpawnReason; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.SpawnEggItem; +import net.minecraft.world.level.block.DispenserBlock; +import net.minecraft.world.level.gameevent.GameEvent; public class PromenadeDispenserBehaviors { public static void register() { - ItemDispenserBehavior spawnEggBehavior = new ItemDispenserBehavior() { - @Override - public ItemStack dispenseSilently(BlockPointer pointer, ItemStack stack) { - Direction direction = pointer.state().get(DispenserBlock.FACING); - EntityType entityType = ((SpawnEggItem) stack.getItem()).getEntityType(stack); - - try { - entityType.spawnFromItemStack(pointer.world(), stack, null, pointer.pos().offset(direction), SpawnReason.DISPENSER, direction != Direction.UP, false); - } catch (Exception var6) { - LOGGER.error("Error while dispensing spawn egg from dispenser at {}", pointer.pos(), var6); - return ItemStack.EMPTY; - } - - stack.decrement(1); - pointer.world().emitGameEvent(null, GameEvent.ENTITY_PLACE, pointer.pos()); - return stack; - } - }; - - DispenserBlock.registerBehavior(PromenadeItems.SAKURA_BOAT, new BoatDispenserBehavior(PromenadeEntityTypes.SAKURA_BOAT)); - DispenserBlock.registerBehavior(PromenadeItems.SAKURA_CHEST_BOAT, new BoatDispenserBehavior(PromenadeEntityTypes.SAKURA_CHEST_BOAT)); - DispenserBlock.registerBehavior(PromenadeItems.MAPLE_BOAT, new BoatDispenserBehavior(PromenadeEntityTypes.MAPLE_BOAT)); - DispenserBlock.registerBehavior(PromenadeItems.MAPLE_CHEST_BOAT, new BoatDispenserBehavior(PromenadeEntityTypes.MAPLE_CHEST_BOAT)); - DispenserBlock.registerBehavior(PromenadeItems.PALM_BOAT, new BoatDispenserBehavior(PromenadeEntityTypes.PALM_BOAT)); - DispenserBlock.registerBehavior(PromenadeItems.PALM_CHEST_BOAT, new BoatDispenserBehavior(PromenadeEntityTypes.PALM_CHEST_BOAT)); - - - DispenserBlock.registerBehavior(PromenadeItems.CAPYBARA_SPAWN_EGG, spawnEggBehavior); - DispenserBlock.registerBehavior(PromenadeItems.DUCK_SPAWN_EGG, spawnEggBehavior); - DispenserBlock.registerBehavior(PromenadeItems.LUSH_CREEPER_SPAWN_EGG, spawnEggBehavior); - DispenserBlock.registerBehavior(PromenadeItems.SUNKEN_SPAWN_EGG, spawnEggBehavior); + DispenserBlock.registerBehavior(PromenadeItems.SAKURA_BOAT, new BoatDispenseItemBehavior(PromenadeEntityTypes.SAKURA_BOAT)); + DispenserBlock.registerBehavior(PromenadeItems.SAKURA_CHEST_BOAT, new BoatDispenseItemBehavior(PromenadeEntityTypes.SAKURA_CHEST_BOAT)); + DispenserBlock.registerBehavior(PromenadeItems.MAPLE_BOAT, new BoatDispenseItemBehavior(PromenadeEntityTypes.MAPLE_BOAT)); + DispenserBlock.registerBehavior(PromenadeItems.MAPLE_CHEST_BOAT, new BoatDispenseItemBehavior(PromenadeEntityTypes.MAPLE_CHEST_BOAT)); + DispenserBlock.registerBehavior(PromenadeItems.PALM_BOAT, new BoatDispenseItemBehavior(PromenadeEntityTypes.PALM_BOAT)); + DispenserBlock.registerBehavior(PromenadeItems.PALM_CHEST_BOAT, new BoatDispenseItemBehavior(PromenadeEntityTypes.PALM_CHEST_BOAT)); } } diff --git a/src/main/java/fr/hugman/promenade/block/entity/PromenadeBlockEntities.java b/src/main/java/fr/hugman/promenade/block/entity/PromenadeBlockEntities.java index 085579b6..4d005f69 100644 --- a/src/main/java/fr/hugman/promenade/block/entity/PromenadeBlockEntities.java +++ b/src/main/java/fr/hugman/promenade/block/entity/PromenadeBlockEntities.java @@ -1,30 +1,30 @@ package fr.hugman.promenade.block.entity; import fr.hugman.promenade.block.PromenadeBlocks; -import net.minecraft.block.entity.BlockEntityType; +import net.minecraft.world.level.block.entity.BlockEntityType; public class PromenadeBlockEntities { public static void addBlocksToVanillaBlockEntityTypes() { - BlockEntityType.SIGN.addSupportedBlock(PromenadeBlocks.SAKURA_SIGN); - BlockEntityType.SIGN.addSupportedBlock(PromenadeBlocks.SAKURA_WALL_SIGN); - BlockEntityType.HANGING_SIGN.addSupportedBlock(PromenadeBlocks.SAKURA_HANGING_SIGN); - BlockEntityType.HANGING_SIGN.addSupportedBlock(PromenadeBlocks.SAKURA_WALL_HANGING_SIGN); - BlockEntityType.SIGN.addSupportedBlock(PromenadeBlocks.MAPLE_SIGN); - BlockEntityType.SIGN.addSupportedBlock(PromenadeBlocks.MAPLE_WALL_SIGN); - BlockEntityType.HANGING_SIGN.addSupportedBlock(PromenadeBlocks.MAPLE_HANGING_SIGN); - BlockEntityType.HANGING_SIGN.addSupportedBlock(PromenadeBlocks.MAPLE_WALL_HANGING_SIGN); - BlockEntityType.SIGN.addSupportedBlock(PromenadeBlocks.PALM_SIGN); - BlockEntityType.SIGN.addSupportedBlock(PromenadeBlocks.PALM_WALL_SIGN); - BlockEntityType.HANGING_SIGN.addSupportedBlock(PromenadeBlocks.PALM_HANGING_SIGN); - BlockEntityType.HANGING_SIGN.addSupportedBlock(PromenadeBlocks.PALM_WALL_HANGING_SIGN); - BlockEntityType.SIGN.addSupportedBlock(PromenadeBlocks.DARK_AMARANTH_SIGN); - BlockEntityType.SIGN.addSupportedBlock(PromenadeBlocks.DARK_AMARANTH_WALL_SIGN); - BlockEntityType.HANGING_SIGN.addSupportedBlock(PromenadeBlocks.DARK_AMARANTH_HANGING_SIGN); - BlockEntityType.HANGING_SIGN.addSupportedBlock(PromenadeBlocks.DARK_AMARANTH_WALL_HANGING_SIGN); + BlockEntityType.SIGN.addValidBlock(PromenadeBlocks.SAKURA_SIGN); + BlockEntityType.SIGN.addValidBlock(PromenadeBlocks.SAKURA_WALL_SIGN); + BlockEntityType.HANGING_SIGN.addValidBlock(PromenadeBlocks.SAKURA_HANGING_SIGN); + BlockEntityType.HANGING_SIGN.addValidBlock(PromenadeBlocks.SAKURA_WALL_HANGING_SIGN); + BlockEntityType.SIGN.addValidBlock(PromenadeBlocks.MAPLE_SIGN); + BlockEntityType.SIGN.addValidBlock(PromenadeBlocks.MAPLE_WALL_SIGN); + BlockEntityType.HANGING_SIGN.addValidBlock(PromenadeBlocks.MAPLE_HANGING_SIGN); + BlockEntityType.HANGING_SIGN.addValidBlock(PromenadeBlocks.MAPLE_WALL_HANGING_SIGN); + BlockEntityType.SIGN.addValidBlock(PromenadeBlocks.PALM_SIGN); + BlockEntityType.SIGN.addValidBlock(PromenadeBlocks.PALM_WALL_SIGN); + BlockEntityType.HANGING_SIGN.addValidBlock(PromenadeBlocks.PALM_HANGING_SIGN); + BlockEntityType.HANGING_SIGN.addValidBlock(PromenadeBlocks.PALM_WALL_HANGING_SIGN); + BlockEntityType.SIGN.addValidBlock(PromenadeBlocks.DARK_AMARANTH_SIGN); + BlockEntityType.SIGN.addValidBlock(PromenadeBlocks.DARK_AMARANTH_WALL_SIGN); + BlockEntityType.HANGING_SIGN.addValidBlock(PromenadeBlocks.DARK_AMARANTH_HANGING_SIGN); + BlockEntityType.HANGING_SIGN.addValidBlock(PromenadeBlocks.DARK_AMARANTH_WALL_HANGING_SIGN); - BlockEntityType.SHELF.addSupportedBlock(PromenadeBlocks.SAKURA_SHELF); - BlockEntityType.SHELF.addSupportedBlock(PromenadeBlocks.MAPLE_SHELF); - BlockEntityType.SHELF.addSupportedBlock(PromenadeBlocks.PALM_SHELF); - BlockEntityType.SHELF.addSupportedBlock(PromenadeBlocks.DARK_AMARANTH_SHELF); + BlockEntityType.SHELF.addValidBlock(PromenadeBlocks.SAKURA_SHELF); + BlockEntityType.SHELF.addValidBlock(PromenadeBlocks.MAPLE_SHELF); + BlockEntityType.SHELF.addValidBlock(PromenadeBlocks.PALM_SHELF); + BlockEntityType.SHELF.addValidBlock(PromenadeBlocks.DARK_AMARANTH_SHELF); } } diff --git a/src/main/java/fr/hugman/promenade/block/helper/BlockBuilder.java b/src/main/java/fr/hugman/promenade/block/helper/BlockBuilder.java index 48f17e3c..db05689e 100644 --- a/src/main/java/fr/hugman/promenade/block/helper/BlockBuilder.java +++ b/src/main/java/fr/hugman/promenade/block/helper/BlockBuilder.java @@ -1,61 +1,60 @@ package fr.hugman.promenade.block.helper; -import net.minecraft.block.AbstractBlock; -import net.minecraft.block.Block; -import net.minecraft.item.BlockItem; -import net.minecraft.item.Item; -import net.minecraft.registry.Registries; -import net.minecraft.registry.Registry; -import net.minecraft.registry.RegistryKey; -import net.minecraft.registry.RegistryKeys; - import java.util.function.Function; import java.util.function.Supplier; +import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.Item; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockBehaviour; public class BlockBuilder { - private static final Function DEFAULT_FACTORY = Block::new; - private static final Supplier DEFAULT_ITEM_SETTINGS = () -> new Item.Settings().useBlockPrefixedTranslationKey(); + private static final Function DEFAULT_FACTORY = Block::new; + private static final Supplier DEFAULT_ITEM_SETTINGS = () -> new Item.Properties().useBlockDescriptionPrefix(); - private Function factory = DEFAULT_FACTORY; - private AbstractBlock.Settings settings; + private Function factory = DEFAULT_FACTORY; + private BlockBehaviour.Properties settings; - private Item.Settings itemSettings = DEFAULT_ITEM_SETTINGS.get(); + private Item.Properties itemSettings = DEFAULT_ITEM_SETTINGS.get(); - public BlockBuilder(Function factory, AbstractBlock.Settings settings) { + public BlockBuilder(Function factory, BlockBehaviour.Properties settings) { this.factory = factory; this.settings = settings; } - public BlockBuilder(AbstractBlock.Settings settings) { + public BlockBuilder(BlockBehaviour.Properties settings) { this.settings = settings; } public BlockBuilder(Block block) { // retrieves the block's values - this.settings = AbstractBlock.Settings.copyShallow(block); + this.settings = BlockBehaviour.Properties.ofLegacyCopy(block); } - public BlockBuilder factory(Function factory) { + public BlockBuilder factory(Function factory) { this.factory = factory; return this; } - public BlockBuilder settings(AbstractBlock.Settings settings) { + public BlockBuilder settings(BlockBehaviour.Properties settings) { this.settings = settings; return this; } - public BlockBuilder settings(Function settingsConsumer) { + public BlockBuilder settings(Function settingsConsumer) { this.settings = settingsConsumer.apply(this.settings); return this; } - public BlockBuilder itemSettings(Item.Settings settings) { + public BlockBuilder itemSettings(Item.Properties settings) { this.itemSettings = settings; return this; } - public BlockBuilder itemSettings(Function settings) { + public BlockBuilder itemSettings(Function settings) { this.itemSettings = settings.apply(this.itemSettings); return this; } @@ -65,15 +64,15 @@ public BlockBuilder noItem() { return this; } - public Block register(RegistryKey key) { + public Block register(ResourceKey key) { if (this.factory == null) { throw new IllegalStateException("Cannot register block: factory is not set!"); } - var block = this.factory.apply(this.settings.registryKey(key)); - Registry.register(Registries.BLOCK, key, block); - if (this.itemSettings instanceof Item.Settings) { - var itemRegistryKey = RegistryKey.of(RegistryKeys.ITEM, key.getValue()); - Registry.register(Registries.ITEM, itemRegistryKey, new BlockItem(block, this.itemSettings.registryKey(itemRegistryKey))); + var block = this.factory.apply(this.settings.setId(key)); + Registry.register(BuiltInRegistries.BLOCK, key, block); + if (this.itemSettings instanceof Item.Properties) { + var itemRegistryKey = ResourceKey.create(Registries.ITEM, key.identifier()); + Registry.register(BuiltInRegistries.ITEM, itemRegistryKey, new BlockItem(block, this.itemSettings.setId(itemRegistryKey))); } return block; } diff --git a/src/main/java/fr/hugman/promenade/block/helper/BlockFactory.java b/src/main/java/fr/hugman/promenade/block/helper/BlockFactory.java index 80596e17..06d5d89b 100644 --- a/src/main/java/fr/hugman/promenade/block/helper/BlockFactory.java +++ b/src/main/java/fr/hugman/promenade/block/helper/BlockFactory.java @@ -5,27 +5,53 @@ import fr.hugman.promenade.block.TintedParticleSnowyLeavesBlock; import fr.hugman.promenade.block.UntintedParticleSnowyLeavesBlock; import fr.hugman.promenade.sound.PromenadeBlockSounds; -import net.minecraft.block.*; -import net.minecraft.block.enums.NoteBlockInstrument; -import net.minecraft.block.piston.PistonBehavior; -import net.minecraft.component.DataComponentTypes; -import net.minecraft.component.type.ContainerComponent; -import net.minecraft.particle.ParticleEffect; -import net.minecraft.registry.RegistryKey; -import net.minecraft.registry.tag.TagKey; -import net.minecraft.sound.BlockSoundGroup; -import net.minecraft.util.math.Direction; -import net.minecraft.world.gen.feature.ConfiguredFeature; - +import net.minecraft.core.Direction; +import net.minecraft.core.component.DataComponents; +import net.minecraft.core.particles.ParticleOptions; +import net.minecraft.resources.ResourceKey; +import net.minecraft.tags.TagKey; +import net.minecraft.world.item.component.ItemContainerContents; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.ButtonBlock; +import net.minecraft.world.level.block.CeilingHangingSignBlock; +import net.minecraft.world.level.block.DoorBlock; +import net.minecraft.world.level.block.FenceBlock; +import net.minecraft.world.level.block.FenceGateBlock; +import net.minecraft.world.level.block.FlowerPotBlock; +import net.minecraft.world.level.block.LeafLitterBlock; +import net.minecraft.world.level.block.PressurePlateBlock; +import net.minecraft.world.level.block.RotatedPillarBlock; +import net.minecraft.world.level.block.SaplingBlock; +import net.minecraft.world.level.block.ShelfBlock; +import net.minecraft.world.level.block.SlabBlock; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.world.level.block.StairBlock; +import net.minecraft.world.level.block.StandingSignBlock; +import net.minecraft.world.level.block.TintedParticleLeavesBlock; +import net.minecraft.world.level.block.TrapDoorBlock; +import net.minecraft.world.level.block.UntintedParticleLeavesBlock; +import net.minecraft.world.level.block.WallBlock; +import net.minecraft.world.level.block.WallHangingSignBlock; +import net.minecraft.world.level.block.WallSignBlock; +import net.minecraft.world.level.block.grower.TreeGrower; +import net.minecraft.world.level.block.state.BlockBehaviour; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BlockSetType; +import net.minecraft.world.level.block.state.properties.NoteBlockInstrument; +import net.minecraft.world.level.block.state.properties.WoodType; +import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; +import net.minecraft.world.level.material.MapColor; +import net.minecraft.world.level.material.PushReaction; import java.util.function.Function; import java.util.function.Predicate; public final class BlockFactory { - public static BlockBuilder of(Function factory, AbstractBlock.Settings settings) { + public static BlockBuilder of(Function factory, BlockBehaviour.Properties settings) { return new BlockBuilder(factory, settings); } - public static BlockBuilder of(AbstractBlock.Settings settings) { + public static BlockBuilder of(BlockBehaviour.Properties settings) { return new BlockBuilder(settings); } @@ -38,233 +64,233 @@ public static BlockBuilder slab(Block baseBlock) { } public static BlockBuilder stairs(Block baseBlock) { - return copy(baseBlock).factory(s -> new StairsBlock(baseBlock.getDefaultState(), s)); + return copy(baseBlock).factory(s -> new StairBlock(baseBlock.defaultBlockState(), s)); } public static BlockBuilder wall(Block baseBlock) { - return copy(baseBlock).factory(WallBlock::new).settings(AbstractBlock.Settings.copyShallow(baseBlock).solid()); + return copy(baseBlock).factory(WallBlock::new).settings(BlockBehaviour.Properties.ofLegacyCopy(baseBlock).forceSolidOn()); } public static BlockBuilder fence(Block baseBlock) { - return copy(baseBlock).factory(FenceBlock::new).settings(AbstractBlock.Settings.copyShallow(baseBlock)); + return copy(baseBlock).factory(FenceBlock::new).settings(BlockBehaviour.Properties.ofLegacyCopy(baseBlock)); } public static BlockBuilder fenceGate(Block baseBlock, WoodType woodType) { - return copy(baseBlock).factory(s -> new FenceGateBlock(woodType, s)).settings(AbstractBlock.Settings.copyShallow(baseBlock).solid()); + return copy(baseBlock).factory(s -> new FenceGateBlock(woodType, s)).settings(BlockBehaviour.Properties.ofLegacyCopy(baseBlock).forceSolidOn()); } public static BlockBuilder trapdoor(Block baseBlock, BlockSetType setType) { - return copy(baseBlock).factory(s -> new TrapdoorBlock(setType, s)).settings(AbstractBlock.Settings.copyShallow(baseBlock) + return copy(baseBlock).factory(s -> new TrapDoorBlock(setType, s)).settings(BlockBehaviour.Properties.ofLegacyCopy(baseBlock) .strength(3.0f) - .nonOpaque() - .allowsSpawning(Blocks::never)); + .noOcclusion() + .isValidSpawn(Blocks::never)); } public static BlockBuilder door(Block baseBlock, BlockSetType setType) { - return copy(baseBlock).factory(s -> new DoorBlock(setType, s)).settings(AbstractBlock.Settings.copyShallow(baseBlock) + return copy(baseBlock).factory(s -> new DoorBlock(setType, s)).settings(BlockBehaviour.Properties.ofLegacyCopy(baseBlock) .strength(3.0f) - .nonOpaque() - .pistonBehavior(PistonBehavior.DESTROY)); + .noOcclusion() + .pushReaction(PushReaction.DESTROY)); } public static BlockBuilder woodenButton(Block baseBlock, BlockSetType setType) { - return copy(baseBlock).factory(s -> new ButtonBlock(setType, 30, s)).settings(AbstractBlock.Settings.create() + return copy(baseBlock).factory(s -> new ButtonBlock(setType, 30, s)).settings(BlockBehaviour.Properties.of() .strength(0.5f) .noCollision() - .pistonBehavior(PistonBehavior.DESTROY) - .sounds(baseBlock.getDefaultState().getSoundGroup())); + .pushReaction(PushReaction.DESTROY) + .sound(baseBlock.defaultBlockState().getSoundType())); } public static BlockBuilder pressurePlate(Block baseBlock, BlockSetType setType) { - return copy(baseBlock).factory(s -> new PressurePlateBlock(setType, s)).settings(AbstractBlock.Settings.copyShallow(baseBlock) - .solid() + return copy(baseBlock).factory(s -> new PressurePlateBlock(setType, s)).settings(BlockBehaviour.Properties.ofLegacyCopy(baseBlock) + .forceSolidOn() .strength(0.5f) - .pistonBehavior(PistonBehavior.DESTROY) - .requiresTool() + .pushReaction(PushReaction.DESTROY) + .requiresCorrectToolForDrops() .noCollision()); } public static BlockBuilder sign(Block baseBlock, WoodType woodType) { - return copy(baseBlock).factory(s -> new SignBlock(woodType, s)).settings(AbstractBlock.Settings.copyShallow(baseBlock) - .mapColor(baseBlock.getDefaultMapColor()) - .solid() + return copy(baseBlock).factory(s -> new StandingSignBlock(woodType, s)).settings(BlockBehaviour.Properties.ofLegacyCopy(baseBlock) + .mapColor(baseBlock.defaultMapColor()) + .forceSolidOn() .noCollision() .strength(1.0F)).noItem(); } public static BlockBuilder wallSign(Block standingSign, WoodType woodType) { - return copy(standingSign).factory(s -> new WallSignBlock(woodType, s)).settings(AbstractBlock.Settings.copyShallow(standingSign) - .lootTable(standingSign.getLootTableKey()) - .mapColor(standingSign.getDefaultMapColor()) - .solid() + return copy(standingSign).factory(s -> new WallSignBlock(woodType, s)).settings(BlockBehaviour.Properties.ofLegacyCopy(standingSign) + .overrideLootTable(standingSign.getLootTable()) + .mapColor(standingSign.defaultMapColor()) + .forceSolidOn() .noCollision() .strength(1.0F)).noItem(); } - public static BlockBuilder hangingSign(Block baseBlock, WoodType woodType, BlockSoundGroup soundGroup) { - return copy(baseBlock).factory(s -> new HangingSignBlock(woodType, s)).settings(AbstractBlock.Settings.copyShallow(baseBlock) - .mapColor(baseBlock.getDefaultMapColor()) - .solid() + public static BlockBuilder hangingSign(Block baseBlock, WoodType woodType, SoundType soundGroup) { + return copy(baseBlock).factory(s -> new CeilingHangingSignBlock(woodType, s)).settings(BlockBehaviour.Properties.ofLegacyCopy(baseBlock) + .mapColor(baseBlock.defaultMapColor()) + .forceSolidOn() .noCollision() .strength(1.0F) - .sounds(soundGroup)).noItem(); + .sound(soundGroup)).noItem(); } - public static BlockBuilder wallHangingSign(Block standingSign, WoodType woodType, BlockSoundGroup soundGroup) { - return copy(standingSign).factory(s -> new WallHangingSignBlock(woodType, s)).settings(AbstractBlock.Settings.copyShallow(standingSign) - .lootTable(standingSign.getLootTableKey()) - .mapColor(standingSign.getDefaultMapColor()) - .solid() + public static BlockBuilder wallHangingSign(Block standingSign, WoodType woodType, SoundType soundGroup) { + return copy(standingSign).factory(s -> new WallHangingSignBlock(woodType, s)).settings(BlockBehaviour.Properties.ofLegacyCopy(standingSign) + .overrideLootTable(standingSign.getLootTable()) + .mapColor(standingSign.defaultMapColor()) + .forceSolidOn() .noCollision() .strength(1.0F) - .sounds(soundGroup)).noItem(); + .sound(soundGroup)).noItem(); } public static BlockBuilder shelf(Block planks) { - return copy(planks).factory(ShelfBlock::new).settings(AbstractBlock.Settings.copyShallow(planks).sounds(BlockSoundGroup.SHELF)).itemSettings((s -> s.component(DataComponentTypes.CONTAINER, ContainerComponent.DEFAULT))); + return copy(planks).factory(ShelfBlock::new).settings(BlockBehaviour.Properties.ofLegacyCopy(planks).sound(SoundType.SHELF)).itemSettings((s -> s.component(DataComponents.CONTAINER, ItemContainerContents.EMPTY))); } - public static BlockBuilder log(MapColor woodColor, MapColor barkColor, BlockSoundGroup sounds, boolean flammable) { + public static BlockBuilder log(MapColor woodColor, MapColor barkColor, SoundType sounds, boolean flammable) { return log(woodColor, sounds, flammable) - .settings(settings -> settings.mapColor((state) -> state.get(PillarBlock.AXIS) == Direction.Axis.Y ? woodColor : barkColor)); + .settings(settings -> settings.mapColor((state) -> state.getValue(RotatedPillarBlock.AXIS) == Direction.Axis.Y ? woodColor : barkColor)); } - public static BlockBuilder log(MapColor color, BlockSoundGroup sounds, boolean flammable) { - AbstractBlock.Settings settings = AbstractBlock.Settings.create() + public static BlockBuilder log(MapColor color, SoundType sounds, boolean flammable) { + BlockBehaviour.Properties settings = BlockBehaviour.Properties.of() .mapColor(color) .instrument(NoteBlockInstrument.BASS) .strength(2.0F) - .sounds(sounds); - if (flammable) settings.burnable(); - var builder = new BlockBuilder(PillarBlock::new, settings); + .sound(sounds); + if (flammable) settings.ignitedByLava(); + var builder = new BlockBuilder(RotatedPillarBlock::new, settings); return builder; } - public static BlockBuilder sapling(MapColor mapColor, SaplingGenerator generator) { - return new BlockBuilder(s -> new SaplingBlock(generator, s), AbstractBlock.Settings.create() + public static BlockBuilder sapling(MapColor mapColor, TreeGrower generator) { + return new BlockBuilder(s -> new SaplingBlock(generator, s), BlockBehaviour.Properties.of() .mapColor(mapColor) - .sounds(BlockSoundGroup.GRASS) - .breakInstantly() + .sound(SoundType.GRASS) + .instabreak() .noCollision() - .ticksRandomly() - .pistonBehavior(PistonBehavior.DESTROY)); + .randomTicks() + .pushReaction(PushReaction.DESTROY)); } - public static BlockBuilder sapling(MapColor mapColor, SaplingGenerator generator, Predicate saplingSoilPredicate) { + public static BlockBuilder sapling(MapColor mapColor, TreeGrower generator, Predicate saplingSoilPredicate) { return sapling(mapColor, generator).factory(settings -> new fr.hugman.promenade.block.SaplingBlock(generator, saplingSoilPredicate, settings)); } public static BlockBuilder leaves(MapColor mapColor) { - return new BlockBuilder(s -> new TintedParticleLeavesBlock(0.01f, s), AbstractBlock.Settings.create() + return new BlockBuilder(s -> new TintedParticleLeavesBlock(0.01f, s), BlockBehaviour.Properties.of() .mapColor(mapColor) .strength(0.2f) - .ticksRandomly() - .sounds(BlockSoundGroup.GRASS) - .nonOpaque() - .allowsSpawning(Blocks::never) - .suffocates(Blocks::never) - .blockVision(Blocks::never) - .pistonBehavior(PistonBehavior.DESTROY) - .solidBlock(Blocks::never)); - } - - public static BlockBuilder leaves(MapColor mapColor, BlockSoundGroup soundGroup, float particleChance, ParticleEffect fallingParticle) { - return new BlockBuilder(s -> new UntintedParticleLeavesBlock(particleChance, fallingParticle, s), AbstractBlock.Settings.create() + .randomTicks() + .sound(SoundType.GRASS) + .noOcclusion() + .isValidSpawn(Blocks::never) + .isSuffocating(Blocks::never) + .isViewBlocking(Blocks::never) + .pushReaction(PushReaction.DESTROY) + .isRedstoneConductor(Blocks::never)); + } + + public static BlockBuilder leaves(MapColor mapColor, SoundType soundGroup, float particleChance, ParticleOptions fallingParticle) { + return new BlockBuilder(s -> new UntintedParticleLeavesBlock(particleChance, fallingParticle, s), BlockBehaviour.Properties.of() .mapColor(mapColor) .strength(0.2f) - .ticksRandomly() - .sounds(soundGroup) - .nonOpaque() - .burnable() - .allowsSpawning(Blocks::never) - .suffocates(Blocks::never) - .blockVision(Blocks::never) - .pistonBehavior(PistonBehavior.DESTROY) - .solidBlock(Blocks::never)); + .randomTicks() + .sound(soundGroup) + .noOcclusion() + .ignitedByLava() + .isValidSpawn(Blocks::never) + .isSuffocating(Blocks::never) + .isViewBlocking(Blocks::never) + .pushReaction(PushReaction.DESTROY) + .isRedstoneConductor(Blocks::never)); } public static BlockBuilder hangingLeaves(MapColor mapColor) { - return new BlockBuilder(HangingLeavesBlock::new, AbstractBlock.Settings.create() + return new BlockBuilder(HangingLeavesBlock::new, BlockBehaviour.Properties.of() .mapColor(mapColor) - .sounds(BlockSoundGroup.GRASS) - .replaceable().noCollision().breakInstantly() - .burnable() - .pistonBehavior(PistonBehavior.DESTROY)); + .sound(SoundType.GRASS) + .replaceable().noCollision().instabreak() + .ignitedByLava() + .pushReaction(PushReaction.DESTROY)); } public static BlockBuilder snowyLeaves() { - return new BlockBuilder(s -> new TintedParticleSnowyLeavesBlock(0.01f, s), AbstractBlock.Settings.create() - .mapColor(MapColor.WHITE) + return new BlockBuilder(s -> new TintedParticleSnowyLeavesBlock(0.01f, s), BlockBehaviour.Properties.of() + .mapColor(MapColor.SNOW) .strength(0.2f) - .ticksRandomly() - .sounds(PromenadeBlockSounds.SNOWY_LEAVES) - .nonOpaque() - .burnable() - .allowsSpawning(Blocks::canSpawnOnLeaves) - .suffocates(Blocks::never) - .blockVision(Blocks::never) - .pistonBehavior(PistonBehavior.DESTROY) - .solidBlock(Blocks::never)); + .randomTicks() + .sound(PromenadeBlockSounds.SNOWY_LEAVES) + .noOcclusion() + .ignitedByLava() + .isValidSpawn(Blocks::ocelotOrParrot) + .isSuffocating(Blocks::never) + .isViewBlocking(Blocks::never) + .pushReaction(PushReaction.DESTROY) + .isRedstoneConductor(Blocks::never)); } - public static BlockBuilder snowyLeaves(BlockSoundGroup soundGroup) { - return snowyLeaves().settings(settings -> settings.sounds(soundGroup)); + public static BlockBuilder snowyLeaves(SoundType soundGroup) { + return snowyLeaves().settings(settings -> settings.sound(soundGroup)); } - public static BlockBuilder snowyLeaves(float particleChance, ParticleEffect particle) { + public static BlockBuilder snowyLeaves(float particleChance, ParticleOptions particle) { return snowyLeaves().factory(s -> new UntintedParticleSnowyLeavesBlock(particleChance, particle, s)); } - public static BlockBuilder snowyLeaves(float particleChance, ParticleEffect particle, BlockSoundGroup soundGroup) { - return snowyLeaves(particleChance, particle).settings(settings -> settings.sounds(soundGroup)); + public static BlockBuilder snowyLeaves(float particleChance, ParticleOptions particle, SoundType soundGroup) { + return snowyLeaves(particleChance, particle).settings(settings -> settings.sound(soundGroup)); } public static BlockBuilder pot(Block block) { - return new BlockBuilder(s -> new FlowerPotBlock(block, s), AbstractBlock.Settings.create() - .breakInstantly() - .nonOpaque() - .luminance(state -> block.getDefaultState().getLuminance()) - .pistonBehavior(PistonBehavior.DESTROY)); + return new BlockBuilder(s -> new FlowerPotBlock(block, s), BlockBehaviour.Properties.of() + .instabreak() + .noOcclusion() + .lightLevel(state -> block.defaultBlockState().getLightEmission()) + .pushReaction(PushReaction.DESTROY)); } public static BlockBuilder pile() { - return pile(MapColor.DARK_GREEN); + return pile(MapColor.PLANT); } public static BlockBuilder pile(MapColor color) { - return pile(color, BlockSoundGroup.GRASS); + return pile(color, SoundType.GRASS); } - public static BlockBuilder pile(MapColor color, BlockSoundGroup sounds) { - return new BlockBuilder(PileBlock::new, AbstractBlock.Settings.create() + public static BlockBuilder pile(MapColor color, SoundType sounds) { + return new BlockBuilder(PileBlock::new, BlockBehaviour.Properties.of() .mapColor(color) - .burnable() + .ignitedByLava() .strength(0.1f) - .sounds(sounds) + .sound(sounds) .noCollision() - .nonOpaque()); + .noOcclusion()); } public static BlockBuilder fallenLeaves(MapColor color) { - return fallenLeaves(color, BlockSoundGroup.LEAF_LITTER); + return fallenLeaves(color, SoundType.LEAF_LITTER); } - public static BlockBuilder fallenLeaves(MapColor color, BlockSoundGroup sounds) { - return new BlockBuilder(LeafLitterBlock::new, AbstractBlock.Settings.create() + public static BlockBuilder fallenLeaves(MapColor color, SoundType sounds) { + return new BlockBuilder(LeafLitterBlock::new, BlockBehaviour.Properties.of() .mapColor(color) .replaceable() .noCollision() - .sounds(sounds) - .pistonBehavior(PistonBehavior.DESTROY) + .sound(sounds) + .pushReaction(PushReaction.DESTROY) ); } - public static BlockBuilder fungus(MapColor mapColor, RegistryKey> featureKey, TagKey canPlantOn, TagKey canGrowOn) { - return of(s -> new fr.hugman.promenade.block.FungusBlock(featureKey, canPlantOn, canGrowOn, s), AbstractBlock.Settings.create() + public static BlockBuilder fungus(MapColor mapColor, ResourceKey> featureKey, TagKey canPlantOn, TagKey canGrowOn) { + return of(s -> new fr.hugman.promenade.block.FungusBlock(featureKey, canPlantOn, canGrowOn, s), BlockBehaviour.Properties.of() .mapColor(mapColor) - .sounds(BlockSoundGroup.FUNGUS) - .pistonBehavior(PistonBehavior.DESTROY) - .breakInstantly() + .sound(SoundType.FUNGUS) + .pushReaction(PushReaction.DESTROY) + .instabreak() .noCollision()); } } diff --git a/src/main/java/fr/hugman/promenade/block/map_color/PromenadeMapColors.java b/src/main/java/fr/hugman/promenade/block/map_color/PromenadeMapColors.java index 7e3240c6..55c04000 100644 --- a/src/main/java/fr/hugman/promenade/block/map_color/PromenadeMapColors.java +++ b/src/main/java/fr/hugman/promenade/block/map_color/PromenadeMapColors.java @@ -1,26 +1,26 @@ package fr.hugman.promenade.block.map_color; -import net.minecraft.block.MapColor; +import net.minecraft.world.level.material.MapColor; public class PromenadeMapColors { public static final MapColor SAKURA_BARK = MapColor.TERRACOTTA_BROWN; public static final MapColor SAKURA_WOOD = MapColor.TERRACOTTA_BROWN; - public static final MapColor BLUSH_BLOSSOMS = MapColor.PINK; - public static final MapColor COTTON_BLOSSOMS = MapColor.OFF_WHITE; + public static final MapColor BLUSH_BLOSSOMS = MapColor.COLOR_PINK; + public static final MapColor COTTON_BLOSSOMS = MapColor.QUARTZ; - public static final MapColor MAPLE_BARK = MapColor.DEEPSLATE_GRAY; + public static final MapColor MAPLE_BARK = MapColor.DEEPSLATE; public static final MapColor MAPLE_WOOD = MapColor.TERRACOTTA_WHITE; - public static final MapColor SAP_MAPLE_LEAVES = MapColor.DARK_GREEN; - public static final MapColor VERMILION_MAPLE_LEAVES = MapColor.DULL_RED; - public static final MapColor FULVOUS_MAPLE_LEAVES = MapColor.ORANGE; + public static final MapColor SAP_MAPLE_LEAVES = MapColor.PLANT; + public static final MapColor VERMILION_MAPLE_LEAVES = MapColor.CRIMSON_NYLIUM; + public static final MapColor FULVOUS_MAPLE_LEAVES = MapColor.COLOR_ORANGE; public static final MapColor MIKADO_MAPLE_LEAVES = MapColor.GOLD; - public static final MapColor PALM_BARK = MapColor.SPRUCE_BROWN; - public static final MapColor PALM_WOOD = MapColor.ORANGE; - public static final MapColor PALM_LEAVES = MapColor.DARK_GREEN; + public static final MapColor PALM_BARK = MapColor.PODZOL; + public static final MapColor PALM_WOOD = MapColor.COLOR_ORANGE; + public static final MapColor PALM_LEAVES = MapColor.PLANT; - public static final MapColor AMARANTH_BARK = MapColor.DARK_DULL_PINK; - public static final MapColor AMARANTH_WOOD = MapColor.GRAY; + public static final MapColor AMARANTH_BARK = MapColor.WARPED_HYPHAE; + public static final MapColor AMARANTH_WOOD = MapColor.COLOR_GRAY; } diff --git a/src/main/java/fr/hugman/promenade/block/property/PromenadeBlockProperties.java b/src/main/java/fr/hugman/promenade/block/property/PromenadeBlockProperties.java index bc039b25..aed28a34 100644 --- a/src/main/java/fr/hugman/promenade/block/property/PromenadeBlockProperties.java +++ b/src/main/java/fr/hugman/promenade/block/property/PromenadeBlockProperties.java @@ -1,13 +1,13 @@ package fr.hugman.promenade.block.property; import fr.hugman.promenade.block.MoaiType; -import net.minecraft.state.property.BooleanProperty; -import net.minecraft.state.property.EnumProperty; -import net.minecraft.state.property.IntProperty; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import net.minecraft.world.level.block.state.properties.IntegerProperty; public class PromenadeBlockProperties { - public static final BooleanProperty NATURAL = BooleanProperty.of("natural"); - public static final BooleanProperty DRIP = BooleanProperty.of("drip"); - public static final EnumProperty MOAI_TYPE = EnumProperty.of("type", MoaiType.class); - public static final IntProperty DISTANCE_1_14 = IntProperty.of("distance", 1, 14); + public static final BooleanProperty NATURAL = BooleanProperty.create("natural"); + public static final BooleanProperty DRIP = BooleanProperty.create("drip"); + public static final EnumProperty MOAI_TYPE = EnumProperty.create("type", MoaiType.class); + public static final IntegerProperty DISTANCE_1_14 = IntegerProperty.create("distance", 1, 14); } diff --git a/src/main/java/fr/hugman/promenade/block/snowy/SnowyBlockTransformation.java b/src/main/java/fr/hugman/promenade/block/snowy/SnowyBlockTransformation.java index bb92bf3e..68364fe1 100644 --- a/src/main/java/fr/hugman/promenade/block/snowy/SnowyBlockTransformation.java +++ b/src/main/java/fr/hugman/promenade/block/snowy/SnowyBlockTransformation.java @@ -2,13 +2,13 @@ import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; -import net.minecraft.block.Block; -import net.minecraft.registry.Registries; -import net.minecraft.registry.entry.RegistryEntry; +import net.minecraft.core.Holder; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.world.level.block.Block; -public record SnowyBlockTransformation(RegistryEntry baseBlock, RegistryEntry snowyBlock) { +public record SnowyBlockTransformation(Holder baseBlock, Holder snowyBlock) { public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( - Registries.BLOCK.getEntryCodec().fieldOf("base_block").forGetter(SnowyBlockTransformation::baseBlock), - Registries.BLOCK.getEntryCodec().fieldOf("snowy_block").forGetter(SnowyBlockTransformation::snowyBlock) + BuiltInRegistries.BLOCK.holderByNameCodec().fieldOf("base_block").forGetter(SnowyBlockTransformation::baseBlock), + BuiltInRegistries.BLOCK.holderByNameCodec().fieldOf("snowy_block").forGetter(SnowyBlockTransformation::snowyBlock) ).apply(instance, SnowyBlockTransformation::new)); } diff --git a/src/main/java/fr/hugman/promenade/block/type/PromenadeBlockSetTypes.java b/src/main/java/fr/hugman/promenade/block/type/PromenadeBlockSetTypes.java index 5cafadad..0c49b0d5 100644 --- a/src/main/java/fr/hugman/promenade/block/type/PromenadeBlockSetTypes.java +++ b/src/main/java/fr/hugman/promenade/block/type/PromenadeBlockSetTypes.java @@ -2,7 +2,7 @@ import fr.hugman.promenade.Promenade; import net.fabricmc.fabric.api.object.builder.v1.block.type.BlockSetTypeBuilder; -import net.minecraft.block.BlockSetType; +import net.minecraft.world.level.block.state.properties.BlockSetType; public class PromenadeBlockSetTypes { public static final BlockSetType SAKURA = BlockSetTypeBuilder.copyOf(BlockSetType.CHERRY).register(Promenade.id("sakura")); diff --git a/src/main/java/fr/hugman/promenade/block/type/PromenadeWoodTypes.java b/src/main/java/fr/hugman/promenade/block/type/PromenadeWoodTypes.java index 1c5af3b4..12295457 100644 --- a/src/main/java/fr/hugman/promenade/block/type/PromenadeWoodTypes.java +++ b/src/main/java/fr/hugman/promenade/block/type/PromenadeWoodTypes.java @@ -2,7 +2,7 @@ import fr.hugman.promenade.Promenade; import net.fabricmc.fabric.api.object.builder.v1.block.type.WoodTypeBuilder; -import net.minecraft.block.WoodType; +import net.minecraft.world.level.block.state.properties.WoodType; public class PromenadeWoodTypes { public static final WoodType SAKURA = WoodTypeBuilder.copyOf(WoodType.CHERRY).register(Promenade.id("sakura"), PromenadeBlockSetTypes.SAKURA); diff --git a/src/main/java/fr/hugman/promenade/component/PromenadeComponentTypes.java b/src/main/java/fr/hugman/promenade/component/PromenadeComponentTypes.java index 471027b8..d2a73f50 100644 --- a/src/main/java/fr/hugman/promenade/component/PromenadeComponentTypes.java +++ b/src/main/java/fr/hugman/promenade/component/PromenadeComponentTypes.java @@ -5,25 +5,24 @@ import fr.hugman.promenade.entity.variant.CapybaraVariant; import fr.hugman.promenade.entity.variant.DuckVariant; import fr.hugman.promenade.entity.variant.SunkenVariant; -import net.minecraft.component.ComponentType; -import net.minecraft.network.RegistryByteBuf; -import net.minecraft.network.codec.PacketCodec; -import net.minecraft.registry.Registries; -import net.minecraft.registry.Registry; -import net.minecraft.registry.entry.RegistryEntry; - import java.util.function.UnaryOperator; +import net.minecraft.core.Holder; +import net.minecraft.core.Registry; +import net.minecraft.core.component.DataComponentType; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.StreamCodec; public class PromenadeComponentTypes { - public static final ComponentType> DUCK_VARIANT = of("duck/variant", DuckVariant.ENTRY_CODEC, DuckVariant.ENTRY_PACKET_CODEC); - public static final ComponentType> CAPYBARA_VARIANT = of("capybara/variant", CapybaraVariant.ENTRY_CODEC, CapybaraVariant.ENTRY_PACKET_CODEC); - public static final ComponentType> SUNKEN_VARIANT = of("sunken/variant", SunkenVariant.ENTRY_CODEC, SunkenVariant.ENTRY_PACKET_CODEC); + public static final DataComponentType> DUCK_VARIANT = of("duck/variant", DuckVariant.ENTRY_CODEC, DuckVariant.ENTRY_PACKET_CODEC); + public static final DataComponentType> CAPYBARA_VARIANT = of("capybara/variant", CapybaraVariant.ENTRY_CODEC, CapybaraVariant.ENTRY_PACKET_CODEC); + public static final DataComponentType> SUNKEN_VARIANT = of("sunken/variant", SunkenVariant.ENTRY_CODEC, SunkenVariant.ENTRY_PACKET_CODEC); - private static ComponentType of(String id, Codec codec, PacketCodec packetCodec) { - return of(id, builder -> builder.codec(codec).packetCodec(packetCodec)); + private static DataComponentType of(String id, Codec codec, StreamCodec packetCodec) { + return of(id, builder -> builder.persistent(codec).networkSynchronized(packetCodec)); } - private static ComponentType of(String id, UnaryOperator> builderOperator) { - return Registry.register(Registries.DATA_COMPONENT_TYPE, Promenade.id(id), ((ComponentType.Builder)builderOperator.apply(ComponentType.builder())).build()); + private static DataComponentType of(String id, UnaryOperator> builderOperator) { + return Registry.register(BuiltInRegistries.DATA_COMPONENT_TYPE, Promenade.id(id), ((DataComponentType.Builder)builderOperator.apply(DataComponentType.builder())).build()); } } diff --git a/src/main/java/fr/hugman/promenade/component/PromenadeConsumableComponents.java b/src/main/java/fr/hugman/promenade/component/PromenadeConsumableComponents.java index d48672d2..1cd589d4 100644 --- a/src/main/java/fr/hugman/promenade/component/PromenadeConsumableComponents.java +++ b/src/main/java/fr/hugman/promenade/component/PromenadeConsumableComponents.java @@ -1,23 +1,23 @@ package fr.hugman.promenade.component; -import net.minecraft.component.type.ConsumableComponent; -import net.minecraft.component.type.ConsumableComponents; -import net.minecraft.entity.effect.StatusEffectInstance; -import net.minecraft.entity.effect.StatusEffects; -import net.minecraft.item.consume.ApplyEffectsConsumeEffect; -import net.minecraft.item.consume.RemoveEffectsConsumeEffect; -import net.minecraft.sound.SoundEvents; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.world.effect.MobEffectInstance; +import net.minecraft.world.effect.MobEffects; +import net.minecraft.world.item.component.Consumable; +import net.minecraft.world.item.component.Consumables; +import net.minecraft.world.item.consume_effects.ApplyStatusEffectsConsumeEffect; +import net.minecraft.world.item.consume_effects.RemoveStatusEffectsConsumeEffect; public class PromenadeConsumableComponents { - public static final ConsumableComponent MAPLE_SYRUP_BOTTLE = ConsumableComponents.drink() + public static final Consumable MAPLE_SYRUP_BOTTLE = Consumables.defaultDrink() .consumeSeconds(2.0F) - .sound(SoundEvents.ITEM_HONEY_BOTTLE_DRINK) - .consumeEffect(new RemoveEffectsConsumeEffect(StatusEffects.POISON)) + .sound(SoundEvents.HONEY_DRINK) + .onConsume(new RemoveStatusEffectsConsumeEffect(MobEffects.POISON)) .build(); - public static final ConsumableComponent RAW_DUCK = foodWithEffect(new StatusEffectInstance(StatusEffects.HUNGER, 600, 0), 0.3F); + public static final Consumable RAW_DUCK = foodWithEffect(new MobEffectInstance(MobEffects.HUNGER, 600, 0), 0.3F); - public static ConsumableComponent foodWithEffect(StatusEffectInstance effect, float probability) { - return ConsumableComponents.food().consumeEffect(new ApplyEffectsConsumeEffect(effect, probability)).build(); + public static Consumable foodWithEffect(MobEffectInstance effect, float probability) { + return Consumables.defaultFood().onConsume(new ApplyStatusEffectsConsumeEffect(effect, probability)).build(); } } diff --git a/src/main/java/fr/hugman/promenade/component/PromenadeFoodComponents.java b/src/main/java/fr/hugman/promenade/component/PromenadeFoodComponents.java index 425897d6..9e26c25c 100644 --- a/src/main/java/fr/hugman/promenade/component/PromenadeFoodComponents.java +++ b/src/main/java/fr/hugman/promenade/component/PromenadeFoodComponents.java @@ -1,24 +1,24 @@ package fr.hugman.promenade.component; -import net.minecraft.component.type.FoodComponent; +import net.minecraft.world.food.FoodProperties; public class PromenadeFoodComponents { - public static final FoodComponent MAPLE_SYRUP_BOTTLE = alwaysEdible(6, 0.1F); + public static final FoodProperties MAPLE_SYRUP_BOTTLE = alwaysEdible(6, 0.1F); - public static final FoodComponent BLUEBERRIES = simple(2, 0.1F); + public static final FoodProperties BLUEBERRIES = simple(2, 0.1F); - public static final FoodComponent BANANA = simple(4, 0.3F); - public static final FoodComponent APRICOT = simple(4, 0.3F); - public static final FoodComponent MANGO = simple(4, 0.3F); + public static final FoodProperties BANANA = simple(4, 0.3F); + public static final FoodProperties APRICOT = simple(4, 0.3F); + public static final FoodProperties MANGO = simple(4, 0.3F); - public static final FoodComponent RAW_DUCK = simple(2, 0.3F); - public static final FoodComponent COOKED_DUCK = simple(6, 0.6F); + public static final FoodProperties RAW_DUCK = simple(2, 0.3F); + public static final FoodProperties COOKED_DUCK = simple(6, 0.6F); - public static FoodComponent simple(int nutrition, float saturation) { - return new FoodComponent.Builder().nutrition(nutrition).saturationModifier(saturation).build(); + public static FoodProperties simple(int nutrition, float saturation) { + return new FoodProperties.Builder().nutrition(nutrition).saturationModifier(saturation).build(); } - public static FoodComponent alwaysEdible(int nutrition, float saturation) { - return new FoodComponent.Builder().nutrition(nutrition).saturationModifier(saturation).build(); + public static FoodProperties alwaysEdible(int nutrition, float saturation) { + return new FoodProperties.Builder().nutrition(nutrition).saturationModifier(saturation).build(); } } diff --git a/src/main/java/fr/hugman/promenade/config/PromenadeConfig.java b/src/main/java/fr/hugman/promenade/config/PromenadeConfig.java index 8bf08bf4..8a4f52e6 100644 --- a/src/main/java/fr/hugman/promenade/config/PromenadeConfig.java +++ b/src/main/java/fr/hugman/promenade/config/PromenadeConfig.java @@ -9,7 +9,6 @@ import com.mojang.serialization.codecs.RecordCodecBuilder; import fr.hugman.promenade.Promenade; import fr.hugman.promenade.world.biome.PromenadeBiomes; -import net.minecraft.world.biome.source.util.MultiNoiseUtil; import org.apache.commons.io.IOUtils; import org.jetbrains.annotations.NotNull; @@ -20,6 +19,7 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.Optional; +import net.minecraft.world.level.biome.Climate; public record PromenadeConfig( BiomesConfig biomes, @@ -55,7 +55,7 @@ public record BiomesConfig( int carnelianTreewayWeight, int sakuraGrovesWeight, int glacarianTaigaWeight, - Optional darkAmaranthForestsNoise + Optional darkAmaranthForestsNoise ) { private static final Codec CODEC = RecordCodecBuilder.create(instance -> @@ -63,7 +63,7 @@ public record BiomesConfig( Codec.INT.optionalFieldOf("carnelian_treeway_weight", 20).forGetter(BiomesConfig::carnelianTreewayWeight), Codec.INT.optionalFieldOf("sakura_groves_weight", 20).forGetter(BiomesConfig::sakuraGrovesWeight), Codec.INT.optionalFieldOf("glacarian_taiga_weight", 10).forGetter(BiomesConfig::glacarianTaigaWeight), - MultiNoiseUtil.NoiseHypercube.CODEC.optionalFieldOf("dark_amaranth_forests_noise").forGetter(BiomesConfig::darkAmaranthForestsNoise) + Climate.ParameterPoint.CODEC.optionalFieldOf("dark_amaranth_forests_noise").forGetter(BiomesConfig::darkAmaranthForestsNoise) ).apply(instance, BiomesConfig::new) ); } diff --git a/src/main/java/fr/hugman/promenade/entity/CapybaraEntity.java b/src/main/java/fr/hugman/promenade/entity/Capybara.java similarity index 51% rename from src/main/java/fr/hugman/promenade/entity/CapybaraEntity.java rename to src/main/java/fr/hugman/promenade/entity/Capybara.java index 5468325f..5810f28b 100644 --- a/src/main/java/fr/hugman/promenade/entity/CapybaraEntity.java +++ b/src/main/java/fr/hugman/promenade/entity/Capybara.java @@ -1,8 +1,8 @@ package fr.hugman.promenade.entity; -import com.mojang.serialization.Dynamic; import fr.hugman.promenade.component.PromenadeComponentTypes; import fr.hugman.promenade.entity.ai.brain.PromenadeMemoryModuleTypes; +import fr.hugman.promenade.entity.ai.brain.sensor.PromenadeSensorTypes; import fr.hugman.promenade.entity.data.PromenadeTrackedData; import fr.hugman.promenade.entity.variant.CapybaraVariant; import fr.hugman.promenade.entity.variant.CapybaraVariants; @@ -13,64 +13,76 @@ import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.SharedConstants; -import net.minecraft.component.ComponentType; -import net.minecraft.component.ComponentsAccess; -import net.minecraft.entity.*; -import net.minecraft.entity.ai.brain.Brain; -import net.minecraft.entity.ai.brain.MemoryModuleState; -import net.minecraft.entity.ai.brain.MemoryModuleType; -import net.minecraft.entity.ai.control.BodyControl; -import net.minecraft.entity.attribute.DefaultAttributeContainer; -import net.minecraft.entity.attribute.EntityAttributes; -import net.minecraft.entity.data.DataTracker; -import net.minecraft.entity.data.TrackedData; -import net.minecraft.entity.data.TrackedDataHandlerRegistry; -import net.minecraft.entity.passive.AnimalEntity; -import net.minecraft.entity.passive.PassiveEntity; -import net.minecraft.entity.spawn.SpawnContext; -import net.minecraft.item.ItemStack; -import net.minecraft.network.codec.PacketCodec; -import net.minecraft.network.codec.PacketCodecs; -import net.minecraft.registry.entry.RegistryEntry; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.sound.SoundEvent; -import net.minecraft.storage.ReadView; -import net.minecraft.storage.WriteView; -import net.minecraft.util.StringIdentifiable; +import net.minecraft.core.Holder; +import net.minecraft.core.component.DataComponentGetter; +import net.minecraft.core.component.DataComponentType; +import net.minecraft.network.codec.ByteBufCodecs; +import net.minecraft.network.codec.StreamCodec; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.sounds.SoundEvent; +import net.minecraft.util.ByIdMap; +import net.minecraft.util.Mth; +import net.minecraft.util.StringRepresentable; import net.minecraft.util.Unit; -import net.minecraft.util.function.ValueLists; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.Vec3d; -import net.minecraft.util.math.floatprovider.FloatProvider; -import net.minecraft.util.math.floatprovider.TrapezoidFloatProvider; -import net.minecraft.util.math.intprovider.BiasedToBottomIntProvider; -import net.minecraft.util.math.intprovider.IntProvider; -import net.minecraft.util.profiler.Profiler; -import net.minecraft.util.profiler.Profilers; -import net.minecraft.world.LocalDifficulty; -import net.minecraft.world.ServerWorldAccess; -import net.minecraft.world.World; -import net.minecraft.world.event.GameEvent; +import net.minecraft.util.profiling.Profiler; +import net.minecraft.util.profiling.ProfilerFiller; +import net.minecraft.util.valueproviders.BiasedToBottomInt; +import net.minecraft.util.valueproviders.FloatProvider; +import net.minecraft.util.valueproviders.IntProvider; +import net.minecraft.util.valueproviders.TrapezoidFloat; +import net.minecraft.world.DifficultyInstance; +import net.minecraft.world.entity.*; +import net.minecraft.world.entity.ai.Brain; +import net.minecraft.world.entity.ai.attributes.AttributeSupplier; +import net.minecraft.world.entity.ai.attributes.Attributes; +import net.minecraft.world.entity.ai.control.BodyRotationControl; +import net.minecraft.world.entity.ai.memory.MemoryModuleType; +import net.minecraft.world.entity.ai.memory.MemoryStatus; +import net.minecraft.world.entity.ai.sensing.SensorType; +import net.minecraft.world.entity.animal.Animal; +import net.minecraft.world.entity.variant.SpawnContext; +import net.minecraft.world.entity.variant.VariantUtils; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.ServerLevelAccessor; +import net.minecraft.world.level.gameevent.GameEvent; +import net.minecraft.world.level.storage.ValueInput; +import net.minecraft.world.level.storage.ValueOutput; +import net.minecraft.world.phys.Vec3; import org.jetbrains.annotations.Nullable; +import java.util.List; import java.util.function.IntFunction; -public class CapybaraEntity extends AnimalEntity { - private static final FloatProvider FART_CHANCE_PROVIDER = TrapezoidFloatProvider.create(0.1F, 0.55F, 0.2F); - private static final EntityDimensions BABY_BASE_DIMENSIONS = EntityDimensions.changing(0.7f, 0.875f).scaled(0.5F).withEyeHeight(0.5F); +public class Capybara extends Animal { + private static final FloatProvider FART_CHANCE_PROVIDER = TrapezoidFloat.of(0.1F, 0.55F, 0.2F); + private static final EntityDimensions BABY_DIMENSIONS = EntityDimensions.scalable(0.49f, 0.45f).withEyeHeight(0.40F); - protected static final TrackedData STATE = DataTracker.registerData(CapybaraEntity.class, PromenadeTrackedData.CAPYBARA_STATE); - public static final TrackedData LAST_STATE_TICK = DataTracker.registerData(CapybaraEntity.class, TrackedDataHandlerRegistry.LONG); + protected static final EntityDataAccessor STATE = SynchedEntityData.defineId(Capybara.class, PromenadeTrackedData.CAPYBARA_STATE); + public static final EntityDataAccessor LAST_STATE_TICK = SynchedEntityData.defineId(Capybara.class, EntityDataSerializers.LONG); public static final String FART_CHANCE_KEY = "fart_chance"; public static final String LAST_STATE_TICK_KEY = "last_state_tick"; public static final String STATE_KEY = "state_key"; - private static final TrackedData> VARIANT = DataTracker.registerData(CapybaraEntity.class, PromenadeTrackedData.CAPYBARA_VARIANT); - private static final TrackedData FART_CHANCE = DataTracker.registerData(CapybaraEntity.class, TrackedDataHandlerRegistry.FLOAT); + private static final EntityDataAccessor> VARIANT = SynchedEntityData.defineId(Capybara.class, PromenadeTrackedData.CAPYBARA_VARIANT); + private static final EntityDataAccessor FART_CHANCE = SynchedEntityData.defineId(Capybara.class, EntityDataSerializers.FLOAT); + + private static final Brain.Provider BRAIN_PROVIDER = Brain.provider( + List.of( + SensorType.NEAREST_LIVING_ENTITIES, + SensorType.HURT_BY, + PromenadeSensorTypes.CAPYBARA_TEMPTATIONS, + SensorType.NEAREST_ADULT, + SensorType.IS_IN_WATER + ), _ -> CapybaraAi.getActivities() + ); private static final int EAR_WIGGLE_LENGHT = (int) (0.2f * SharedConstants.TICKS_PER_SECOND); - private static final IntProvider EAR_WIGGLE_COOLDOWN_PROVIDER = BiasedToBottomIntProvider.create(EAR_WIGGLE_LENGHT, 64); // Minimum MUST be the length of the anim + private static final IntProvider EAR_WIGGLE_COOLDOWN_PROVIDER = BiasedToBottomInt.of(EAR_WIGGLE_LENGHT, 64); // Minimum MUST be the length of the anim public final AnimationState earWiggleAnimState = new AnimationState(); public final AnimationState fallToSleepAnimState = new AnimationState(); public final AnimationState sleepingAnimState = new AnimationState(); @@ -79,72 +91,68 @@ public class CapybaraEntity extends AnimalEntity { public int earWiggleCooldown = 0; - public CapybaraEntity(EntityType entityType, World world) { + public Capybara(EntityType entityType, Level world) { super(entityType, world); - this.getNavigation().setCanSwim(true); + this.getNavigation().setCanFloat(true); } @Override public void tick() { super.tick(); - if (this.getEntityWorld().isClient()) { + if (this.level().isClientSide()) { this.updateAnimations(); } this.tickState(); } @Override - protected void mobTick(ServerWorld world) { - Profiler profiler = Profilers.get(); + protected void customServerAiStep(ServerLevel world) { + ProfilerFiller profiler = Profiler.get(); profiler.push("capybaraBrain"); - Brain brain = (Brain) this.getBrain(); - brain.tick((ServerWorld) this.getEntityWorld(), this); + Brain brain = (Brain) this.getBrain(); + brain.tick((ServerLevel) this.level(), this); profiler.pop(); profiler.push("capybaraActivityUpdate"); - CapybaraBrain.updateActivities(this); + CapybaraAi.updateActivities(this); profiler.pop(); - super.mobTick(world); + super.customServerAiStep(world); } @Override - public EntityData initialize(ServerWorldAccess world, LocalDifficulty difficulty, SpawnReason spawnReason, @Nullable EntityData entityData) { - CapybaraVariants.select(this.random, this.getRegistryManager(), SpawnContext.of(world, this.getBlockPos())).ifPresent(this::setVariant); - this.dataTracker.set(LAST_STATE_TICK, world.toServerWorld().getTime() - WAKE_UP_LENGTH); - this.dataTracker.set(FART_CHANCE, FART_CHANCE_PROVIDER.get(this.random)); - return super.initialize(world, difficulty, spawnReason, entityData); + public SpawnGroupData finalizeSpawn(ServerLevelAccessor world, DifficultyInstance difficulty, EntitySpawnReason spawnReason, @Nullable SpawnGroupData entityData) { + CapybaraVariants.select(this.random, this.registryAccess(), SpawnContext.create(world, this.blockPosition())).ifPresent(this::setVariant); + this.entityData.set(LAST_STATE_TICK, world.getLevel().getGameTime() - WAKE_UP_LENGTH); + this.entityData.set(FART_CHANCE, FART_CHANCE_PROVIDER.sample(this.random)); + return super.finalizeSpawn(world, difficulty, spawnReason, entityData); } /*========*/ /* AI */ /*========*/ - public static DefaultAttributeContainer.Builder createCapybaraAttributes() { + public static AttributeSupplier.Builder createCapybaraAttributes() { return createAnimalAttributes() - .add(EntityAttributes.MAX_HEALTH, 10.0) - .add(EntityAttributes.MOVEMENT_SPEED, 0.2); - } - - protected Brain.Profile createBrainProfile() { - return CapybaraBrain.createProfile(); + .add(Attributes.MAX_HEALTH, 10.0) + .add(Attributes.MOVEMENT_SPEED, 0.2); } @Override - protected Brain deserializeBrain(Dynamic dynamic) { - return CapybaraBrain.create(this.createBrainProfile().deserialize(dynamic)); + protected Brain makeBrain(Brain.Packed packedBrain) { + return BRAIN_PROVIDER.makeBrain(this, packedBrain); } @Override - public boolean isBreedingItem(ItemStack stack) { - return stack.isIn(PromenadeItemTags.CAPYBARA_FOOD); + public boolean isFood(ItemStack stack) { + return stack.is(PromenadeItemTags.CAPYBARA_FOOD); } @Override - public void travel(Vec3d movementInput) { + public void travel(Vec3 movementInput) { if (!this.isAlive()) { return; } - if (this.isStationary() && this.isOnGround()) { - this.setVelocity(this.getVelocity().multiply(0.0, 1.0, 0.0)); + if (this.isStationary() && this.onGround()) { + this.setDeltaMovement(this.getDeltaMovement().multiply(0.0, 1.0, 0.0)); movementInput = movementInput.multiply(0.0, 1.0, 0.0); } super.travel(movementInput); @@ -155,29 +163,29 @@ public boolean isStationary() { } public boolean isPanicking() { - return this.getBrain().isMemoryInState(MemoryModuleType.IS_PANICKING, MemoryModuleState.VALUE_PRESENT); + return this.getBrain().checkMemory(MemoryModuleType.IS_PANICKING, MemoryStatus.VALUE_PRESENT); } @Override - protected EntityDimensions getBaseDimensions(EntityPose pose) { - return this.isBaby() ? BABY_BASE_DIMENSIONS : super.getBaseDimensions(pose); + protected EntityDimensions getDefaultDimensions(Pose pose) { + return this.isBaby() ? BABY_DIMENSIONS : super.getDefaultDimensions(pose); } @Override - protected BodyControl createBodyControl() { + protected BodyRotationControl createBodyControl() { return new CapybaraBodyControl(this); } - class CapybaraBodyControl extends BodyControl { + class CapybaraBodyControl extends BodyRotationControl { - public CapybaraBodyControl(CapybaraEntity capybara) { + public CapybaraBodyControl(Capybara capybara) { super(capybara); } @Override - public void tick() { - if (!CapybaraEntity.this.isStationary()) { - super.tick(); + public void clientTick() { + if (!Capybara.this.isStationary()) { + super.clientTick(); } } } @@ -199,7 +207,7 @@ public void forceDefaultState() { public void updateState(State state) { this.setState(state); - this.setLastStateTick(this.getEntityWorld().getTime()); + this.setLastStateTick(this.level().getGameTime()); } private void tickState() { @@ -249,7 +257,7 @@ private boolean isWakingUp() { } public boolean canWakeUp() { - return this.isAsleep() && this.getEntityWorld().isDay(); + return this.isAsleep() && this.level().isBrightOutside(); } public long getWakeUpLength() { @@ -274,10 +282,10 @@ public boolean isStanding() { public void fart() { this.updateState(State.FARTING); - this.getBrain().remember(PromenadeMemoryModuleTypes.FART_COOLDOWN, Unit.INSTANCE, createFartCooldown()); + this.getBrain().setMemoryWithExpiry(PromenadeMemoryModuleTypes.FART_COOLDOWN, Unit.INSTANCE, createFartCooldown()); - this.playSound(PromenadeSoundEvents.CAPYBARA_FART, getSoundVolume(), getSoundPitch()); - this.emitGameEvent(GameEvent.ENTITY_ACTION); + this.playSound(PromenadeSoundEvents.CAPYBARA_FART, getSoundVolume(), getVoicePitch()); + this.gameEvent(GameEvent.ENTITY_ACTION); } public boolean isFarting() { @@ -297,22 +305,22 @@ public void finishFarting() { } public void setLastStateTick(long t) { - this.dataTracker.set(LAST_STATE_TICK, t); + this.entityData.set(LAST_STATE_TICK, t); } public long getLastStateTickDelta() { - return this.getEntityWorld().getTime() - this.dataTracker.get(LAST_STATE_TICK); + return this.level().getGameTime() - this.entityData.get(LAST_STATE_TICK); } public State getState() { - return this.dataTracker.get(STATE); + return this.entityData.get(STATE); } public void setState(State state) { - this.dataTracker.set(STATE, state); + this.entityData.set(STATE, state); } - public enum State implements StringIdentifiable { + public enum State implements StringRepresentable { IDLING("idling", 0), FARTING("farting", 1), SLEEPING("sleeping", 2), @@ -322,9 +330,9 @@ public enum State implements StringIdentifiable { private final String name; private final int index; - private static final EnumCodec CODEC = StringIdentifiable.createCodec(State::values); - private static final IntFunction INDEX_TO_VALUE = ValueLists.createIndexToValueFunction(State::getIndex, values(), ValueLists.OutOfBoundsHandling.ZERO); - public static final PacketCodec PACKET_CODEC = PacketCodecs.indexed(INDEX_TO_VALUE, State::getIndex); + private static final EnumCodec CODEC = StringRepresentable.fromEnum(State::values); + private static final IntFunction INDEX_TO_VALUE = ByIdMap.continuous(State::getIndex, values(), ByIdMap.OutOfBoundsStrategy.ZERO); + public static final StreamCodec PACKET_CODEC = ByteBufCodecs.idMapper(INDEX_TO_VALUE, State::getIndex); State(String name, int index) { this.name = name; @@ -332,10 +340,10 @@ public enum State implements StringIdentifiable { } public static State fromName(String name) { - return CODEC.byId(name, IDLING); + return CODEC.byName(name, IDLING); } - public String asString() { + public String getSerializedName() { return this.name; } @@ -351,8 +359,8 @@ private int getIndex() { @Environment(EnvType.CLIENT) private void updateAnimations() { if (this.earWiggleCooldown <= 0) { - this.earWiggleCooldown = MathHelper.clamp(EAR_WIGGLE_COOLDOWN_PROVIDER.get(this.random), (int) (EAR_WIGGLE_LENGHT / this.getEarWiggleSpeed()), Integer.MAX_VALUE); - this.earWiggleAnimState.start(this.age); + this.earWiggleCooldown = Mth.clamp(EAR_WIGGLE_COOLDOWN_PROVIDER.sample(this.random), (int) (EAR_WIGGLE_LENGHT / this.getEarWiggleSpeed()), Integer.MAX_VALUE); + this.earWiggleAnimState.start(this.tickCount); } else { this.earWiggleCooldown--; } @@ -366,7 +374,7 @@ private void stopAnimations() { } @Override - public void onTrackedDataSet(TrackedData data) { + public void onSyncedDataUpdated(EntityDataAccessor data) { if (STATE.equals(data)) { var state = this.getState(); this.stopAnimations(); @@ -377,20 +385,20 @@ public void onTrackedDataSet(TrackedData data) { case FARTING -> this.fartAnimState; case null, default -> null; }); - if (animstate != null) animstate.startIfNotRunning(this.age); + if (animstate != null) animstate.startIfStopped(this.tickCount); } - super.onTrackedDataSet(data); + super.onSyncedDataUpdated(data); } @Environment(EnvType.CLIENT) - public boolean hasLargeEyes() { + public boolean isSurprised() { boolean surprisedByFart = this.isFarting() && this.getLastStateTickDelta() < 40L; return isBaby() || surprisedByFart; } @Environment(EnvType.CLIENT) - public boolean hasClosedEyes() { + public boolean isVisuallySleeping() { boolean aboutToStartToSleep = this.isFallingToSleep() && this.getLastStateTickDelta() > 31L; boolean shakingHead = this.isFarting() && (40L < this.getLastStateTickDelta() && this.getLastStateTickDelta() < 65L); boolean wakingUp = this.isWakingUp() && (this.getLastStateTickDelta() < 5L || (18L < this.getLastStateTickDelta() && this.getLastStateTickDelta() < 34L)); @@ -423,8 +431,8 @@ protected SoundEvent getAmbientSound() { } @Override - public int getMinAmbientSoundDelay() { - return this.isBaby() ? 20 : super.getMinAmbientSoundDelay(); + public int getAmbientSoundInterval() { + return this.isBaby() ? 20 : super.getAmbientSoundInterval(); } @Override @@ -444,28 +452,28 @@ public void playAmbientSound() { @Nullable @Override - public PassiveEntity createChild(ServerWorld world, PassiveEntity entity) { - var capyBaby = PromenadeEntityTypes.CAPYBARA.create(this.getEntityWorld(), SpawnReason.BREEDING); - if (capyBaby != null && entity instanceof CapybaraEntity capyMama) { + public AgeableMob getBreedOffspring(ServerLevel world, AgeableMob entity) { + var capyBaby = PromenadeEntityTypes.CAPYBARA.create(this.level(), EntitySpawnReason.BREEDING); + if (capyBaby != null && entity instanceof Capybara capyMama) { capyBaby.setVariant(this.random.nextBoolean() ? this.getVariant() : capyMama.getVariant()); } return capyBaby; } - public RegistryEntry getVariant() { - return this.dataTracker.get(VARIANT); + public Holder getVariant() { + return this.entityData.get(VARIANT); } - public void setVariant(RegistryEntry variant) { - this.dataTracker.set(VARIANT, variant); + public void setVariant(Holder variant) { + this.entityData.set(VARIANT, variant); } public float getFartChance() { - return this.dataTracker.get(FART_CHANCE); + return this.entityData.get(FART_CHANCE); } public void setFartChance(float frequency) { - this.dataTracker.set(FART_CHANCE, frequency); + this.entityData.set(FART_CHANCE, frequency); } @@ -475,53 +483,53 @@ public void setFartChance(float frequency) { /*==========*/ @Override - protected void initDataTracker(DataTracker.Builder builder) { - super.initDataTracker(builder); - builder.add(VARIANT, Variants.getOrDefaultOrThrow(this.getRegistryManager(), CapybaraVariants.DEFAULT)); - builder.add(FART_CHANCE, 0.0f); - builder.add(STATE, State.IDLING); - builder.add(LAST_STATE_TICK, -WAKE_UP_LENGTH); + protected void defineSynchedData(SynchedEntityData.Builder builder) { + super.defineSynchedData(builder); + builder.define(VARIANT, VariantUtils.getDefaultOrAny(this.registryAccess(), CapybaraVariants.DEFAULT)); + builder.define(FART_CHANCE, 0.0f); + builder.define(STATE, State.IDLING); + builder.define(LAST_STATE_TICK, -WAKE_UP_LENGTH); } @Override - protected void writeCustomData(WriteView view) { - super.writeCustomData(view); - Variants.writeData(view, this.getVariant()); + protected void addAdditionalSaveData(ValueOutput view) { + super.addAdditionalSaveData(view); + VariantUtils.writeVariant(view, this.getVariant()); view.putFloat(FART_CHANCE_KEY, this.getFartChance()); - view.putString(STATE_KEY, this.getState().asString()); - view.putLong(LAST_STATE_TICK_KEY, this.dataTracker.get(LAST_STATE_TICK)); + view.putString(STATE_KEY, this.getState().getSerializedName()); + view.putLong(LAST_STATE_TICK_KEY, this.entityData.get(LAST_STATE_TICK)); } @Override - protected void readCustomData(ReadView view) { - super.readCustomData(view); - Variants.fromData(view, PromenadeRegistryKeys.CAPYBARA_VARIANT).ifPresent(this::setVariant); + protected void readAdditionalSaveData(ValueInput view) { + super.readAdditionalSaveData(view); + VariantUtils.readVariant(view, PromenadeRegistryKeys.CAPYBARA_VARIANT).ifPresent(this::setVariant); - view.getOptionalString(STATE_KEY).ifPresent(s -> this.setState(State.fromName(s))); - view.getOptionalLong(LAST_STATE_TICK_KEY).ifPresent(this::setLastStateTick); - this.setFartChance(view.getFloat(FART_CHANCE_KEY, FART_CHANCE_PROVIDER.getMin())); + view.getString(STATE_KEY).ifPresent(s -> this.setState(State.fromName(s))); + view.getLong(LAST_STATE_TICK_KEY).ifPresent(this::setLastStateTick); + this.setFartChance(view.getFloatOr(FART_CHANCE_KEY, FART_CHANCE_PROVIDER.min())); } @Nullable @Override - public T get(ComponentType type) { - return type == PromenadeComponentTypes.CAPYBARA_VARIANT ? castComponentValue((ComponentType)type, this.getVariant()) : super.get(type); + public T get(DataComponentType type) { + return type == PromenadeComponentTypes.CAPYBARA_VARIANT ? castComponentValue((DataComponentType)type, this.getVariant()) : super.get(type); } @Override - protected void copyComponentsFrom(ComponentsAccess from) { - this.copyComponentFrom(from, PromenadeComponentTypes.CAPYBARA_VARIANT); - super.copyComponentsFrom(from); + protected void applyImplicitComponents(DataComponentGetter from) { + this.applyImplicitComponentIfPresent(from, PromenadeComponentTypes.CAPYBARA_VARIANT); + super.applyImplicitComponents(from); } @Override - protected boolean setApplicableComponent(ComponentType type, T value) { + protected boolean applyImplicitComponent(DataComponentType type, T value) { if (type == PromenadeComponentTypes.CAPYBARA_VARIANT) { this.setVariant(castComponentValue(PromenadeComponentTypes.CAPYBARA_VARIANT, value)); return true; } else { - return super.setApplicableComponent(type, value); + return super.applyImplicitComponent(type, value); } } } diff --git a/src/main/java/fr/hugman/promenade/entity/CapybaraAi.java b/src/main/java/fr/hugman/promenade/entity/CapybaraAi.java new file mode 100644 index 00000000..b14843a0 --- /dev/null +++ b/src/main/java/fr/hugman/promenade/entity/CapybaraAi.java @@ -0,0 +1,140 @@ +package fr.hugman.promenade.entity; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.mojang.datafixers.util.Pair; +import fr.hugman.promenade.entity.ai.brain.PromenadeMemoryModuleTypes; +import fr.hugman.promenade.tag.PromenadeItemTags; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.util.valueproviders.UniformInt; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.ai.ActivityData; +import net.minecraft.world.entity.ai.behavior.*; +import net.minecraft.world.entity.ai.behavior.declarative.BehaviorBuilder; +import net.minecraft.world.entity.ai.memory.MemoryModuleType; +import net.minecraft.world.entity.ai.memory.MemoryStatus; +import net.minecraft.world.entity.schedule.Activity; +import net.minecraft.world.item.ItemStack; + +import java.util.List; +import java.util.Map; +import java.util.function.Predicate; + +public class CapybaraAi { + private static final UniformInt WALK_TOWARD_ADULT_RANGE = UniformInt.of(5, 16); + + protected static List> getActivities() { + return List.of(initCoreActivity(), initIdleActivity()); + } + + private static ActivityData initCoreActivity() { + return ActivityData.create( + Activity.CORE, + 0, + ImmutableList.of( + new Swim<>(0.8f), + new AnimalPanic<>(1.0F) { + private void run(ServerLevel serverWorld, Capybara capybara, long l) { + capybara.forceDefaultState(); + super.start(serverWorld, capybara, l); + } + }, + new LookAtTargetSink(45, 90), + new MoveToTargetSink(), + new CountDownCooldownTicks(MemoryModuleType.TEMPTATION_COOLDOWN_TICKS), + new CountDownCooldownTicks(MemoryModuleType.GAZE_COOLDOWN_TICKS) + ) + ); + } + + + private static ActivityData initIdleActivity() { + return ActivityData.create( + Activity.IDLE, + ImmutableList.of( + Pair.of(0, SetEntityLookTargetSometimes.create(EntityType.PLAYER, 6.0f, UniformInt.of(30, 60))), + Pair.of(1, new AnimalMakeLove(PromenadeEntityTypes.CAPYBARA)), + Pair.of(2, new FollowTemptation(_ -> 1.5f)), + Pair.of(3, BehaviorBuilder.triggerIf(Predicate.not(Capybara::isStationary), BabyFollowAdult.create(WALK_TOWARD_ADULT_RANGE, 1.5f))), + Pair.of(4, new RandomLookAround(UniformInt.of(150, 250), 30.0f, 0.0f, 10.0f)), + Pair.of(5, new RunOne<>(ImmutableMap.of(MemoryModuleType.WALK_TARGET, MemoryStatus.VALUE_ABSENT), ImmutableList.of( + Pair.of(BehaviorBuilder.triggerIf(Predicate.not(Capybara::isStationary), RandomStroll.stroll(1.0f)), 1), + Pair.of(BehaviorBuilder.triggerIf(Predicate.not(Capybara::isStationary), SetWalkTargetFromLookTarget.create(1.0f, 3)), 1), + Pair.of(new SleepOrWakeUp(20), 1), + Pair.of(new Fart(10), 1), + Pair.of(new DoNothing(30, 60), 1) + )))) + ); + } + + public static void updateActivities(Capybara capybara) { + capybara.getBrain().setActiveActivityToFirstValid(ImmutableList.of(Activity.IDLE)); + } + + public static Predicate getTemptItemPredicate() { + return (stack) -> stack.is(PromenadeItemTags.CAPYBARA_FOOD); + } + + public static class SleepOrWakeUp extends Behavior { + private final int lastPoseTickDelta; + + public SleepOrWakeUp(int lastPoseSecondsDelta) { + super(ImmutableMap.of( + MemoryModuleType.IS_PANICKING, MemoryStatus.VALUE_ABSENT, + MemoryModuleType.IS_TEMPTED, MemoryStatus.VALUE_ABSENT, + MemoryModuleType.IS_IN_WATER, MemoryStatus.VALUE_ABSENT, + MemoryModuleType.BREED_TARGET, MemoryStatus.VALUE_ABSENT)); + this.lastPoseTickDelta = lastPoseSecondsDelta * 20; + } + + @Override + protected boolean checkExtraStartConditions(ServerLevel serverLevel, Capybara capybara) { + return capybara.getLastStateTickDelta() >= this.lastPoseTickDelta && + !capybara.isLeashed() && + capybara.onGround() && + !capybara.hasControllingPassenger(); + } + + @Override + protected void start(ServerLevel serverLevel, Capybara capybara, long l) { + if (capybara.canFallToSleep()) { + capybara.startFallingToSleep(); + } else if (capybara.canWakeUp()) { + capybara.startWakingUp(); + } + } + } + + static class Fart extends Behavior { + private final int lastPoseTickDelta; + + Fart(int lastPoseSecondsDelta) { + super(Map.of( + MemoryModuleType.IS_PANICKING, MemoryStatus.VALUE_ABSENT, + MemoryModuleType.IS_TEMPTED, MemoryStatus.VALUE_ABSENT, + MemoryModuleType.IS_IN_WATER, MemoryStatus.VALUE_ABSENT, + PromenadeMemoryModuleTypes.FART_COOLDOWN, MemoryStatus.VALUE_ABSENT, + MemoryModuleType.BREED_TARGET, MemoryStatus.VALUE_ABSENT + )); + this.lastPoseTickDelta = lastPoseSecondsDelta * 20; + } + + @Override + protected boolean checkExtraStartConditions(ServerLevel serverLevel, Capybara capybara) { + return capybara.getLastStateTickDelta() >= this.lastPoseTickDelta && + !capybara.mayBeLeashed() && + capybara.onGround() && + !capybara.hasControllingPassenger(); + } + + @Override + protected void start(ServerLevel serverLevel, Capybara capybara, long l) { + capybara.fart(); + } + + @Override + protected boolean canStillUse(ServerLevel serverLevel, Capybara livingEntity, long l) { + return true; + } + } +} \ No newline at end of file diff --git a/src/main/java/fr/hugman/promenade/entity/CapybaraBrain.java b/src/main/java/fr/hugman/promenade/entity/CapybaraBrain.java deleted file mode 100644 index e7bd7fca..00000000 --- a/src/main/java/fr/hugman/promenade/entity/CapybaraBrain.java +++ /dev/null @@ -1,165 +0,0 @@ -package fr.hugman.promenade.entity; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.mojang.datafixers.util.Pair; -import fr.hugman.promenade.entity.ai.brain.PromenadeMemoryModuleTypes; -import fr.hugman.promenade.entity.ai.brain.sensor.PromenadeSensorTypes; -import fr.hugman.promenade.tag.PromenadeItemTags; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.ai.brain.Activity; -import net.minecraft.entity.ai.brain.Brain; -import net.minecraft.entity.ai.brain.MemoryModuleState; -import net.minecraft.entity.ai.brain.MemoryModuleType; -import net.minecraft.entity.ai.brain.sensor.Sensor; -import net.minecraft.entity.ai.brain.sensor.SensorType; -import net.minecraft.entity.ai.brain.task.*; -import net.minecraft.item.ItemStack; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.util.math.intprovider.UniformIntProvider; - -import java.util.Map; -import java.util.function.Predicate; - -public class CapybaraBrain { - private static final UniformIntProvider WALK_TOWARD_ADULT_RANGE = UniformIntProvider.create(5, 16); - - private static final ImmutableList>> SENSORS = ImmutableList.of( - SensorType.NEAREST_LIVING_ENTITIES, - SensorType.HURT_BY, - PromenadeSensorTypes.CAPYBARA_TEMPTATIONS, - SensorType.NEAREST_ADULT, - SensorType.IS_IN_WATER - ); - - private static final ImmutableList> MEMORY_MODULES = ImmutableList.of( - MemoryModuleType.IS_PANICKING, - MemoryModuleType.HURT_BY, - MemoryModuleType.HURT_BY_ENTITY, - MemoryModuleType.WALK_TARGET, - MemoryModuleType.LOOK_TARGET, - MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE, - MemoryModuleType.PATH, - MemoryModuleType.VISIBLE_MOBS, - MemoryModuleType.TEMPTING_PLAYER, - MemoryModuleType.TEMPTATION_COOLDOWN_TICKS, - MemoryModuleType.GAZE_COOLDOWN_TICKS, - MemoryModuleType.IS_TEMPTED, - MemoryModuleType.BREED_TARGET, - MemoryModuleType.NEAREST_VISIBLE_ADULT, - PromenadeMemoryModuleTypes.FART_COOLDOWN - ); - - public static Brain.Profile createProfile() { - return Brain.createProfile(MEMORY_MODULES, SENSORS); - } - - protected static Brain create(Brain brain) { - CapybaraBrain.addCoreActivities(brain); - CapybaraBrain.addIdleActivities(brain); - brain.setCoreActivities(ImmutableSet.of(Activity.CORE)); - brain.setDefaultActivity(Activity.IDLE); - brain.resetPossibleActivities(); - return brain; - } - - private static void addCoreActivities(Brain brain) { - brain.setTaskList(Activity.CORE, 0, ImmutableList.of( - new StayAboveWaterTask<>(0.8f), - new net.minecraft.entity.ai.brain.task.FleeTask<>(1.0F) { - protected void run(ServerWorld serverWorld, CapybaraEntity capybaraEntity, long l) { - capybaraEntity.forceDefaultState(); - super.run(serverWorld, capybaraEntity, l); - } - }, - new UpdateLookControlTask(45, 90), - new MoveToTargetTask(), - new TickCooldownTask(MemoryModuleType.TEMPTATION_COOLDOWN_TICKS), - new TickCooldownTask(MemoryModuleType.GAZE_COOLDOWN_TICKS))); - } - - private static void addIdleActivities(Brain brain) { - brain.setTaskList(Activity.IDLE, ImmutableList.of( - Pair.of(0, LookAtMobWithIntervalTask.follow(EntityType.PLAYER, 6.0f, UniformIntProvider.create(30, 60))), - Pair.of(1, new BreedTask(PromenadeEntityTypes.CAPYBARA)), - Pair.of(2, new TemptTask(entity -> 1.5f)), - Pair.of(3, TaskTriggerer.runIf(Predicate.not(CapybaraEntity::isStationary), WalkTowardsEntityTask.createNearestVisibleAdult(WALK_TOWARD_ADULT_RANGE, 1.5f))), - Pair.of(4, new LookAroundTask(UniformIntProvider.create(150, 250), 30.0f, 0.0f, 10.0f)), - Pair.of(5, new RandomTask<>(ImmutableMap.of(MemoryModuleType.WALK_TARGET, MemoryModuleState.VALUE_ABSENT), ImmutableList.of( - Pair.of(TaskTriggerer.runIf(Predicate.not(CapybaraEntity::isStationary), StrollTask.create(1.0f)), 1), - Pair.of(TaskTriggerer.runIf(Predicate.not(CapybaraEntity::isStationary), GoToLookTargetTask.create(1.0f, 3)), 1), - Pair.of(new SleepOrWakeUpTask(20), 1), - Pair.of(new FartTask(10), 1), - Pair.of(new WaitTask(30, 60), 1) - ))))); - } - - public static void updateActivities(CapybaraEntity capybara) { - capybara.getBrain().resetPossibleActivities(ImmutableList.of(Activity.IDLE)); - } - - public static Predicate getTemptItemPredicate() { - return (stack) -> stack.isIn(PromenadeItemTags.CAPYBARA_FOOD); - } - - public static class SleepOrWakeUpTask extends MultiTickTask { - private final int lastPoseTickDelta; - - public SleepOrWakeUpTask(int lastPoseSecondsDelta) { - super(ImmutableMap.of( - MemoryModuleType.IS_PANICKING, MemoryModuleState.VALUE_ABSENT, - MemoryModuleType.IS_TEMPTED, MemoryModuleState.VALUE_ABSENT, - MemoryModuleType.IS_IN_WATER, MemoryModuleState.VALUE_ABSENT, - MemoryModuleType.BREED_TARGET, MemoryModuleState.VALUE_ABSENT)); - this.lastPoseTickDelta = lastPoseSecondsDelta * 20; - } - - @Override - protected boolean shouldRun(ServerWorld world, CapybaraEntity capybara) { - return capybara.getLastStateTickDelta() >= this.lastPoseTickDelta && - !capybara.isLeashed() && - capybara.isOnGround() && - !capybara.hasControllingPassenger(); - } - - @Override - protected void run(ServerWorld world, CapybaraEntity capybara, long l) { - if (capybara.canFallToSleep()) { - capybara.startFallingToSleep(); - } else if (capybara.canWakeUp()) { - capybara.startWakingUp(); - } - } - } - - static class FartTask extends MultiTickTask { - private final int lastPoseTickDelta; - - FartTask(int lastPoseSecondsDelta) { - super(Map.of( - MemoryModuleType.IS_PANICKING, MemoryModuleState.VALUE_ABSENT, - MemoryModuleType.IS_TEMPTED, MemoryModuleState.VALUE_ABSENT, - MemoryModuleType.IS_IN_WATER, MemoryModuleState.VALUE_ABSENT, - PromenadeMemoryModuleTypes.FART_COOLDOWN, MemoryModuleState.VALUE_ABSENT, - MemoryModuleType.BREED_TARGET, MemoryModuleState.VALUE_ABSENT - )); - this.lastPoseTickDelta = lastPoseSecondsDelta * 20; - } - - protected boolean shouldRun(ServerWorld serverWorld, CapybaraEntity capybara) { - return capybara.getLastStateTickDelta() >= this.lastPoseTickDelta && - !capybara.mightBeLeashed() && - capybara.isOnGround() && - !capybara.hasControllingPassenger(); - } - - protected boolean shouldKeepRunning(ServerWorld serverWorld, CapybaraEntity capybara, long l) { - return true; - } - - protected void run(ServerWorld serverWorld, CapybaraEntity capybara, long l) { - capybara.fart(); - } - } -} \ No newline at end of file diff --git a/src/main/java/fr/hugman/promenade/entity/Duck.java b/src/main/java/fr/hugman/promenade/entity/Duck.java new file mode 100644 index 00000000..0ed45a6a --- /dev/null +++ b/src/main/java/fr/hugman/promenade/entity/Duck.java @@ -0,0 +1,231 @@ +package fr.hugman.promenade.entity; + +import fr.hugman.promenade.component.PromenadeComponentTypes; +import fr.hugman.promenade.entity.data.PromenadeTrackedData; +import fr.hugman.promenade.entity.variant.DuckVariant; +import fr.hugman.promenade.entity.variant.DuckVariants; +import fr.hugman.promenade.registry.PromenadeRegistryKeys; +import fr.hugman.promenade.sound.PromenadeSoundEvents; +import fr.hugman.promenade.tag.PromenadeItemTags; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Holder; +import net.minecraft.core.component.DataComponentGetter; +import net.minecraft.core.component.DataComponentType; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.sounds.SoundEvent; +import net.minecraft.util.Mth; +import net.minecraft.world.DifficultyInstance; +import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.entity.AgeableMob; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityDimensions; +import net.minecraft.world.entity.EntitySpawnReason; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.Pose; +import net.minecraft.world.entity.SpawnGroupData; +import net.minecraft.world.entity.ai.attributes.AttributeSupplier.Builder; +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.FollowParentGoal; +import net.minecraft.world.entity.ai.goal.LookAtPlayerGoal; +import net.minecraft.world.entity.ai.goal.PanicGoal; +import net.minecraft.world.entity.ai.goal.RandomLookAroundGoal; +import net.minecraft.world.entity.ai.goal.RandomSwimmingGoal; +import net.minecraft.world.entity.ai.goal.TemptGoal; +import net.minecraft.world.entity.ai.goal.WaterAvoidingRandomStrollGoal; +import net.minecraft.world.entity.animal.Animal; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.entity.variant.SpawnContext; +import net.minecraft.world.entity.variant.VariantUtils; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.ServerLevelAccessor; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.pathfinder.PathType; +import net.minecraft.world.level.storage.ValueInput; +import net.minecraft.world.level.storage.ValueOutput; +import net.minecraft.world.phys.Vec3; +import org.jetbrains.annotations.Nullable; + +public class Duck extends Animal { + private static final EntityDimensions BABY_DIMENSIONS = EntityDimensions.scalable(4 / 16f, 5 / 16f).withEyeHeight(3.5f / 16f); + + private static final EntityDataAccessor> VARIANT = SynchedEntityData.defineId(Duck.class, PromenadeTrackedData.DUCK_VARIANT); + + public float flapProgress; + public float maxWingDeviation; + public float prevMaxWingDeviation; + public float prevFlapProgress; + public float wingRotDelta = 1.0F; + + public Duck(EntityType type, Level worldIn) { + super(type, worldIn); + this.setPathfindingMalus(PathType.WATER, 0.0F); + } + + @Override + public SpawnGroupData finalizeSpawn(ServerLevelAccessor world, DifficultyInstance difficulty, EntitySpawnReason spawnReason, @org.jetbrains.annotations.Nullable SpawnGroupData entityData) { + DuckVariants.select(this.random, this.registryAccess(), SpawnContext.create(world, this.blockPosition())).ifPresent(this::setVariant); + return super.finalizeSpawn(world, difficulty, spawnReason, entityData); + } + + @Override + protected EntityDimensions getDefaultDimensions(Pose pose) { + return this.isBaby() ? BABY_DIMENSIONS : super.getDefaultDimensions(pose); + } + + @Override + protected void positionRider(Entity passenger, Entity.MoveFunction positionUpdater) { + super.positionRider(passenger, positionUpdater); + if (passenger instanceof LivingEntity) { + ((LivingEntity) passenger).yBodyRot = this.yBodyRot; + } + } + + /*========*/ + /* AI */ + /*========*/ + + public static Builder createDuckAttributes() { + return createAnimalAttributes() + .add(Attributes.MAX_HEALTH, 4.0D) + .add(Attributes.MOVEMENT_SPEED, 0.25D); + } + + @Override + protected void registerGoals() { + this.goalSelector.addGoal(0, new FloatGoal(this)); + this.goalSelector.addGoal(1, new PanicGoal(this, 1.4D)); + this.goalSelector.addGoal(2, new BreedGoal(this, 1.0D)); + this.goalSelector.addGoal(3, new TemptGoal(this, 1.0, (stack) -> stack.is(PromenadeItemTags.DUCK_FOOD), false)); + this.goalSelector.addGoal(4, new FollowParentGoal(this, 1.1D)); + this.goalSelector.addGoal(5, new RandomSwimmingGoal(this, 1.0, 10)); + this.goalSelector.addGoal(6, new WaterAvoidingRandomStrollGoal(this, 1.0D)); + this.goalSelector.addGoal(7, new LookAtPlayerGoal(this, Player.class, 6.0F)); + this.goalSelector.addGoal(8, new RandomLookAroundGoal(this)); + } + + @Override + public void aiStep() { + super.aiStep(); + boolean isAirBorne = !this.onGround() && !this.isInWater(); + this.prevFlapProgress = this.flapProgress; + this.prevMaxWingDeviation = this.maxWingDeviation; + this.maxWingDeviation = (float) ((double) this.maxWingDeviation + (double) (!isAirBorne ? -1 : 4) * 0.3D); + this.maxWingDeviation = Mth.clamp(this.maxWingDeviation, 0.0F, 1.0F); + if (isAirBorne && this.wingRotDelta < 0.55F) { + this.wingRotDelta = 0.55F; + } + this.wingRotDelta = (float) ((double) this.wingRotDelta * 0.9D); + Vec3 vec3d = this.getDeltaMovement(); + if (isAirBorne && vec3d.y < 0.0D) { + this.setDeltaMovement(vec3d.multiply(1.0D, 0.75D, 1.0D)); + } + this.flapProgress += this.wingRotDelta * 2.0F; + } + + @Override + public boolean isFood(ItemStack stack) { + return stack.is(PromenadeItemTags.DUCK_FOOD); + } + + @Override + protected float getWaterSlowDown() { + return 0.98f; + } + + /*============*/ + /* SOUNDS */ + /*============*/ + + @Override + protected SoundEvent getAmbientSound() { + return PromenadeSoundEvents.DUCK_AMBIENT; + } + + @Override + protected SoundEvent getHurtSound(DamageSource source) { + return PromenadeSoundEvents.DUCK_HURT; + } + + @Override + protected SoundEvent getDeathSound() { + return PromenadeSoundEvents.DUCK_DEATH; + } + + @Override + protected void playStepSound(BlockPos pos, BlockState state) { + this.playSound(PromenadeSoundEvents.DUCK_STEP, 0.15F, 1.0F); + } + + /*==============*/ + /* VARIANTS */ + /*==============*/ + + @Nullable + @Override + public Duck getBreedOffspring(ServerLevel serverWorld, AgeableMob entity) { + Duck child = PromenadeEntityTypes.DUCK.create(this.level(), EntitySpawnReason.BREEDING); + if (child != null && entity instanceof Duck mama) { + child.setVariant(this.random.nextFloat() < 0.5f ? mama.getVariant() : this.getVariant()); + } + return child; + } + + public Holder getVariant() { + return this.entityData.get(VARIANT); + } + + public void setVariant(Holder registryEntry) { + this.entityData.set(VARIANT, registryEntry); + } + + /*==========*/ + /* DATA */ + /*==========*/ + + @Override + protected void defineSynchedData(SynchedEntityData.Builder builder) { + super.defineSynchedData(builder); + builder.define(VARIANT, VariantUtils.getDefaultOrAny(this.registryAccess(), DuckVariants.DEFAULT)); + } + + @Override + protected void addAdditionalSaveData(ValueOutput view) { + super.addAdditionalSaveData(view); + VariantUtils.writeVariant(view, this.getVariant()); + } + + @Override + protected void readAdditionalSaveData(ValueInput view) { + super.readAdditionalSaveData(view); + VariantUtils.readVariant(view, PromenadeRegistryKeys.DUCK_VARIANT).ifPresent(this::setVariant); + } + + @Nullable + @Override + public T get(DataComponentType type) { + return type == PromenadeComponentTypes.DUCK_VARIANT ? castComponentValue((DataComponentType) type, this.getVariant()) : super.get(type); + } + + @Override + protected void applyImplicitComponents(DataComponentGetter from) { + this.applyImplicitComponentIfPresent(from, PromenadeComponentTypes.DUCK_VARIANT); + super.applyImplicitComponents(from); + } + + @Override + protected boolean applyImplicitComponent(DataComponentType type, T value) { + if (type == PromenadeComponentTypes.DUCK_VARIANT) { + this.setVariant(castComponentValue(PromenadeComponentTypes.DUCK_VARIANT, value)); + return true; + } else { + return super.applyImplicitComponent(type, value); + } + } + +} \ No newline at end of file diff --git a/src/main/java/fr/hugman/promenade/entity/DuckEntity.java b/src/main/java/fr/hugman/promenade/entity/DuckEntity.java deleted file mode 100644 index a0047209..00000000 --- a/src/main/java/fr/hugman/promenade/entity/DuckEntity.java +++ /dev/null @@ -1,216 +0,0 @@ -package fr.hugman.promenade.entity; - -import fr.hugman.promenade.component.PromenadeComponentTypes; -import fr.hugman.promenade.entity.data.PromenadeTrackedData; -import fr.hugman.promenade.entity.variant.DuckVariant; -import fr.hugman.promenade.entity.variant.DuckVariants; -import fr.hugman.promenade.registry.PromenadeRegistryKeys; -import fr.hugman.promenade.sound.PromenadeSoundEvents; -import fr.hugman.promenade.tag.PromenadeItemTags; -import net.minecraft.block.BlockState; -import net.minecraft.component.ComponentType; -import net.minecraft.component.ComponentsAccess; -import net.minecraft.entity.*; -import net.minecraft.entity.ai.goal.*; -import net.minecraft.entity.ai.pathing.PathNodeType; -import net.minecraft.entity.attribute.DefaultAttributeContainer.Builder; -import net.minecraft.entity.attribute.EntityAttributes; -import net.minecraft.entity.damage.DamageSource; -import net.minecraft.entity.data.DataTracker; -import net.minecraft.entity.data.TrackedData; -import net.minecraft.entity.passive.AnimalEntity; -import net.minecraft.entity.passive.PassiveEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.spawn.SpawnContext; -import net.minecraft.item.ItemStack; -import net.minecraft.registry.entry.RegistryEntry; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.sound.SoundEvent; -import net.minecraft.storage.ReadView; -import net.minecraft.storage.WriteView; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.Vec3d; -import net.minecraft.world.LocalDifficulty; -import net.minecraft.world.ServerWorldAccess; -import net.minecraft.world.World; -import org.jetbrains.annotations.Nullable; - -public class DuckEntity extends AnimalEntity { - private static final EntityDimensions BABY_BASE_DIMENSIONS = EntityDimensions.changing(0.4F, 0.8F).scaled(0.5F).withEyeHeight(0.78125F); - - private static final TrackedData> VARIANT = DataTracker.registerData(DuckEntity.class, PromenadeTrackedData.DUCK_VARIANT); - - public float flapProgress; - public float maxWingDeviation; - public float prevMaxWingDeviation; - public float prevFlapProgress; - public float wingRotDelta = 1.0F; - - public DuckEntity(EntityType type, World worldIn) { - super(type, worldIn); - this.setPathfindingPenalty(PathNodeType.WATER, 0.0F); - } - - @Override - public EntityData initialize(ServerWorldAccess world, LocalDifficulty difficulty, SpawnReason spawnReason, @org.jetbrains.annotations.Nullable EntityData entityData) { - DuckVariants.select(this.random, this.getRegistryManager(), SpawnContext.of(world, this.getBlockPos())).ifPresent(this::setVariant); - return super.initialize(world, difficulty, spawnReason, entityData); - } - - @Override - protected EntityDimensions getBaseDimensions(EntityPose pose) { - return this.isBaby() ? BABY_BASE_DIMENSIONS : super.getBaseDimensions(pose); - } - - @Override - protected void updatePassengerPosition(Entity passenger, Entity.PositionUpdater positionUpdater) { - super.updatePassengerPosition(passenger, positionUpdater); - if (passenger instanceof LivingEntity) { - ((LivingEntity) passenger).bodyYaw = this.bodyYaw; - } - } - - /*========*/ - /* AI */ - /*========*/ - - public static Builder createDuckAttributes() { - return createAnimalAttributes() - .add(EntityAttributes.MAX_HEALTH, 4.0D) - .add(EntityAttributes.MOVEMENT_SPEED, 0.25D); - } - - @Override - protected void initGoals() { - this.goalSelector.add(0, new SwimGoal(this)); - this.goalSelector.add(1, new EscapeDangerGoal(this, 1.4D)); - this.goalSelector.add(2, new AnimalMateGoal(this, 1.0D)); - this.goalSelector.add(3, new TemptGoal(this, 1.0, (stack) -> stack.isIn(PromenadeItemTags.DUCK_FOOD), false)); - this.goalSelector.add(4, new FollowParentGoal(this, 1.1D)); - this.goalSelector.add(5, new SwimAroundGoal(this, 1.0, 10)); - this.goalSelector.add(6, new WanderAroundFarGoal(this, 1.0D)); - this.goalSelector.add(7, new LookAtEntityGoal(this, PlayerEntity.class, 6.0F)); - this.goalSelector.add(8, new LookAroundGoal(this)); - } - - @Override - public void tickMovement() { - super.tickMovement(); - boolean isAirBorne = !this.isOnGround() && !this.isTouchingWater(); - this.prevFlapProgress = this.flapProgress; - this.prevMaxWingDeviation = this.maxWingDeviation; - this.maxWingDeviation = (float) ((double) this.maxWingDeviation + (double) (!isAirBorne ? -1 : 4) * 0.3D); - this.maxWingDeviation = MathHelper.clamp(this.maxWingDeviation, 0.0F, 1.0F); - if (isAirBorne && this.wingRotDelta < 0.55F) { - this.wingRotDelta = 0.55F; - } - this.wingRotDelta = (float) ((double) this.wingRotDelta * 0.9D); - Vec3d vec3d = this.getVelocity(); - if (isAirBorne && vec3d.y < 0.0D) { - this.setVelocity(vec3d.multiply(1.0D, 0.75D, 1.0D)); - } - this.flapProgress += this.wingRotDelta * 2.0F; - } - - @Override - public boolean isBreedingItem(ItemStack stack) { - return stack.isIn(PromenadeItemTags.DUCK_FOOD); - } - - @Override - protected float getBaseWaterMovementSpeedMultiplier() { - return 0.9f; - } - - /*============*/ - /* SOUNDS */ - /*============*/ - - @Override - protected SoundEvent getAmbientSound() { - return PromenadeSoundEvents.DUCK_AMBIENT; - } - - @Override - protected SoundEvent getHurtSound(DamageSource source) { - return PromenadeSoundEvents.DUCK_HURT; - } - - @Override - protected SoundEvent getDeathSound() { - return PromenadeSoundEvents.DUCK_DEATH; - } - - @Override - protected void playStepSound(BlockPos pos, BlockState state) { - this.playSound(PromenadeSoundEvents.DUCK_STEP, 0.15F, 1.0F); - } - - /*==============*/ - /* VARIANTS */ - /*==============*/ - - @Nullable - @Override - public DuckEntity createChild(ServerWorld serverWorld, PassiveEntity entity) { - DuckEntity child = PromenadeEntityTypes.DUCK.create(this.getEntityWorld(), SpawnReason.BREEDING); - if (child != null && entity instanceof DuckEntity mama) { - child.setVariant(this.random.nextFloat() < 0.5f ? mama.getVariant() : this.getVariant()); - } - return child; - } - - public RegistryEntry getVariant() { - return this.dataTracker.get(VARIANT); - } - - public void setVariant(RegistryEntry registryEntry) { - this.dataTracker.set(VARIANT, registryEntry); - } - - /*==========*/ - /* DATA */ - /*==========*/ - - @Override - protected void initDataTracker(DataTracker.Builder builder) { - super.initDataTracker(builder); - builder.add(VARIANT, Variants.getOrDefaultOrThrow(this.getRegistryManager(), DuckVariants.DEFAULT)); - } - - @Override - protected void writeCustomData(WriteView view) { - super.writeCustomData(view); - Variants.writeData(view, this.getVariant()); - } - - @Override - protected void readCustomData(ReadView view) { - super.readCustomData(view); - Variants.fromData(view, PromenadeRegistryKeys.DUCK_VARIANT).ifPresent(this::setVariant); - } - - @Nullable - @Override - public T get(ComponentType type) { - return type == PromenadeComponentTypes.DUCK_VARIANT ? castComponentValue((ComponentType) type, this.getVariant()) : super.get(type); - } - - @Override - protected void copyComponentsFrom(ComponentsAccess from) { - this.copyComponentFrom(from, PromenadeComponentTypes.DUCK_VARIANT); - super.copyComponentsFrom(from); - } - - @Override - protected boolean setApplicableComponent(ComponentType type, T value) { - if (type == PromenadeComponentTypes.DUCK_VARIANT) { - this.setVariant(castComponentValue(PromenadeComponentTypes.DUCK_VARIANT, value)); - return true; - } else { - return super.setApplicableComponent(type, value); - } - } - -} \ No newline at end of file diff --git a/src/main/java/fr/hugman/promenade/entity/LushCreeper.java b/src/main/java/fr/hugman/promenade/entity/LushCreeper.java new file mode 100644 index 00000000..544d3064 --- /dev/null +++ b/src/main/java/fr/hugman/promenade/entity/LushCreeper.java @@ -0,0 +1,85 @@ +package fr.hugman.promenade.entity; + +import java.util.Collection; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Registry; +import net.minecraft.core.registries.Registries; +import net.minecraft.data.worldgen.features.CaveFeatures; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.util.RandomSource; +import net.minecraft.world.effect.MobEffectInstance; +import net.minecraft.world.entity.AreaEffectCloud; +import net.minecraft.world.entity.EntitySpawnReason; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.monster.Creeper; +import net.minecraft.world.entity.monster.Monster; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.ServerLevelAccessor; +import net.minecraft.world.level.gamerules.GameRules; +import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; + +public class LushCreeper extends Creeper { + private static final int EXPLOSION_Y_LENGTH = 10; + + public LushCreeper(EntityType entityType, Level world) { + super(entityType, world); + } + + public static boolean canSpawn(EntityType type, ServerLevelAccessor world, EntitySpawnReason spawnReason, BlockPos pos, RandomSource random) { + return pos.getY() < 0 && Monster.checkMonsterSpawnRules(type, world, spawnReason, pos, random); + } + + @Override + protected void explodeCreeper() { + if (this.level() instanceof ServerLevel serverWorld) { + boolean hasGeneratedMoss = false; + if (serverWorld.getGameRules().get(GameRules.MOB_GRIEFING)) { + Registry> registry = serverWorld.registryAccess().lookupOrThrow(Registries.CONFIGURED_FEATURE); + for (int i = 0; i < EXPLOSION_Y_LENGTH; i++) { + BlockPos pos = blockPosition().below(i); + if (this.level().getBlockState(pos).isRedstoneConductor(this.level(), pos)) { + if (registry.getValue(this.level().getRandom().nextBoolean() ? CaveFeatures.MOSS_PATCH : CaveFeatures.CLAY_POOL_WITH_DRIPLEAVES).place(serverWorld, serverWorld.getChunkSource().getGenerator(), random, pos.above())) { + hasGeneratedMoss = true; + } + break; + } + } + for (int i = 0; i < EXPLOSION_Y_LENGTH; i++) { + BlockPos pos = blockPosition().above(i); + if (this.level().getBlockState(pos).isRedstoneConductor(this.level(), pos)) { + if (registry.getValue(CaveFeatures.MOSS_PATCH_CEILING).place(serverWorld, serverWorld.getChunkSource().getGenerator(), random, pos.below())) { + hasGeneratedMoss = true; + } + break; + } + } + } + if (hasGeneratedMoss) { + this.dead = true; + float f = this.isPowered() ? 2.0F : 1.0F; + this.level().explode(this, this.getX(), this.getY(), this.getZ(), f, Level.ExplosionInteraction.MOB); + this.discard(); + this.spawnLingeringCloud(); + } else { + super.explodeCreeper(); + } + } + } + + private void spawnLingeringCloud() { + Collection statusEffects = this.getActiveEffects(); + if (!statusEffects.isEmpty()) { + AreaEffectCloud aec = new AreaEffectCloud(this.level(), this.getX(), this.getY(), this.getZ()); + aec.setRadius(2.5F); + aec.setRadiusOnUse(-0.5F); + aec.setWaitTime(10); + aec.setDuration(aec.getDuration() / 2); + aec.setRadiusPerTick(-aec.getRadius() / (float) aec.getDuration()); + + for (MobEffectInstance statusEffectInstance : statusEffects) { + aec.addEffect(new MobEffectInstance(statusEffectInstance)); + } + this.level().addFreshEntity(aec); + } + } +} \ No newline at end of file diff --git a/src/main/java/fr/hugman/promenade/entity/LushCreeperEntity.java b/src/main/java/fr/hugman/promenade/entity/LushCreeperEntity.java deleted file mode 100644 index 285f550a..00000000 --- a/src/main/java/fr/hugman/promenade/entity/LushCreeperEntity.java +++ /dev/null @@ -1,86 +0,0 @@ -package fr.hugman.promenade.entity; - -import net.minecraft.entity.AreaEffectCloudEntity; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.SpawnReason; -import net.minecraft.entity.effect.StatusEffectInstance; -import net.minecraft.entity.mob.CreeperEntity; -import net.minecraft.entity.mob.HostileEntity; -import net.minecraft.registry.Registry; -import net.minecraft.registry.RegistryKeys; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.random.Random; -import net.minecraft.world.ServerWorldAccess; -import net.minecraft.world.World; -import net.minecraft.world.gen.feature.ConfiguredFeature; -import net.minecraft.world.gen.feature.UndergroundConfiguredFeatures; -import net.minecraft.world.rule.GameRules; - -import java.util.Collection; - -public class LushCreeperEntity extends CreeperEntity { - private static final int EXPLOSION_Y_LENGTH = 10; - - public LushCreeperEntity(EntityType entityType, World world) { - super(entityType, world); - } - - public static boolean canSpawn(EntityType type, ServerWorldAccess world, SpawnReason spawnReason, BlockPos pos, Random random) { - return pos.getY() < 0 && HostileEntity.canSpawnInDark(type, world, spawnReason, pos, random); - } - - @Override - protected void explode() { - if (this.getEntityWorld() instanceof ServerWorld serverWorld) { - boolean hasGeneratedMoss = false; - if (serverWorld.getGameRules().getValue(GameRules.DO_MOB_GRIEFING)) { - Registry> registry = serverWorld.getRegistryManager().getOrThrow(RegistryKeys.CONFIGURED_FEATURE); - for (int i = 0; i < EXPLOSION_Y_LENGTH; i++) { - BlockPos pos = getBlockPos().down(i); - if (this.getEntityWorld().getBlockState(pos).isSolidBlock(this.getEntityWorld(), pos)) { - if (registry.get(this.getEntityWorld().getRandom().nextBoolean() ? UndergroundConfiguredFeatures.MOSS_PATCH : UndergroundConfiguredFeatures.CLAY_POOL_WITH_DRIPLEAVES).generate(serverWorld, serverWorld.getChunkManager().getChunkGenerator(), random, pos.up())) { - hasGeneratedMoss = true; - } - break; - } - } - for (int i = 0; i < EXPLOSION_Y_LENGTH; i++) { - BlockPos pos = getBlockPos().up(i); - if (this.getEntityWorld().getBlockState(pos).isSolidBlock(this.getEntityWorld(), pos)) { - if (registry.get(UndergroundConfiguredFeatures.MOSS_PATCH_CEILING).generate(serverWorld, serverWorld.getChunkManager().getChunkGenerator(), random, pos.down())) { - hasGeneratedMoss = true; - } - break; - } - } - } - if (hasGeneratedMoss) { - this.dead = true; - float f = this.isCharged() ? 2.0F : 1.0F; - this.getEntityWorld().createExplosion(this, this.getX(), this.getY(), this.getZ(), f, World.ExplosionSourceType.MOB); - this.discard(); - this.spawnEffectsCloud(); - } else { - super.explode(); - } - } - } - - private void spawnEffectsCloud() { - Collection statusEffects = this.getStatusEffects(); - if (!statusEffects.isEmpty()) { - AreaEffectCloudEntity aec = new AreaEffectCloudEntity(this.getEntityWorld(), this.getX(), this.getY(), this.getZ()); - aec.setRadius(2.5F); - aec.setRadiusOnUse(-0.5F); - aec.setWaitTime(10); - aec.setDuration(aec.getDuration() / 2); - aec.setRadiusGrowth(-aec.getRadius() / (float) aec.getDuration()); - - for (StatusEffectInstance statusEffectInstance : statusEffects) { - aec.addEffect(new StatusEffectInstance(statusEffectInstance)); - } - this.getEntityWorld().spawnEntity(aec); - } - } -} \ No newline at end of file diff --git a/src/main/java/fr/hugman/promenade/entity/PromenadeEntityTypes.java b/src/main/java/fr/hugman/promenade/entity/PromenadeEntityTypes.java index ff589742..53946862 100644 --- a/src/main/java/fr/hugman/promenade/entity/PromenadeEntityTypes.java +++ b/src/main/java/fr/hugman/promenade/entity/PromenadeEntityTypes.java @@ -9,65 +9,64 @@ import net.fabricmc.fabric.api.biome.v1.BiomeSelectionContext; import net.fabricmc.fabric.api.biome.v1.BiomeSelectors; import net.fabricmc.fabric.api.object.builder.v1.entity.FabricEntityType; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.SpawnGroup; -import net.minecraft.entity.SpawnLocationTypes; -import net.minecraft.entity.passive.AnimalEntity; -import net.minecraft.entity.vehicle.BoatEntity; -import net.minecraft.entity.vehicle.ChestBoatEntity; -import net.minecraft.registry.Registries; -import net.minecraft.registry.Registry; -import net.minecraft.registry.RegistryKey; -import net.minecraft.registry.RegistryKeys; -import net.minecraft.world.Heightmap; -import net.minecraft.world.biome.BiomeKeys; - +import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.MobCategory; +import net.minecraft.world.entity.SpawnPlacementTypes; +import net.minecraft.world.entity.animal.Animal; +import net.minecraft.world.entity.vehicle.boat.Boat; +import net.minecraft.world.entity.vehicle.boat.ChestBoat; +import net.minecraft.world.level.biome.Biomes; +import net.minecraft.world.level.levelgen.Heightmap; import java.util.function.Predicate; public class PromenadeEntityTypes { - public static final EntityType SAKURA_BOAT = register("sakura_boat", EntityTypeFactory.boat(() -> PromenadeItems.SAKURA_BOAT)); - public static final EntityType SAKURA_CHEST_BOAT = register("sakura_chest_boat", EntityTypeFactory.chestBoat(() -> PromenadeItems.SAKURA_CHEST_BOAT)); + public static final EntityType SAKURA_BOAT = register("sakura_boat", EntityTypeFactory.boat(() -> PromenadeItems.SAKURA_BOAT)); + public static final EntityType SAKURA_CHEST_BOAT = register("sakura_chest_boat", EntityTypeFactory.chestBoat(() -> PromenadeItems.SAKURA_CHEST_BOAT)); - public static final EntityType MAPLE_BOAT = register("maple_boat", EntityTypeFactory.boat(() -> PromenadeItems.MAPLE_BOAT)); - public static final EntityType MAPLE_CHEST_BOAT = register("maple_chest_boat", EntityTypeFactory.chestBoat(() -> PromenadeItems.MAPLE_CHEST_BOAT)); + public static final EntityType MAPLE_BOAT = register("maple_boat", EntityTypeFactory.boat(() -> PromenadeItems.MAPLE_BOAT)); + public static final EntityType MAPLE_CHEST_BOAT = register("maple_chest_boat", EntityTypeFactory.chestBoat(() -> PromenadeItems.MAPLE_CHEST_BOAT)); - public static final EntityType PALM_BOAT = register("palm_boat", EntityTypeFactory.boat(() -> PromenadeItems.PALM_BOAT)); - public static final EntityType PALM_CHEST_BOAT = register("palm_chest_boat", EntityTypeFactory.chestBoat(() -> PromenadeItems.PALM_CHEST_BOAT)); + public static final EntityType PALM_BOAT = register("palm_boat", EntityTypeFactory.boat(() -> PromenadeItems.PALM_BOAT)); + public static final EntityType PALM_CHEST_BOAT = register("palm_chest_boat", EntityTypeFactory.chestBoat(() -> PromenadeItems.PALM_CHEST_BOAT)); - public static final EntityType CAPYBARA = register("capybara", FabricEntityType.Builder.createMob(CapybaraEntity::new, SpawnGroup.CREATURE, mob -> mob - .defaultAttributes(CapybaraEntity::createCapybaraAttributes) - .spawnRestriction(SpawnLocationTypes.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, AnimalEntity::isValidNaturalSpawn) + public static final EntityType CAPYBARA = register("capybara", FabricEntityType.Builder.createMob(Capybara::new, MobCategory.CREATURE, mob -> mob + .defaultAttributes(Capybara::createCapybaraAttributes) + .spawnPlacement(SpawnPlacementTypes.ON_GROUND, Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, Animal::checkAnimalSpawnRules) ) - .dimensions(0.7f, 0.875f) - .eyeHeight(0.875f)); - public static final EntityType DUCK = register("duck", FabricEntityType.Builder.createMob(DuckEntity::new, SpawnGroup.CREATURE, mob -> mob - .defaultAttributes(DuckEntity::createDuckAttributes) - .spawnRestriction(SpawnLocationTypes.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, AnimalEntity::isValidNaturalSpawn) + .sized(0.7f, 0.875f) + .eyeHeight(0.85f)); + public static final EntityType DUCK = register("duck", FabricEntityType.Builder.createMob(Duck::new, MobCategory.CREATURE, mob -> mob + .defaultAttributes(Duck::createDuckAttributes) + .spawnPlacement(SpawnPlacementTypes.ON_GROUND, Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, Animal::checkAnimalSpawnRules) ) - .dimensions(0.4F, 0.8F) - .eyeHeight(1.09375f) - .maxTrackingRange(10) - .trackingTickInterval(3)); - public static final EntityType LUSH_CREEPER = register("lush_creeper", FabricEntityType.Builder.createMob(LushCreeperEntity::new, SpawnGroup.MONSTER, mob -> mob - .defaultAttributes(LushCreeperEntity::createCreeperAttributes) - .spawnRestriction(SpawnLocationTypes.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, LushCreeperEntity::canSpawn) + .sized(8f /16, 10f /16) + .eyeHeight(9.75f /16) + .clientTrackingRange(10) + .updateInterval(3)); + public static final EntityType LUSH_CREEPER = register("lush_creeper", FabricEntityType.Builder.createMob(LushCreeper::new, MobCategory.MONSTER, mob -> mob + .defaultAttributes(LushCreeper::createAttributes) + .spawnPlacement(SpawnPlacementTypes.ON_GROUND, Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, LushCreeper::canSpawn) ) - .dimensions(0.6f, 1.7f) - .maxTrackingRange(8) - .notAllowedInPeaceful()); - public static final EntityType SUNKEN = register("sunken", FabricEntityType.Builder.createMob(SunkenEntity::new, SpawnGroup.MONSTER, mob -> mob - .defaultAttributes(SunkenEntity::createSunkenAttributes) - .spawnRestriction(SpawnLocationTypes.IN_WATER, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, SunkenEntity::canSpawn) + .sized(0.6f, 1.7f) + .clientTrackingRange(8) + .notInPeaceful()); + public static final EntityType SUNKEN = register("sunken", FabricEntityType.Builder.createMob(Sunken::new, MobCategory.MONSTER, mob -> mob + .defaultAttributes(Sunken::createSunkenAttributes) + .spawnPlacement(SpawnPlacementTypes.IN_WATER, Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, Sunken::canSpawn) ) - .dimensions(0.6F, 1.99F) + .sized(0.6F, 1.99F) .eyeHeight(1.74F) - .maxTrackingRange(8) - .notAllowedInPeaceful()); + .clientTrackingRange(8) + .notInPeaceful()); private static EntityType register(String path, EntityType.Builder type) { - var key = RegistryKey.of(RegistryKeys.ENTITY_TYPE, Promenade.id(path)); - return Registry.register(Registries.ENTITY_TYPE, key, type.build(key)); + var key = ResourceKey.create(Registries.ENTITY_TYPE, Promenade.id(path)); + return Registry.register(BuiltInRegistries.ENTITY_TYPE, key, type.build(key)); } public static void appendWorldGen() { @@ -77,23 +76,23 @@ public static void appendWorldGen() { .and(BiomeSelectors.spawnsOneOf(EntityType.SHEEP)) .and(BiomeSelectors.spawnsOneOf(EntityType.CHICKEN)) .and(BiomeSelectors.spawnsOneOf(EntityType.PIG)); - BiomeModifications.addSpawn(hasFarmAnimals, SpawnGroup.CREATURE, PromenadeEntityTypes.DUCK, duckWeight, 4, 4); + BiomeModifications.addSpawn(hasFarmAnimals, MobCategory.CREATURE, PromenadeEntityTypes.DUCK, duckWeight, 4, 4); } var capybaraWeight = PromenadeConfig.get().animals().capybarasWeight(); if (capybaraWeight != 0) { - BiomeModifications.addSpawn(BiomeSelectors.tag(PromenadeBiomeTags.SPAWNS_CAPYBARAS), SpawnGroup.CREATURE, PromenadeEntityTypes.CAPYBARA, capybaraWeight, 3, 5); + BiomeModifications.addSpawn(BiomeSelectors.tag(PromenadeBiomeTags.SPAWNS_CAPYBARAS), MobCategory.CREATURE, PromenadeEntityTypes.CAPYBARA, capybaraWeight, 3, 5); } var lushCreeperWeight = PromenadeConfig.get().monsters().lushCreepersWeight(); if (lushCreeperWeight != 0) { - BiomeModifications.addSpawn(BiomeSelectors.spawnsOneOf(EntityType.CREEPER).and(BiomeSelectors.excludeByKey(BiomeKeys.LUSH_CAVES)), SpawnGroup.MONSTER, LUSH_CREEPER, lushCreeperWeight, 2, 3); - BiomeModifications.addSpawn(BiomeSelectors.includeByKey(BiomeKeys.LUSH_CAVES), SpawnGroup.MONSTER, LUSH_CREEPER, lushCreeperWeight * 4, 2, 4); + BiomeModifications.addSpawn(BiomeSelectors.spawnsOneOf(EntityType.CREEPER).and(BiomeSelectors.excludeByKey(Biomes.LUSH_CAVES)), MobCategory.MONSTER, LUSH_CREEPER, lushCreeperWeight, 2, 3); + BiomeModifications.addSpawn(BiomeSelectors.includeByKey(Biomes.LUSH_CAVES), MobCategory.MONSTER, LUSH_CREEPER, lushCreeperWeight * 4, 2, 4); } var sunkensWeight = PromenadeConfig.get().monsters().sunkensWeight(); if (sunkensWeight != 0) { - BiomeModifications.addSpawn(biomeSelectionContext -> biomeSelectionContext.hasTag(PromenadeBiomeTags.SPAWNS_SUNKEN), SpawnGroup.MONSTER, SUNKEN, sunkensWeight, 1, 3); + BiomeModifications.addSpawn(biomeSelectionContext -> biomeSelectionContext.hasTag(PromenadeBiomeTags.SPAWNS_SUNKEN), MobCategory.MONSTER, SUNKEN, sunkensWeight, 1, 3); } } } diff --git a/src/main/java/fr/hugman/promenade/entity/Sunken.java b/src/main/java/fr/hugman/promenade/entity/Sunken.java new file mode 100644 index 00000000..47622914 --- /dev/null +++ b/src/main/java/fr/hugman/promenade/entity/Sunken.java @@ -0,0 +1,544 @@ +package fr.hugman.promenade.entity; + +import fr.hugman.promenade.component.PromenadeComponentTypes; +import fr.hugman.promenade.entity.data.PromenadeTrackedData; +import fr.hugman.promenade.entity.variant.SunkenVariant; +import fr.hugman.promenade.entity.variant.SunkenVariants; +import fr.hugman.promenade.registry.PromenadeRegistryKeys; +import fr.hugman.promenade.sound.PromenadeSoundEvents; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Holder; +import net.minecraft.core.component.DataComponentGetter; +import net.minecraft.core.component.DataComponentType; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.sounds.SoundEvent; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.tags.FluidTags; +import net.minecraft.util.Mth; +import net.minecraft.util.RandomSource; +import net.minecraft.world.*; +import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.effect.MobEffectInstance; +import net.minecraft.world.effect.MobEffects; +import net.minecraft.world.entity.EntityDimensions; +import net.minecraft.world.entity.EntitySpawnReason; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.MoverType; +import net.minecraft.world.entity.Pose; +import net.minecraft.world.entity.SpawnGroupData; +import net.minecraft.world.entity.ai.attributes.AttributeSupplier; +import net.minecraft.world.entity.ai.attributes.Attributes; +import net.minecraft.world.entity.ai.control.MoveControl; +import net.minecraft.world.entity.ai.goal.AvoidEntityGoal; +import net.minecraft.world.entity.ai.goal.FleeSunGoal; +import net.minecraft.world.entity.ai.goal.Goal; +import net.minecraft.world.entity.ai.goal.LookAtPlayerGoal; +import net.minecraft.world.entity.ai.goal.MeleeAttackGoal; +import net.minecraft.world.entity.ai.goal.MoveToBlockGoal; +import net.minecraft.world.entity.ai.goal.RandomLookAroundGoal; +import net.minecraft.world.entity.ai.goal.RandomSwimmingGoal; +import net.minecraft.world.entity.ai.goal.RangedBowAttackGoal; +import net.minecraft.world.entity.ai.goal.RangedCrossbowAttackGoal; +import net.minecraft.world.entity.ai.goal.RestrictSunGoal; +import net.minecraft.world.entity.ai.goal.TryFindWaterGoal; +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.ai.navigation.GroundPathNavigation; +import net.minecraft.world.entity.ai.navigation.WaterBoundPathNavigation; +import net.minecraft.world.entity.ai.util.DefaultRandomPos; +import net.minecraft.world.entity.animal.dolphin.Dolphin; +import net.minecraft.world.entity.animal.fish.Pufferfish; +import net.minecraft.world.entity.monster.CrossbowAttackMob; +import net.minecraft.world.entity.monster.skeleton.AbstractSkeleton; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.entity.projectile.ProjectileUtil; +import net.minecraft.world.entity.projectile.arrow.AbstractArrow; +import net.minecraft.world.entity.projectile.arrow.Arrow; +import net.minecraft.world.entity.variant.SpawnContext; +import net.minecraft.world.entity.variant.VariantUtils; +import net.minecraft.world.item.BowItem; +import net.minecraft.world.item.CrossbowItem; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.ServerLevelAccessor; +import net.minecraft.world.level.pathfinder.Path; +import net.minecraft.world.level.pathfinder.PathType; +import net.minecraft.world.level.storage.ValueInput; +import net.minecraft.world.level.storage.ValueOutput; +import net.minecraft.world.phys.Vec3; +import javax.annotation.Nullable; +import java.util.Optional; + +public class Sunken extends AbstractSkeleton implements CrossbowAttackMob { + private static final EntityDataAccessor> VARIANT = SynchedEntityData.defineId(Sunken.class, PromenadeTrackedData.SUNKEN_VARIANT); + private static final EntityDataAccessor CHARGING = SynchedEntityData.defineId(Sunken.class, EntityDataSerializers.BOOLEAN); + private static final EntityDataAccessor SWIMMING = SynchedEntityData.defineId(Sunken.class, EntityDataSerializers.BOOLEAN); + + private final static EntityDimensions SWIMMING_DIMENSIONS = EntityDimensions.fixed(0.6F, 0.6F); + + protected final WaterBoundPathNavigation waterNavigation; + protected final GroundPathNavigation landNavigation; + private final RangedCrossbowAttackGoal crossbowAttackGoal = new RangedCrossbowAttackGoal<>(this, 1.0D, 20.0F); + private final RangedBowAttackGoal bowAttackGoal = new RangedBowAttackGoal<>(this, 1.0D, 20, 15.0F); + private final MeleeAttackGoal meleeAttackGoal = new MeleeAttackGoal(this, 1.2D, false) { + public void stop() { + super.stop(); + Sunken.this.setAggressive(false); + } + + public void start() { + super.start(); + Sunken.this.setAggressive(true); + } + }; + boolean targetingUnderwater; + + public Sunken(EntityType entityType, Level world) { + super(entityType, world); + this.reassessWeaponGoal(); + this.moveControl = new SunkenMoveControl(this); + this.setPathfindingMalus(PathType.WATER, 0.0F); + this.waterNavigation = new WaterBoundPathNavigation(this, world); + this.landNavigation = new GroundPathNavigation(this, world); + } + + @Nullable + @Override + public SpawnGroupData finalizeSpawn(ServerLevelAccessor world, DifficultyInstance difficulty, EntitySpawnReason spawnReason, @Nullable SpawnGroupData entityData) { + SunkenVariants.select(this.random, this.registryAccess(), SpawnContext.create(world, this.blockPosition())).ifPresent(this::setVariant); + this.lootTable = Optional.ofNullable(this.getVariant().value().lootTable()); + return super.finalizeSpawn(world, difficulty, spawnReason, entityData); + } + + public static boolean canSpawn(EntityType ignoredType, ServerLevelAccessor world, EntitySpawnReason spawnReason, BlockPos pos, RandomSource random) { + boolean bl = world.getDifficulty() != Difficulty.PEACEFUL + && isDarkEnoughToSpawn(world, pos, random) + && (spawnReason == EntitySpawnReason.SPAWNER || world.getFluidState(pos).is(FluidTags.WATER)); + return pos.getY() < world.getSeaLevel() - 10 && bl; + } + + @Override + public boolean checkSpawnObstruction(LevelReader world) { + return world.isUnobstructed(this); + } + + @Override + public EntityDimensions getDefaultDimensions(Pose pose) { + if (this.isBreaststrokeSwimming()) return SWIMMING_DIMENSIONS; + else return super.getDefaultDimensions(pose); + } + + /*========*/ + /* AI */ + /*========*/ + + public static AttributeSupplier.Builder createSunkenAttributes() { + return createAttributes(); + } + + @Override + protected void registerGoals() { + this.goalSelector.addGoal(1, new TryFindWaterGoal(this)); + this.goalSelector.addGoal(1, new RestrictSunGoal(this)); + this.goalSelector.addGoal(2, new RangedCrossbowAttackGoal(this, 1.0D, 4.5F)); + this.goalSelector.addGoal(3, new AvoidEntityGoal(this, Pufferfish.class, 8.0F, 1.0D, 1.2D)); + this.goalSelector.addGoal(3, new FleeSunGoal(this, 1.0D)); + this.goalSelector.addGoal(6, new RandomSwimmingGoal(this, 1.0D, 40)); + this.goalSelector.addGoal(7, new WaterAvoidingRandomStrollGoal(this, 1.0D)); + this.goalSelector.addGoal(7, new Sunken.TargetAboveWaterGoal(this, 1.0D, this.level().getSeaLevel())); + this.goalSelector.addGoal(7, new Sunken.LeaveWaterGoal(this, 1.0D)); + this.goalSelector.addGoal(8, new LookAtPlayerGoal(this, Player.class, 8.0F)); + this.goalSelector.addGoal(8, new RandomLookAroundGoal(this)); + + this.targetSelector.addGoal(1, new HurtByTargetGoal(this)); + this.targetSelector.addGoal(2, new NearestAttackableTargetGoal(this, Player.class, true)); + this.targetSelector.addGoal(2, new NearestAttackableTargetGoal(this, Dolphin.class, true)); + } + + @Override + public void performRangedAttack(LivingEntity target, float pullProgress) { + if (this.isHolding(stack -> stack.getItem() instanceof CrossbowItem)) { + this.performCrossbowAttack(this, 1.6F); + } else { + ItemStack itemStack = this.getItemInHand(ProjectileUtil.getWeaponHoldingHand(this, Items.BOW)); + AbstractArrow persistentProjectileEntity = this.getArrow(this.getProjectile(itemStack), pullProgress, itemStack); + double d = target.getX() - this.getX(); + double e = target.getY(0.3333333333333333D) - persistentProjectileEntity.getY(); + double f = target.getZ() - this.getZ(); + double g = Math.sqrt(d * d + f * f); + persistentProjectileEntity.shoot(d, e + g * 0.20000000298023224D, f, 1.6F, (float) (14 - this.level().getDifficulty().getId() * 4)); + this.playSound(this.getShootSound(), 1.0F, 1.0F / (this.getRandom().nextFloat() * 0.4F + 0.8F)); + this.level().addFreshEntity(persistentProjectileEntity); + } + } + + @Override + public void performCrossbowAttack(LivingEntity entity, float speed) { + CrossbowAttackMob.super.performCrossbowAttack(entity, speed); + } + + @Override + protected AbstractArrow getArrow(ItemStack arrow, float damageModifier, @Nullable ItemStack shotFrom) { + AbstractArrow persistentProjectileEntity = super.getArrow(arrow, damageModifier, shotFrom); + if (persistentProjectileEntity instanceof Arrow) { + ((Arrow) persistentProjectileEntity).addEffect(new MobEffectInstance(MobEffects.SLOWNESS, 600)); + } + + return persistentProjectileEntity; + } + + @Override + protected void populateDefaultEquipmentSlots(RandomSource random, DifficultyInstance difficulty) { + super.populateDefaultEquipmentSlots(random, difficulty); + this.setItemSlot(EquipmentSlot.MAINHAND, new ItemStack(Items.CROSSBOW)); + } + + @Override + public boolean canUseNonMeleeWeapon(ItemStack stack) { + var weapon = stack.getItem(); + return weapon instanceof BowItem || weapon instanceof CrossbowItem; + } + + @Override + public void travel(Vec3 movementInput) { + if (this.canSimulateMovement() && this.isInWater()) { + float speed = 0.075F; + this.moveRelative(speed, movementInput); + this.move(MoverType.SELF, this.getDeltaMovement()); + this.setDeltaMovement(this.getDeltaMovement().scale(0.9D)); + } else { + super.travel(movementInput); + } + } + + @Override + public boolean isPushedByFluid() { + return !this.isSwimming(); + } + + @Override + public void updateSwimming() { + if (!this.level().isClientSide()) { + boolean b = this.level().isEmptyBlock(this.blockPosition().above(2)); + if (!b && this.canSimulateMovement() && this.isUnderWater()) { + this.navigation = this.waterNavigation; + this.setSwimming(true); + this.setBreaststrokeSwimming(true); + } else { + this.navigation = this.landNavigation; + this.setSwimming(false); + this.setBreaststrokeSwimming(false); + } + } + } + + @Override + public void reassessWeaponGoal() { + if (this.level() != null && !this.level().isClientSide()) { + if (this.bowAttackGoal != null && this.crossbowAttackGoal != null && this.meleeAttackGoal != null) { + this.goalSelector.removeGoal(this.bowAttackGoal); + this.goalSelector.removeGoal(this.crossbowAttackGoal); + this.goalSelector.removeGoal(this.meleeAttackGoal); + ItemStack itemStack = this.getItemInHand(ProjectileUtil.getWeaponHoldingHand(this, Items.CROSSBOW)); + if (itemStack.is(Items.CROSSBOW)) { + this.goalSelector.addGoal(4, this.crossbowAttackGoal); + } else if (itemStack.is(Items.BOW)) { + this.bowAttackGoal.setMinAttackInterval(this.level().getDifficulty() != Difficulty.HARD ? 40 : 20); + this.goalSelector.addGoal(4, this.bowAttackGoal); + } else { + this.goalSelector.addGoal(4, this.meleeAttackGoal); + } + } + } + } + + public boolean isCharging() { + return this.entityData.get(CHARGING); + } + + @Override + public void setChargingCrossbow(boolean charging) { + this.entityData.set(CHARGING, charging); + } + + public boolean isBreaststrokeSwimming() { + if (this.getDeltaMovement().length() < 0.1F) return false; + else return this.entityData.get(SWIMMING); + } + + public void setBreaststrokeSwimming(boolean breaststrokeSwimming) { + this.entityData.set(SWIMMING, breaststrokeSwimming); + } + + @Override + public boolean isVisuallySwimming() { + return isBreaststrokeSwimming(); + } + + @Override + public void onCrossbowAttackPerformed() { + this.noActionTime = 0; + } + + protected boolean hasFinishedCurrentPath() { + Path path = this.getNavigation().getPath(); + if (path != null) { + BlockPos blockPos = path.getTarget(); + if (blockPos != null) { + double d = this.distanceToSqr(blockPos.getX(), blockPos.getY(), blockPos.getZ()); + return d < 4.0D; + } + } + + return false; + } + + boolean isTargetingUnderwater() { + if (this.targetingUnderwater) { + return true; + } else { + LivingEntity livingEntity = this.getTarget(); + return livingEntity != null && livingEntity.isInWater(); + } + } + + public void setTargetingUnderwater(boolean targetingUnderwater) { + this.targetingUnderwater = targetingUnderwater; + } + + /*============*/ + /* SOUNDS */ + /*============*/ + + @Override + protected SoundEvent getAmbientSound() { + return this.isEyeInFluid(FluidTags.WATER) ? PromenadeSoundEvents.SUNKEN_AMBIENT : SoundEvents.SKELETON_AMBIENT; + } + + @Override + protected SoundEvent getHurtSound(DamageSource source) { + return this.isEyeInFluid(FluidTags.WATER) ? PromenadeSoundEvents.SUNKEN_HURT : SoundEvents.SKELETON_HURT; + } + + @Override + protected SoundEvent getDeathSound() { + return this.isEyeInFluid(FluidTags.WATER) ? PromenadeSoundEvents.SUNKEN_DEATH : SoundEvents.SKELETON_DEATH; + } + + @Override + protected SoundEvent getStepSound() { + return this.isEyeInFluid(FluidTags.WATER) ? PromenadeSoundEvents.SUNKEN_STEP : SoundEvents.SKELETON_STEP; + } + + protected SoundEvent getShootSound() { + return this.isEyeInFluid(FluidTags.WATER) ? PromenadeSoundEvents.SUNKEN_SHOOT : (this.isHolding(stack -> stack.getItem() instanceof CrossbowItem) ? SoundEvents.CROSSBOW_SHOOT : SoundEvents.SKELETON_SHOOT); + } + + /*==============*/ + /* VARIANTS */ + /*==============*/ + + public Holder getVariant() { + return this.entityData.get(VARIANT); + } + + public void setVariant(Holder variant) { + this.entityData.set(VARIANT, variant); + } + + /*============*/ + /* STATES */ + /*============*/ + + public State getState() { + if (this.isHolding(Items.CROSSBOW) && this.isCharging()) { + return State.CROSSBOW_CHARGE; + } else if (this.isHolding(CrossbowItem::isCharged)) { + return State.CROSSBOW_HOLD; + } else if (this.isBreaststrokeSwimming()) { + return State.SWIMMING; + } else if (this.isHolding(Items.BOW)) { + return State.BOW_HOLD; + } + return State.NEUTRAL; + } + + public enum State { + CROSSBOW_HOLD, + CROSSBOW_CHARGE, + BOW_HOLD, + SWIMMING, + NEUTRAL + } + + /*==========*/ + /* DATA */ + /*==========*/ + + @Override + protected void defineSynchedData(SynchedEntityData.Builder builder) { + super.defineSynchedData(builder); + builder.define(VARIANT, this.registryAccess().lookupOrThrow(PromenadeRegistryKeys.SUNKEN_VARIANT).getOrThrow(SunkenVariants.DEFAULT)); + builder.define(CHARGING, false); + builder.define(SWIMMING, false); + } + + @Override + protected void addAdditionalSaveData(ValueOutput view) { + super.addAdditionalSaveData(view); + VariantUtils.writeVariant(view, this.getVariant()); + + } + + @Override + protected void readAdditionalSaveData(ValueInput view) { + super.readAdditionalSaveData(view); + VariantUtils.readVariant(view, PromenadeRegistryKeys.SUNKEN_VARIANT).ifPresent(this::setVariant); + } + + @org.jetbrains.annotations.Nullable + @Override + public T get(DataComponentType type) { + return type == PromenadeComponentTypes.SUNKEN_VARIANT ? castComponentValue((DataComponentType) type, this.getVariant()) : super.get(type); + } + + @Override + protected void applyImplicitComponents(DataComponentGetter from) { + this.applyImplicitComponentIfPresent(from, PromenadeComponentTypes.SUNKEN_VARIANT); + super.applyImplicitComponents(from); + } + + @Override + protected boolean applyImplicitComponent(DataComponentType type, T value) { + if (type == PromenadeComponentTypes.SUNKEN_VARIANT) { + this.setVariant(castComponentValue(PromenadeComponentTypes.SUNKEN_VARIANT, value)); + return true; + } else { + return super.applyImplicitComponent(type, value); + } + } + + static class SunkenMoveControl extends MoveControl { + private final Sunken sunken; + + public SunkenMoveControl(Sunken sunken) { + super(sunken); + this.sunken = sunken; + } + + public void tick() { + LivingEntity target = this.sunken.getTarget(); + if (this.sunken.isTargetingUnderwater() || this.sunken.isUnderWater()) { + if (target != null) { + if (target.getY() > this.sunken.getY()) + this.sunken.setDeltaMovement(this.sunken.getDeltaMovement().add(0.0D, 0.002D, 0.0D)); + else this.sunken.setDeltaMovement(this.sunken.getDeltaMovement().add(0.0D, -0.002D, 0.0D)); + } + + if (this.operation == Operation.WAIT || this.sunken.getNavigation().isDone()) { + this.sunken.setSpeed(0.0F); + } + + double d = this.wantedX - this.sunken.getX(); + double e = this.wantedY - this.sunken.getY(); + double f = this.wantedZ - this.sunken.getZ(); + double g = Math.sqrt(d * d + e * e + f * f); + e /= g; + float h = (float) (Mth.atan2(f, d) * 57.2957763671875D) - 90.0F; + this.sunken.setYRot(this.rotlerp(this.sunken.getYRot(), h, 90.0F)); + this.sunken.yBodyRot = this.sunken.getYRot(); + float i = (float) (this.speedModifier * this.sunken.getAttributeValue(Attributes.MOVEMENT_SPEED)); + float j = Mth.lerp(0.125F, this.sunken.getSpeed(), i); + this.sunken.setSpeed(j); + this.sunken.setDeltaMovement(this.sunken.getDeltaMovement().add((double) j * d * 0.005D, (double) j * e * 0.1D, (double) j * f * 0.005D)); + } else { + if (!this.sunken.onGround()) { + this.sunken.setDeltaMovement(this.sunken.getDeltaMovement().add(0.0D, -0.008D, 0.0D)); + } + super.tick(); + } + } + } + + static class LeaveWaterGoal extends MoveToBlockGoal { + private final Sunken sunken; + + public LeaveWaterGoal(Sunken sunken, double speed) { + super(sunken, speed, 8, 2); + this.sunken = sunken; + } + + public boolean canUse() { + return super.canUse() && !this.sunken.level().isBrightOutside() && this.sunken.isInWater() && this.sunken.getY() >= (double) (this.sunken.level().getSeaLevel() - 3); + } + + public boolean canContinueToUse() { + return super.canContinueToUse(); + } + + protected boolean isValidTarget(LevelReader world, BlockPos pos) { + BlockPos blockPos = pos.above(); + return world.isEmptyBlock(blockPos) && world.isEmptyBlock(blockPos.above()) && world.getBlockState(pos).entityCanStandOn(world, pos, this.sunken); + } + + public void start() { + this.sunken.setTargetingUnderwater(false); + this.sunken.navigation = this.sunken.landNavigation; + super.start(); + } + + public void stop() { + super.stop(); + } + } + + private static class TargetAboveWaterGoal extends Goal { + private final Sunken sunken; + private final double speed; + private final int minY; + private boolean foundTarget; + + public TargetAboveWaterGoal(Sunken sunken, double speed, int minY) { + this.sunken = sunken; + this.speed = speed; + this.minY = minY; + } + + public boolean canUse() { + return !this.sunken.level().isBrightOutside() && this.sunken.isInWater() && !this.sunken.isTargetingUnderwater() && this.sunken.getY() < (double) (this.minY - 2); + } + + public boolean canContinueToUse() { + return this.canUse() && !this.foundTarget; + } + + public void tick() { + if (this.sunken.getY() < (double) (this.minY - 1) && (this.sunken.getNavigation().isDone() || this.sunken.hasFinishedCurrentPath())) { + Vec3 vec3d = DefaultRandomPos.getPosTowards(this.sunken, 4, 8, new Vec3(this.sunken.getX(), this.minY - 1, this.sunken.getZ()), 1.6D); + if (vec3d == null) { + this.foundTarget = true; + return; + } + + this.sunken.getNavigation().moveTo(vec3d.x, vec3d.y, vec3d.z, this.speed); + } + + } + + public void start() { + this.sunken.setTargetingUnderwater(true); + this.foundTarget = false; + } + + public void stop() { + this.sunken.setTargetingUnderwater(false); + } + } +} \ No newline at end of file diff --git a/src/main/java/fr/hugman/promenade/entity/SunkenEntity.java b/src/main/java/fr/hugman/promenade/entity/SunkenEntity.java deleted file mode 100644 index b5e5bf70..00000000 --- a/src/main/java/fr/hugman/promenade/entity/SunkenEntity.java +++ /dev/null @@ -1,519 +0,0 @@ -package fr.hugman.promenade.entity; - -import fr.hugman.promenade.component.PromenadeComponentTypes; -import fr.hugman.promenade.entity.data.PromenadeTrackedData; -import fr.hugman.promenade.entity.variant.SunkenVariant; -import fr.hugman.promenade.entity.variant.SunkenVariants; -import fr.hugman.promenade.registry.PromenadeRegistryKeys; -import fr.hugman.promenade.sound.PromenadeSoundEvents; -import net.minecraft.component.ComponentType; -import net.minecraft.component.ComponentsAccess; -import net.minecraft.entity.*; -import net.minecraft.entity.ai.NoPenaltyTargeting; -import net.minecraft.entity.ai.control.MoveControl; -import net.minecraft.entity.ai.goal.*; -import net.minecraft.entity.ai.pathing.MobNavigation; -import net.minecraft.entity.ai.pathing.Path; -import net.minecraft.entity.ai.pathing.PathNodeType; -import net.minecraft.entity.ai.pathing.SwimNavigation; -import net.minecraft.entity.attribute.DefaultAttributeContainer; -import net.minecraft.entity.attribute.EntityAttributes; -import net.minecraft.entity.damage.DamageSource; -import net.minecraft.entity.data.DataTracker; -import net.minecraft.entity.data.TrackedData; -import net.minecraft.entity.data.TrackedDataHandlerRegistry; -import net.minecraft.entity.effect.StatusEffectInstance; -import net.minecraft.entity.effect.StatusEffects; -import net.minecraft.entity.mob.AbstractSkeletonEntity; -import net.minecraft.entity.passive.DolphinEntity; -import net.minecraft.entity.passive.PufferfishEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.projectile.ArrowEntity; -import net.minecraft.entity.projectile.PersistentProjectileEntity; -import net.minecraft.entity.projectile.ProjectileUtil; -import net.minecraft.entity.spawn.SpawnContext; -import net.minecraft.item.BowItem; -import net.minecraft.item.CrossbowItem; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.registry.entry.RegistryEntry; -import net.minecraft.registry.tag.FluidTags; -import net.minecraft.sound.SoundEvent; -import net.minecraft.sound.SoundEvents; -import net.minecraft.storage.ReadView; -import net.minecraft.storage.WriteView; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.Vec3d; -import net.minecraft.util.math.random.Random; -import net.minecraft.world.*; - -import javax.annotation.Nullable; -import java.util.Optional; - -public class SunkenEntity extends AbstractSkeletonEntity implements CrossbowUser { - private static final TrackedData> VARIANT = DataTracker.registerData(SunkenEntity.class, PromenadeTrackedData.SUNKEN_VARIANT); - private static final TrackedData CHARGING = DataTracker.registerData(SunkenEntity.class, TrackedDataHandlerRegistry.BOOLEAN); - private static final TrackedData SWIMMING = DataTracker.registerData(SunkenEntity.class, TrackedDataHandlerRegistry.BOOLEAN); - - private final static EntityDimensions SWIMMING_DIMENSIONS = EntityDimensions.fixed(0.6F, 0.6F); - - protected final SwimNavigation waterNavigation; - protected final MobNavigation landNavigation; - private final CrossbowAttackGoal crossbowAttackGoal = new CrossbowAttackGoal<>(this, 1.0D, 20.0F); - private final BowAttackGoal bowAttackGoal = new BowAttackGoal<>(this, 1.0D, 20, 15.0F); - private final MeleeAttackGoal meleeAttackGoal = new MeleeAttackGoal(this, 1.2D, false) { - public void stop() { - super.stop(); - SunkenEntity.this.setAttacking(false); - } - - public void start() { - super.start(); - SunkenEntity.this.setAttacking(true); - } - }; - boolean targetingUnderwater; - - public SunkenEntity(EntityType entityType, World world) { - super(entityType, world); - this.updateAttackType(); - this.moveControl = new SunkenMoveControl(this); - this.setPathfindingPenalty(PathNodeType.WATER, 0.0F); - this.waterNavigation = new SwimNavigation(this, world); - this.landNavigation = new MobNavigation(this, world); - } - - @Nullable - @Override - public EntityData initialize(ServerWorldAccess world, LocalDifficulty difficulty, SpawnReason spawnReason, @Nullable EntityData entityData) { - SunkenVariants.select(this.random, this.getRegistryManager(), SpawnContext.of(world, this.getBlockPos())).ifPresent(this::setVariant); - this.lootTable = Optional.ofNullable(this.getVariant().value().lootTable()); - return super.initialize(world, difficulty, spawnReason, entityData); - } - - public static boolean canSpawn(EntityType ignoredType, ServerWorldAccess world, SpawnReason spawnReason, BlockPos pos, Random random) { - boolean bl = world.getDifficulty() != Difficulty.PEACEFUL - && isSpawnDark(world, pos, random) - && (spawnReason == SpawnReason.SPAWNER || world.getFluidState(pos).isIn(FluidTags.WATER)); - return pos.getY() < world.getSeaLevel() - 10 && bl; - } - - @Override - public boolean canSpawn(WorldView world) { - return world.doesNotIntersectEntities(this); - } - - @Override - public EntityDimensions getBaseDimensions(EntityPose pose) { - if (this.isBreaststrokeSwimming()) return SWIMMING_DIMENSIONS; - else return super.getBaseDimensions(pose); - } - - /*========*/ - /* AI */ - /*========*/ - - public static DefaultAttributeContainer.Builder createSunkenAttributes() { - return createAbstractSkeletonAttributes(); - } - - @Override - protected void initGoals() { - this.goalSelector.add(1, new MoveIntoWaterGoal(this)); - this.goalSelector.add(1, new AvoidSunlightGoal(this)); - this.goalSelector.add(2, new CrossbowAttackGoal(this, 1.0D, 4.5F)); - this.goalSelector.add(3, new FleeEntityGoal(this, PufferfishEntity.class, 8.0F, 1.0D, 1.2D)); - this.goalSelector.add(3, new EscapeSunlightGoal(this, 1.0D)); - this.goalSelector.add(6, new SwimAroundGoal(this, 1.0D, 40)); - this.goalSelector.add(7, new WanderAroundFarGoal(this, 1.0D)); - this.goalSelector.add(7, new SunkenEntity.TargetAboveWaterGoal(this, 1.0D, this.getEntityWorld().getSeaLevel())); - this.goalSelector.add(7, new SunkenEntity.LeaveWaterGoal(this, 1.0D)); - this.goalSelector.add(8, new LookAtEntityGoal(this, PlayerEntity.class, 8.0F)); - this.goalSelector.add(8, new LookAroundGoal(this)); - - this.targetSelector.add(1, new RevengeGoal(this)); - this.targetSelector.add(2, new ActiveTargetGoal(this, PlayerEntity.class, true)); - this.targetSelector.add(2, new ActiveTargetGoal(this, DolphinEntity.class, true)); - } - - @Override - public void shootAt(LivingEntity target, float pullProgress) { - if (this.isHolding(stack -> stack.getItem() instanceof CrossbowItem)) { - this.shoot(this, 1.6F); - } else { - ItemStack itemStack = this.getStackInHand(ProjectileUtil.getHandPossiblyHolding(this, Items.BOW)); - PersistentProjectileEntity persistentProjectileEntity = this.createArrowProjectile(this.getProjectileType(itemStack), pullProgress, itemStack); - double d = target.getX() - this.getX(); - double e = target.getBodyY(0.3333333333333333D) - persistentProjectileEntity.getY(); - double f = target.getZ() - this.getZ(); - double g = Math.sqrt(d * d + f * f); - persistentProjectileEntity.setVelocity(d, e + g * 0.20000000298023224D, f, 1.6F, (float) (14 - this.getEntityWorld().getDifficulty().getId() * 4)); - this.playSound(this.getShootSound(), 1.0F, 1.0F / (this.getRandom().nextFloat() * 0.4F + 0.8F)); - this.getEntityWorld().spawnEntity(persistentProjectileEntity); - } - } - - @Override - public void shoot(LivingEntity entity, float speed) { - CrossbowUser.super.shoot(entity, speed); - } - - @Override - protected PersistentProjectileEntity createArrowProjectile(ItemStack arrow, float damageModifier, @Nullable ItemStack shotFrom) { - PersistentProjectileEntity persistentProjectileEntity = super.createArrowProjectile(arrow, damageModifier, shotFrom); - if (persistentProjectileEntity instanceof ArrowEntity) { - ((ArrowEntity) persistentProjectileEntity).addEffect(new StatusEffectInstance(StatusEffects.SLOWNESS, 600)); - } - - return persistentProjectileEntity; - } - - @Override - protected void initEquipment(Random random, LocalDifficulty difficulty) { - super.initEquipment(random, difficulty); - this.equipStack(EquipmentSlot.MAINHAND, new ItemStack(Items.CROSSBOW)); - } - - @Override - public boolean canUseRangedWeapon(ItemStack stack) { - var weapon = stack.getItem(); - return weapon instanceof BowItem || weapon instanceof CrossbowItem; - } - - @Override - public void travel(Vec3d movementInput) { - if (this.canMoveVoluntarily() && this.isTouchingWater()) { - float speed = 0.075F; - this.updateVelocity(speed, movementInput); - this.move(MovementType.SELF, this.getVelocity()); - this.setVelocity(this.getVelocity().multiply(0.9D)); - } else { - super.travel(movementInput); - } - } - - @Override - public boolean isPushedByFluids() { - return !this.isSwimming(); - } - - @Override - public void updateSwimming() { - if (!this.getEntityWorld().isClient()) { - boolean b = this.getEntityWorld().isAir(this.getBlockPos().up(2)); - if (!b && this.canMoveVoluntarily() && this.isSubmergedInWater()) { - this.navigation = this.waterNavigation; - this.setSwimming(true); - this.setBreaststrokeSwimming(true); - } else { - this.navigation = this.landNavigation; - this.setSwimming(false); - this.setBreaststrokeSwimming(false); - } - } - } - - @Override - public void updateAttackType() { - if (this.getEntityWorld() != null && !this.getEntityWorld().isClient()) { - if (this.bowAttackGoal != null && this.crossbowAttackGoal != null && this.meleeAttackGoal != null) { - this.goalSelector.remove(this.bowAttackGoal); - this.goalSelector.remove(this.crossbowAttackGoal); - this.goalSelector.remove(this.meleeAttackGoal); - ItemStack itemStack = this.getStackInHand(ProjectileUtil.getHandPossiblyHolding(this, Items.CROSSBOW)); - if (itemStack.isOf(Items.CROSSBOW)) { - this.goalSelector.add(4, this.crossbowAttackGoal); - } else if (itemStack.isOf(Items.BOW)) { - this.bowAttackGoal.setAttackInterval(this.getEntityWorld().getDifficulty() != Difficulty.HARD ? 40 : 20); - this.goalSelector.add(4, this.bowAttackGoal); - } else { - this.goalSelector.add(4, this.meleeAttackGoal); - } - } - } - } - - public boolean isCharging() { - return this.dataTracker.get(CHARGING); - } - - @Override - public void setCharging(boolean charging) { - this.dataTracker.set(CHARGING, charging); - } - - public boolean isBreaststrokeSwimming() { - if (this.getVelocity().length() < 0.1F) return false; - else return this.dataTracker.get(SWIMMING); - } - - public void setBreaststrokeSwimming(boolean breaststrokeSwimming) { - this.dataTracker.set(SWIMMING, breaststrokeSwimming); - } - - @Override - public boolean isInSwimmingPose() { - return isBreaststrokeSwimming(); - } - - @Override - public void postShoot() { - this.despawnCounter = 0; - } - - protected boolean hasFinishedCurrentPath() { - Path path = this.getNavigation().getCurrentPath(); - if (path != null) { - BlockPos blockPos = path.getTarget(); - if (blockPos != null) { - double d = this.squaredDistanceTo(blockPos.getX(), blockPos.getY(), blockPos.getZ()); - return d < 4.0D; - } - } - - return false; - } - - boolean isTargetingUnderwater() { - if (this.targetingUnderwater) { - return true; - } else { - LivingEntity livingEntity = this.getTarget(); - return livingEntity != null && livingEntity.isTouchingWater(); - } - } - - public void setTargetingUnderwater(boolean targetingUnderwater) { - this.targetingUnderwater = targetingUnderwater; - } - - /*============*/ - /* SOUNDS */ - /*============*/ - - @Override - protected SoundEvent getAmbientSound() { - return this.isSubmergedIn(FluidTags.WATER) ? PromenadeSoundEvents.SUNKEN_AMBIENT : SoundEvents.ENTITY_SKELETON_AMBIENT; - } - - @Override - protected SoundEvent getHurtSound(DamageSource source) { - return this.isSubmergedIn(FluidTags.WATER) ? PromenadeSoundEvents.SUNKEN_HURT : SoundEvents.ENTITY_SKELETON_HURT; - } - - @Override - protected SoundEvent getDeathSound() { - return this.isSubmergedIn(FluidTags.WATER) ? PromenadeSoundEvents.SUNKEN_DEATH : SoundEvents.ENTITY_SKELETON_DEATH; - } - - @Override - protected SoundEvent getStepSound() { - return this.isSubmergedIn(FluidTags.WATER) ? PromenadeSoundEvents.SUNKEN_STEP : SoundEvents.ENTITY_SKELETON_STEP; - } - - protected SoundEvent getShootSound() { - return this.isSubmergedIn(FluidTags.WATER) ? PromenadeSoundEvents.SUNKEN_SHOOT : (this.isHolding(stack -> stack.getItem() instanceof CrossbowItem) ? SoundEvents.ITEM_CROSSBOW_SHOOT : SoundEvents.ENTITY_SKELETON_SHOOT); - } - - /*==============*/ - /* VARIANTS */ - /*==============*/ - - public RegistryEntry getVariant() { - return this.dataTracker.get(VARIANT); - } - - public void setVariant(RegistryEntry variant) { - this.dataTracker.set(VARIANT, variant); - } - - /*============*/ - /* STATES */ - /*============*/ - - public State getState() { - if (this.isHolding(Items.CROSSBOW) && this.isCharging()) { - return State.CROSSBOW_CHARGE; - } else if (this.isHolding(CrossbowItem::isCharged)) { - return State.CROSSBOW_HOLD; - } else if (this.isBreaststrokeSwimming()) { - return State.SWIMMING; - } else if (this.isHolding(Items.BOW)) { - return State.BOW_HOLD; - } - return State.NEUTRAL; - } - - public enum State { - CROSSBOW_HOLD, - CROSSBOW_CHARGE, - BOW_HOLD, - SWIMMING, - NEUTRAL - } - - /*==========*/ - /* DATA */ - /*==========*/ - - @Override - protected void initDataTracker(DataTracker.Builder builder) { - super.initDataTracker(builder); - builder.add(VARIANT, this.getRegistryManager().getOrThrow(PromenadeRegistryKeys.SUNKEN_VARIANT).getOrThrow(SunkenVariants.DEFAULT)); - builder.add(CHARGING, false); - builder.add(SWIMMING, false); - } - - @Override - protected void writeCustomData(WriteView view) { - super.writeCustomData(view); - Variants.writeData(view, this.getVariant()); - - } - - @Override - protected void readCustomData(ReadView view) { - super.readCustomData(view); - Variants.fromData(view, PromenadeRegistryKeys.SUNKEN_VARIANT).ifPresent(this::setVariant); - } - - @org.jetbrains.annotations.Nullable - @Override - public T get(ComponentType type) { - return type == PromenadeComponentTypes.SUNKEN_VARIANT ? castComponentValue((ComponentType) type, this.getVariant()) : super.get(type); - } - - @Override - protected void copyComponentsFrom(ComponentsAccess from) { - this.copyComponentFrom(from, PromenadeComponentTypes.SUNKEN_VARIANT); - super.copyComponentsFrom(from); - } - - @Override - protected boolean setApplicableComponent(ComponentType type, T value) { - if (type == PromenadeComponentTypes.SUNKEN_VARIANT) { - this.setVariant(castComponentValue(PromenadeComponentTypes.SUNKEN_VARIANT, value)); - return true; - } else { - return super.setApplicableComponent(type, value); - } - } - - static class SunkenMoveControl extends MoveControl { - private final SunkenEntity sunken; - - public SunkenMoveControl(SunkenEntity sunken) { - super(sunken); - this.sunken = sunken; - } - - public void tick() { - LivingEntity target = this.sunken.getTarget(); - if (this.sunken.isTargetingUnderwater() || this.sunken.isSubmergedInWater()) { - if (target != null) { - if (target.getY() > this.sunken.getY()) - this.sunken.setVelocity(this.sunken.getVelocity().add(0.0D, 0.002D, 0.0D)); - else this.sunken.setVelocity(this.sunken.getVelocity().add(0.0D, -0.002D, 0.0D)); - } - - if (this.state == State.WAIT || this.sunken.getNavigation().isIdle()) { - this.sunken.setMovementSpeed(0.0F); - } - - double d = this.targetX - this.sunken.getX(); - double e = this.targetY - this.sunken.getY(); - double f = this.targetZ - this.sunken.getZ(); - double g = Math.sqrt(d * d + e * e + f * f); - e /= g; - float h = (float) (MathHelper.atan2(f, d) * 57.2957763671875D) - 90.0F; - this.sunken.setYaw(this.wrapDegrees(this.sunken.getYaw(), h, 90.0F)); - this.sunken.bodyYaw = this.sunken.getYaw(); - float i = (float) (this.speed * this.sunken.getAttributeValue(EntityAttributes.MOVEMENT_SPEED)); - float j = MathHelper.lerp(0.125F, this.sunken.getMovementSpeed(), i); - this.sunken.setMovementSpeed(j); - this.sunken.setVelocity(this.sunken.getVelocity().add((double) j * d * 0.005D, (double) j * e * 0.1D, (double) j * f * 0.005D)); - } else { - if (!this.sunken.isOnGround()) { - this.sunken.setVelocity(this.sunken.getVelocity().add(0.0D, -0.008D, 0.0D)); - } - super.tick(); - } - } - } - - static class LeaveWaterGoal extends MoveToTargetPosGoal { - private final SunkenEntity sunken; - - public LeaveWaterGoal(SunkenEntity sunken, double speed) { - super(sunken, speed, 8, 2); - this.sunken = sunken; - } - - public boolean canStart() { - return super.canStart() && !this.sunken.getEntityWorld().isDay() && this.sunken.isTouchingWater() && this.sunken.getY() >= (double) (this.sunken.getEntityWorld().getSeaLevel() - 3); - } - - public boolean shouldContinue() { - return super.shouldContinue(); - } - - protected boolean isTargetPos(WorldView world, BlockPos pos) { - BlockPos blockPos = pos.up(); - return world.isAir(blockPos) && world.isAir(blockPos.up()) && world.getBlockState(pos).hasSolidTopSurface(world, pos, this.sunken); - } - - public void start() { - this.sunken.setTargetingUnderwater(false); - this.sunken.navigation = this.sunken.landNavigation; - super.start(); - } - - public void stop() { - super.stop(); - } - } - - private static class TargetAboveWaterGoal extends Goal { - private final SunkenEntity sunken; - private final double speed; - private final int minY; - private boolean foundTarget; - - public TargetAboveWaterGoal(SunkenEntity sunken, double speed, int minY) { - this.sunken = sunken; - this.speed = speed; - this.minY = minY; - } - - public boolean canStart() { - return !this.sunken.getEntityWorld().isDay() && this.sunken.isTouchingWater() && !this.sunken.isTargetingUnderwater() && this.sunken.getY() < (double) (this.minY - 2); - } - - public boolean shouldContinue() { - return this.canStart() && !this.foundTarget; - } - - public void tick() { - if (this.sunken.getY() < (double) (this.minY - 1) && (this.sunken.getNavigation().isIdle() || this.sunken.hasFinishedCurrentPath())) { - Vec3d vec3d = NoPenaltyTargeting.findTo(this.sunken, 4, 8, new Vec3d(this.sunken.getX(), this.minY - 1, this.sunken.getZ()), 1.6D); - if (vec3d == null) { - this.foundTarget = true; - return; - } - - this.sunken.getNavigation().startMovingTo(vec3d.x, vec3d.y, vec3d.z, this.speed); - } - - } - - public void start() { - this.sunken.setTargetingUnderwater(true); - this.foundTarget = false; - } - - public void stop() { - this.sunken.setTargetingUnderwater(false); - } - } -} \ No newline at end of file diff --git a/src/main/java/fr/hugman/promenade/entity/ai/brain/PromenadeActivities.java b/src/main/java/fr/hugman/promenade/entity/ai/brain/PromenadeActivities.java index 18825519..ebd573ed 100644 --- a/src/main/java/fr/hugman/promenade/entity/ai/brain/PromenadeActivities.java +++ b/src/main/java/fr/hugman/promenade/entity/ai/brain/PromenadeActivities.java @@ -1,15 +1,15 @@ package fr.hugman.promenade.entity.ai.brain; import fr.hugman.promenade.Promenade; -import net.minecraft.entity.ai.brain.Activity; -import net.minecraft.registry.Registries; -import net.minecraft.registry.Registry; +import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.world.entity.schedule.Activity; public class PromenadeActivities { public static final Activity FART = register("fart"); private static Activity register(String id) { var key = Promenade.id(id); - return Registry.register(Registries.ACTIVITY, key, new Activity(key.toString())); + return Registry.register(BuiltInRegistries.ACTIVITY, key, new Activity(key.toString())); } } diff --git a/src/main/java/fr/hugman/promenade/entity/ai/brain/PromenadeMemoryModuleTypes.java b/src/main/java/fr/hugman/promenade/entity/ai/brain/PromenadeMemoryModuleTypes.java index 502778fc..72c47416 100644 --- a/src/main/java/fr/hugman/promenade/entity/ai/brain/PromenadeMemoryModuleTypes.java +++ b/src/main/java/fr/hugman/promenade/entity/ai/brain/PromenadeMemoryModuleTypes.java @@ -2,22 +2,21 @@ import com.mojang.serialization.Codec; import fr.hugman.promenade.Promenade; -import net.minecraft.entity.ai.brain.MemoryModuleType; -import net.minecraft.registry.Registries; -import net.minecraft.registry.Registry; +import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.util.Unit; - +import net.minecraft.world.entity.ai.memory.MemoryModuleType; import java.util.Optional; public class PromenadeMemoryModuleTypes { public static final MemoryModuleType FART_COOLDOWN = register("fart_cooldown", Unit.CODEC); private static MemoryModuleType register(String id, Codec codec) { - return Registry.register(Registries.MEMORY_MODULE_TYPE, Promenade.id(id), new MemoryModuleType<>(Optional.of(codec))); + return Registry.register(BuiltInRegistries.MEMORY_MODULE_TYPE, Promenade.id(id), new MemoryModuleType<>(Optional.of(codec))); } private static MemoryModuleType register(String id) { - return Registry.register(Registries.MEMORY_MODULE_TYPE, Promenade.id(id), new MemoryModuleType<>(Optional.empty())); + return Registry.register(BuiltInRegistries.MEMORY_MODULE_TYPE, Promenade.id(id), new MemoryModuleType<>(Optional.empty())); } diff --git a/src/main/java/fr/hugman/promenade/entity/ai/brain/sensor/PromenadeSensorTypes.java b/src/main/java/fr/hugman/promenade/entity/ai/brain/sensor/PromenadeSensorTypes.java index fbdb91e8..c140e658 100644 --- a/src/main/java/fr/hugman/promenade/entity/ai/brain/sensor/PromenadeSensorTypes.java +++ b/src/main/java/fr/hugman/promenade/entity/ai/brain/sensor/PromenadeSensorTypes.java @@ -1,20 +1,19 @@ package fr.hugman.promenade.entity.ai.brain.sensor; import fr.hugman.promenade.Promenade; -import fr.hugman.promenade.entity.CapybaraBrain; -import net.minecraft.entity.ai.brain.sensor.Sensor; -import net.minecraft.entity.ai.brain.sensor.SensorType; -import net.minecraft.entity.ai.brain.sensor.TemptationsSensor; -import net.minecraft.registry.Registries; -import net.minecraft.registry.Registry; - +import fr.hugman.promenade.entity.CapybaraAi; import java.util.function.Supplier; +import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.world.entity.ai.sensing.Sensor; +import net.minecraft.world.entity.ai.sensing.SensorType; +import net.minecraft.world.entity.ai.sensing.TemptingSensor; public class PromenadeSensorTypes { - public static final SensorType CAPYBARA_TEMPTATIONS = register("capybara_temptations", () -> new TemptationsSensor(CapybaraBrain.getTemptItemPredicate())); + public static final SensorType CAPYBARA_TEMPTATIONS = register("capybara_temptations", () -> new TemptingSensor(CapybaraAi.getTemptItemPredicate())); private static > SensorType register(String path, Supplier factory) { - return Registry.register(Registries.SENSOR_TYPE, Promenade.id(path), new SensorType<>(factory)); + return Registry.register(BuiltInRegistries.SENSOR_TYPE, Promenade.id(path), new SensorType<>(factory)); } } diff --git a/src/main/java/fr/hugman/promenade/entity/damage/PromenadeFallLocations.java b/src/main/java/fr/hugman/promenade/entity/damage/PromenadeFallLocations.java index 0f636f88..96b30043 100644 --- a/src/main/java/fr/hugman/promenade/entity/damage/PromenadeFallLocations.java +++ b/src/main/java/fr/hugman/promenade/entity/damage/PromenadeFallLocations.java @@ -1,6 +1,6 @@ package fr.hugman.promenade.entity.damage; -import net.minecraft.entity.damage.FallLocation; +import net.minecraft.world.damagesource.FallLocation; public class PromenadeFallLocations { public static final FallLocation COILED_VINES = new FallLocation("coiled_vines"); diff --git a/src/main/java/fr/hugman/promenade/entity/data/PromenadeTrackedData.java b/src/main/java/fr/hugman/promenade/entity/data/PromenadeTrackedData.java index 87a7d0b5..2b9d6baa 100644 --- a/src/main/java/fr/hugman/promenade/entity/data/PromenadeTrackedData.java +++ b/src/main/java/fr/hugman/promenade/entity/data/PromenadeTrackedData.java @@ -1,26 +1,26 @@ package fr.hugman.promenade.entity.data; import fr.hugman.promenade.Promenade; -import fr.hugman.promenade.entity.CapybaraEntity; +import fr.hugman.promenade.entity.Capybara; import fr.hugman.promenade.entity.variant.CapybaraVariant; import fr.hugman.promenade.entity.variant.DuckVariant; import fr.hugman.promenade.entity.variant.SunkenVariant; -import net.fabricmc.fabric.api.object.builder.v1.entity.FabricTrackedDataRegistry; -import net.minecraft.entity.data.TrackedDataHandler; -import net.minecraft.network.RegistryByteBuf; -import net.minecraft.network.codec.PacketCodec; -import net.minecraft.registry.entry.RegistryEntry; +import net.fabricmc.fabric.api.object.builder.v1.entity.FabricEntityDataRegistry; +import net.minecraft.core.Holder; +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.StreamCodec; +import net.minecraft.network.syncher.EntityDataSerializer; public class PromenadeTrackedData { - public static final TrackedDataHandler> DUCK_VARIANT = of("duck_variant", DuckVariant.ENTRY_PACKET_CODEC); - public static final TrackedDataHandler> CAPYBARA_VARIANT = of("capybara_variant", CapybaraVariant.ENTRY_PACKET_CODEC); - public static final TrackedDataHandler> SUNKEN_VARIANT = of("sunken_variant", SunkenVariant.ENTRY_PACKET_CODEC); + public static final EntityDataSerializer> DUCK_VARIANT = of("duck_variant", DuckVariant.ENTRY_PACKET_CODEC); + public static final EntityDataSerializer> CAPYBARA_VARIANT = of("capybara_variant", CapybaraVariant.ENTRY_PACKET_CODEC); + public static final EntityDataSerializer> SUNKEN_VARIANT = of("sunken_variant", SunkenVariant.ENTRY_PACKET_CODEC); - public static final TrackedDataHandler CAPYBARA_STATE = of("capybara_state", CapybaraEntity.State.PACKET_CODEC); + public static final EntityDataSerializer CAPYBARA_STATE = of("capybara_state", Capybara.State.PACKET_CODEC); - public static TrackedDataHandler of(String name, PacketCodec codec) { - var handler = TrackedDataHandler.create(codec); - FabricTrackedDataRegistry.register(Promenade.id(name), handler); + public static EntityDataSerializer of(String name, StreamCodec codec) { + var handler = EntityDataSerializer.forValueType(codec); + FabricEntityDataRegistry.register(Promenade.id(name), handler); return handler; } } diff --git a/src/main/java/fr/hugman/promenade/entity/helper/EntityTypeFactory.java b/src/main/java/fr/hugman/promenade/entity/helper/EntityTypeFactory.java index 1ae29080..552f36eb 100644 --- a/src/main/java/fr/hugman/promenade/entity/helper/EntityTypeFactory.java +++ b/src/main/java/fr/hugman/promenade/entity/helper/EntityTypeFactory.java @@ -1,29 +1,28 @@ package fr.hugman.promenade.entity.helper; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.SpawnGroup; -import net.minecraft.entity.vehicle.BoatEntity; -import net.minecraft.entity.vehicle.ChestBoatEntity; -import net.minecraft.item.Item; - import java.util.function.Supplier; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.MobCategory; +import net.minecraft.world.entity.vehicle.boat.Boat; +import net.minecraft.world.entity.vehicle.boat.ChestBoat; +import net.minecraft.world.item.Item; public class EntityTypeFactory { - public static EntityType.Builder boat(Supplier item) { - EntityType.EntityFactory factory = (type, world) -> new BoatEntity(type, world, item); - return EntityType.Builder.create(factory, SpawnGroup.MISC) - .dropsNothing() - .dimensions(1.375F, 0.5625F) + public static EntityType.Builder boat(Supplier item) { + EntityType.EntityFactory factory = (type, world) -> new Boat(type, world, item); + return EntityType.Builder.of(factory, MobCategory.MISC) + .noLootTable() + .sized(1.375F, 0.5625F) .eyeHeight(0.5625F) - .maxTrackingRange(10); + .clientTrackingRange(10); } - public static EntityType.Builder chestBoat(Supplier item) { - EntityType.EntityFactory factory = (type, world) -> new ChestBoatEntity(type, world, item); - return EntityType.Builder.create(factory, SpawnGroup.MISC) - .dropsNothing() - .dimensions(1.375F, 0.5625F) + public static EntityType.Builder chestBoat(Supplier item) { + EntityType.EntityFactory factory = (type, world) -> new ChestBoat(type, world, item); + return EntityType.Builder.of(factory, MobCategory.MISC) + .noLootTable() + .sized(1.375F, 0.5625F) .eyeHeight(0.5625F) - .maxTrackingRange(10); + .clientTrackingRange(10); } } diff --git a/src/main/java/fr/hugman/promenade/entity/spawn/ChanceSpawnCondition.java b/src/main/java/fr/hugman/promenade/entity/spawn/ChanceSpawnCondition.java index f4ab121f..fbf5b43b 100644 --- a/src/main/java/fr/hugman/promenade/entity/spawn/ChanceSpawnCondition.java +++ b/src/main/java/fr/hugman/promenade/entity/spawn/ChanceSpawnCondition.java @@ -2,21 +2,21 @@ import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; -import net.minecraft.entity.spawn.SpawnCondition; -import net.minecraft.entity.spawn.SpawnContext; -import net.minecraft.util.dynamic.Codecs; +import net.minecraft.util.ExtraCodecs; +import net.minecraft.world.entity.variant.SpawnCondition; +import net.minecraft.world.entity.variant.SpawnContext; public record ChanceSpawnCondition(float chance) implements SpawnCondition { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> instance.group( - Codecs.rangedInclusiveFloat(0.0F, 1.0F).fieldOf("chance").forGetter(ChanceSpawnCondition::chance) + ExtraCodecs.floatRange(0.0F, 1.0F).fieldOf("chance").forGetter(ChanceSpawnCondition::chance) ).apply(instance, ChanceSpawnCondition::new)); public boolean test(SpawnContext spawnContext) { - return spawnContext.world().getRandom().nextFloat() < this.chance; + return spawnContext.level().getRandom().nextFloat() < this.chance; } @Override - public MapCodec getCodec() { + public MapCodec codec() { return CODEC; } } diff --git a/src/main/java/fr/hugman/promenade/entity/spawn/PromenadeSpawnConditions.java b/src/main/java/fr/hugman/promenade/entity/spawn/PromenadeSpawnConditions.java index c7ef0ef6..0297a767 100644 --- a/src/main/java/fr/hugman/promenade/entity/spawn/PromenadeSpawnConditions.java +++ b/src/main/java/fr/hugman/promenade/entity/spawn/PromenadeSpawnConditions.java @@ -2,9 +2,9 @@ import com.mojang.serialization.MapCodec; import fr.hugman.promenade.Promenade; -import net.minecraft.entity.spawn.SpawnCondition; -import net.minecraft.registry.Registries; -import net.minecraft.registry.Registry; +import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.world.entity.variant.SpawnCondition; public class PromenadeSpawnConditions { public static void register() { @@ -12,6 +12,6 @@ public static void register() { } public static MapCodec of(String name, MapCodec codec) { - return Registry.register(Registries.SPAWN_CONDITION_TYPE, Promenade.id(name), codec); + return Registry.register(BuiltInRegistries.SPAWN_CONDITION_TYPE, Promenade.id(name), codec); } } diff --git a/src/main/java/fr/hugman/promenade/entity/variant/CapybaraVariant.java b/src/main/java/fr/hugman/promenade/entity/variant/CapybaraVariant.java index c5344dad..e8b79159 100644 --- a/src/main/java/fr/hugman/promenade/entity/variant/CapybaraVariant.java +++ b/src/main/java/fr/hugman/promenade/entity/variant/CapybaraVariant.java @@ -3,47 +3,59 @@ import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; import fr.hugman.promenade.registry.PromenadeRegistryKeys; -import net.minecraft.entity.VariantSelectorProvider; -import net.minecraft.entity.spawn.SpawnCondition; -import net.minecraft.entity.spawn.SpawnConditionSelectors; -import net.minecraft.entity.spawn.SpawnContext; -import net.minecraft.network.RegistryByteBuf; -import net.minecraft.network.codec.PacketCodec; -import net.minecraft.network.codec.PacketCodecs; -import net.minecraft.registry.entry.RegistryEntry; -import net.minecraft.registry.entry.RegistryFixedCodec; -import net.minecraft.util.AssetInfo.TextureAssetInfo; +import net.minecraft.core.ClientAsset.ResourceTexture; +import net.minecraft.core.Holder; +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.ByteBufCodecs; +import net.minecraft.network.codec.StreamCodec; +import net.minecraft.resources.RegistryFixedCodec; +import net.minecraft.world.entity.variant.PriorityProvider; +import net.minecraft.world.entity.variant.SpawnCondition; +import net.minecraft.world.entity.variant.SpawnContext; +import net.minecraft.world.entity.variant.SpawnPrioritySelectors; import java.util.List; public record CapybaraVariant( - TextureAssetInfo smallEyesTexture, - TextureAssetInfo largeEyesTexture, - TextureAssetInfo closedEyesTexture, - SpawnConditionSelectors spawnConditions -) implements VariantSelectorProvider { + AssetInfo adultInfo, + AssetInfo babyInfo, + SpawnPrioritySelectors spawnConditions +) implements PriorityProvider { public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( - TextureAssetInfo.CODEC.fieldOf("small_eyes_texture").forGetter(CapybaraVariant::smallEyesTexture), - TextureAssetInfo.CODEC.fieldOf("large_eyes_texture").forGetter(CapybaraVariant::largeEyesTexture), - TextureAssetInfo.CODEC.fieldOf("closed_eyes_texture").forGetter(CapybaraVariant::closedEyesTexture), - SpawnConditionSelectors.CODEC.fieldOf("spawn_conditions").forGetter(CapybaraVariant::spawnConditions) + AssetInfo.CODEC.fieldOf("assets").forGetter(CapybaraVariant::adultInfo), + AssetInfo.CODEC.fieldOf("baby_assets").forGetter(CapybaraVariant::babyInfo), + SpawnPrioritySelectors.CODEC.fieldOf("spawn_conditions").forGetter(CapybaraVariant::spawnConditions) ).apply(instance, CapybaraVariant::new)); public static final Codec NETWORK_CODEC = RecordCodecBuilder.create(instance -> instance.group( - TextureAssetInfo.CODEC.fieldOf("small_eyes_texture").forGetter(CapybaraVariant::smallEyesTexture), - TextureAssetInfo.CODEC.fieldOf("large_eyes_texture").forGetter(CapybaraVariant::largeEyesTexture), - TextureAssetInfo.CODEC.fieldOf("closed_eyes_texture").forGetter(CapybaraVariant::closedEyesTexture) + AssetInfo.CODEC.fieldOf("assets").forGetter(CapybaraVariant::adultInfo), + AssetInfo.CODEC.fieldOf("baby_assets").forGetter(CapybaraVariant::babyInfo) ).apply(instance, CapybaraVariant::new)); - public static final Codec> ENTRY_CODEC = RegistryFixedCodec.of(PromenadeRegistryKeys.CAPYBARA_VARIANT); - public static final PacketCodec> ENTRY_PACKET_CODEC = PacketCodecs.registryEntry(PromenadeRegistryKeys.CAPYBARA_VARIANT); + public static final Codec> ENTRY_CODEC = RegistryFixedCodec.create(PromenadeRegistryKeys.CAPYBARA_VARIANT); + public static final StreamCodec> ENTRY_PACKET_CODEC = ByteBufCodecs.holderRegistry(PromenadeRegistryKeys.CAPYBARA_VARIANT); - private CapybaraVariant(TextureAssetInfo smallEyesTexture, TextureAssetInfo largeEyesTexture, TextureAssetInfo closedEyesTexture) { - this(smallEyesTexture, largeEyesTexture, closedEyesTexture, SpawnConditionSelectors.EMPTY); + private CapybaraVariant(AssetInfo adultInfo, AssetInfo babyInfo) { + this(adultInfo, babyInfo, SpawnPrioritySelectors.EMPTY); } @Override - public List> getSelectors() { + public List> selectors() { return this.spawnConditions.selectors(); } + + public record AssetInfo( + ResourceTexture normal, + ResourceTexture surprised, + ResourceTexture sleeping + ) { + public static final Codec CODEC = RecordCodecBuilder.create( + instance -> instance.group( + ResourceTexture.CODEC.fieldOf("normal").forGetter(AssetInfo::normal), + ResourceTexture.CODEC.fieldOf("surprised").forGetter(AssetInfo::surprised), + ResourceTexture.CODEC.fieldOf("sleeping").forGetter(AssetInfo::sleeping) + ) + .apply(instance, AssetInfo::new) + ); + } } diff --git a/src/main/java/fr/hugman/promenade/entity/variant/CapybaraVariants.java b/src/main/java/fr/hugman/promenade/entity/variant/CapybaraVariants.java index 704ecd8d..c57e445c 100644 --- a/src/main/java/fr/hugman/promenade/entity/variant/CapybaraVariants.java +++ b/src/main/java/fr/hugman/promenade/entity/variant/CapybaraVariants.java @@ -2,26 +2,25 @@ import fr.hugman.promenade.Promenade; import fr.hugman.promenade.registry.PromenadeRegistryKeys; -import net.minecraft.entity.VariantSelectorProvider; -import net.minecraft.entity.spawn.SpawnContext; -import net.minecraft.registry.DynamicRegistryManager; -import net.minecraft.registry.RegistryKey; -import net.minecraft.registry.entry.RegistryEntry; -import net.minecraft.util.math.random.Random; - import java.util.Optional; +import net.minecraft.core.Holder; +import net.minecraft.core.RegistryAccess; +import net.minecraft.resources.ResourceKey; +import net.minecraft.util.RandomSource; +import net.minecraft.world.entity.variant.PriorityProvider; +import net.minecraft.world.entity.variant.SpawnContext; public class CapybaraVariants { - public static final RegistryKey BROWN = of("brown"); - public static final RegistryKey ALBINO = of("albino"); + public static final ResourceKey BROWN = of("brown"); + public static final ResourceKey ALBINO = of("albino"); - public static final RegistryKey DEFAULT = BROWN; + public static final ResourceKey DEFAULT = BROWN; - public static RegistryKey of(String path) { - return RegistryKey.of(PromenadeRegistryKeys.CAPYBARA_VARIANT, Promenade.id(path)); + public static ResourceKey of(String path) { + return ResourceKey.create(PromenadeRegistryKeys.CAPYBARA_VARIANT, Promenade.id(path)); } - public static Optional> select(Random random, DynamicRegistryManager registries, SpawnContext context) { - return VariantSelectorProvider.select(registries.getOrThrow(PromenadeRegistryKeys.CAPYBARA_VARIANT).streamEntries(), RegistryEntry::value, random, context); + public static Optional> select(RandomSource random, RegistryAccess registries, SpawnContext context) { + return PriorityProvider.pick(registries.lookupOrThrow(PromenadeRegistryKeys.CAPYBARA_VARIANT).listElements(), Holder::value, random, context); } } diff --git a/src/main/java/fr/hugman/promenade/entity/variant/DuckVariant.java b/src/main/java/fr/hugman/promenade/entity/variant/DuckVariant.java index 676f798e..6abc82c5 100644 --- a/src/main/java/fr/hugman/promenade/entity/variant/DuckVariant.java +++ b/src/main/java/fr/hugman/promenade/entity/variant/DuckVariant.java @@ -4,46 +4,47 @@ import com.mojang.serialization.codecs.RecordCodecBuilder; import fr.hugman.promenade.Promenade; import fr.hugman.promenade.registry.PromenadeRegistryKeys; -import net.minecraft.entity.VariantSelectorProvider; -import net.minecraft.entity.spawn.SpawnCondition; -import net.minecraft.entity.spawn.SpawnConditionSelectors; -import net.minecraft.entity.spawn.SpawnContext; -import net.minecraft.network.RegistryByteBuf; -import net.minecraft.network.codec.PacketCodec; -import net.minecraft.network.codec.PacketCodecs; -import net.minecraft.registry.entry.RegistryEntry; -import net.minecraft.registry.entry.RegistryFixedCodec; -import net.minecraft.util.AssetInfo.TextureAssetInfo; - import java.util.List; +import net.minecraft.core.ClientAsset.ResourceTexture; +import net.minecraft.core.Holder; +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.ByteBufCodecs; +import net.minecraft.network.codec.StreamCodec; +import net.minecraft.resources.RegistryFixedCodec; +import net.minecraft.world.entity.variant.PriorityProvider; +import net.minecraft.world.entity.variant.SpawnCondition; +import net.minecraft.world.entity.variant.SpawnContext; +import net.minecraft.world.entity.variant.SpawnPrioritySelectors; +import org.jspecify.annotations.NonNull; public record DuckVariant( - TextureAssetInfo texture, - TextureAssetInfo babyTexture, - SpawnConditionSelectors spawnConditions -) implements VariantSelectorProvider { - public static final TextureAssetInfo DEFAULT_DUCKLING_ASSET = new TextureAssetInfo(Promenade.id("entity/duck/duckling")); + ResourceTexture texture, + ResourceTexture babyTexture, + SpawnPrioritySelectors spawnConditions +) implements PriorityProvider { + public static final ResourceTexture DEFAULT_DUCKLING_ASSET = new ResourceTexture(Promenade.id("entity/duck/duckling")); public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( - TextureAssetInfo.MAP_CODEC.forGetter(DuckVariant::texture), - TextureAssetInfo.CODEC.optionalFieldOf("baby_texture", DEFAULT_DUCKLING_ASSET).forGetter(DuckVariant::babyTexture), - SpawnConditionSelectors.CODEC.fieldOf("spawn_conditions").forGetter(DuckVariant::spawnConditions) + ResourceTexture.DEFAULT_FIELD_CODEC.forGetter(DuckVariant::texture), + ResourceTexture.CODEC.optionalFieldOf("baby_asset_id", DEFAULT_DUCKLING_ASSET).forGetter(DuckVariant::babyTexture), + SpawnPrioritySelectors.CODEC.fieldOf("spawn_conditions").forGetter(DuckVariant::spawnConditions) ).apply(instance, DuckVariant::new)); public static final Codec NETWORK_CODEC = RecordCodecBuilder.create(instance -> instance.group( - TextureAssetInfo.MAP_CODEC.forGetter(DuckVariant::texture), - TextureAssetInfo.CODEC.optionalFieldOf("baby_texture", DEFAULT_DUCKLING_ASSET).forGetter(DuckVariant::babyTexture) + ResourceTexture.DEFAULT_FIELD_CODEC.forGetter(DuckVariant::texture), + ResourceTexture.CODEC.optionalFieldOf("baby_asset_id", DEFAULT_DUCKLING_ASSET).forGetter(DuckVariant::babyTexture) ).apply(instance, DuckVariant::new)); - public static final Codec> ENTRY_CODEC = RegistryFixedCodec.of(PromenadeRegistryKeys.DUCK_VARIANT); - public static final PacketCodec> ENTRY_PACKET_CODEC = PacketCodecs.registryEntry(PromenadeRegistryKeys.DUCK_VARIANT); + public static final Codec> ENTRY_CODEC = RegistryFixedCodec.create(PromenadeRegistryKeys.DUCK_VARIANT); + public static final StreamCodec> ENTRY_PACKET_CODEC = ByteBufCodecs.holderRegistry(PromenadeRegistryKeys.DUCK_VARIANT); - public DuckVariant(TextureAssetInfo texture, TextureAssetInfo babyTexture) { - this(texture, babyTexture, SpawnConditionSelectors.EMPTY); + public DuckVariant(ResourceTexture texture, ResourceTexture babyTexture) { + this(texture, babyTexture, SpawnPrioritySelectors.EMPTY); } @Override - public List> getSelectors() { + @NonNull + public List> selectors() { return this.spawnConditions.selectors(); } } diff --git a/src/main/java/fr/hugman/promenade/entity/variant/DuckVariants.java b/src/main/java/fr/hugman/promenade/entity/variant/DuckVariants.java index dffe0481..57aa7d05 100644 --- a/src/main/java/fr/hugman/promenade/entity/variant/DuckVariants.java +++ b/src/main/java/fr/hugman/promenade/entity/variant/DuckVariants.java @@ -2,31 +2,30 @@ import fr.hugman.promenade.Promenade; import fr.hugman.promenade.registry.PromenadeRegistryKeys; -import net.minecraft.entity.VariantSelectorProvider; -import net.minecraft.entity.spawn.SpawnContext; -import net.minecraft.registry.DynamicRegistryManager; -import net.minecraft.registry.RegistryKey; -import net.minecraft.registry.entry.RegistryEntry; -import net.minecraft.util.Identifier; -import net.minecraft.util.math.random.Random; - import java.util.Optional; +import net.minecraft.core.Holder; +import net.minecraft.core.RegistryAccess; +import net.minecraft.resources.Identifier; +import net.minecraft.resources.ResourceKey; +import net.minecraft.util.RandomSource; +import net.minecraft.world.entity.variant.PriorityProvider; +import net.minecraft.world.entity.variant.SpawnContext; public class DuckVariants { - public static final RegistryKey PEKIN = of("pekin"); - public static final RegistryKey MALLARD = of("mallard"); + public static final ResourceKey PEKIN = of("pekin"); + public static final ResourceKey MALLARD = of("mallard"); - public static final RegistryKey DEFAULT = PEKIN; + public static final ResourceKey DEFAULT = PEKIN; - private static RegistryKey of(String path) { + private static ResourceKey of(String path) { return of(Promenade.id(path)); } - public static RegistryKey of(Identifier id) { - return RegistryKey.of(PromenadeRegistryKeys.DUCK_VARIANT, id); + public static ResourceKey of(Identifier id) { + return ResourceKey.create(PromenadeRegistryKeys.DUCK_VARIANT, id); } - public static Optional> select(Random random, DynamicRegistryManager registries, SpawnContext context) { - return VariantSelectorProvider.select(registries.getOrThrow(PromenadeRegistryKeys.DUCK_VARIANT).streamEntries(), RegistryEntry::value, random, context); + public static Optional> select(RandomSource random, RegistryAccess registries, SpawnContext context) { + return PriorityProvider.pick(registries.lookupOrThrow(PromenadeRegistryKeys.DUCK_VARIANT).listElements(), Holder::value, random, context); } } diff --git a/src/main/java/fr/hugman/promenade/entity/variant/PromenadePaintingVariants.java b/src/main/java/fr/hugman/promenade/entity/variant/PromenadePaintingVariants.java index b7f22962..ee4a59c7 100644 --- a/src/main/java/fr/hugman/promenade/entity/variant/PromenadePaintingVariants.java +++ b/src/main/java/fr/hugman/promenade/entity/variant/PromenadePaintingVariants.java @@ -1,15 +1,15 @@ package fr.hugman.promenade.entity.variant; import fr.hugman.promenade.Promenade; -import net.minecraft.entity.decoration.painting.PaintingVariant; -import net.minecraft.registry.RegistryKey; -import net.minecraft.registry.RegistryKeys; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.entity.decoration.painting.PaintingVariant; public class PromenadePaintingVariants { - public static final RegistryKey OPTIMISM = of("optimism"); - public static final RegistryKey NURTURE = of("nurture"); + public static final ResourceKey OPTIMISM = of("optimism"); + public static final ResourceKey NURTURE = of("nurture"); - public static RegistryKey of(String path) { - return RegistryKey.of(RegistryKeys.PAINTING_VARIANT, Promenade.id(path)); + public static ResourceKey of(String path) { + return ResourceKey.create(Registries.PAINTING_VARIANT, Promenade.id(path)); } } diff --git a/src/main/java/fr/hugman/promenade/entity/variant/PromenadeWolfVariants.java b/src/main/java/fr/hugman/promenade/entity/variant/PromenadeWolfVariants.java index 4a031d1c..99a07bc0 100644 --- a/src/main/java/fr/hugman/promenade/entity/variant/PromenadeWolfVariants.java +++ b/src/main/java/fr/hugman/promenade/entity/variant/PromenadeWolfVariants.java @@ -1,14 +1,14 @@ package fr.hugman.promenade.entity.variant; import fr.hugman.promenade.Promenade; -import net.minecraft.entity.passive.WolfVariant; -import net.minecraft.registry.RegistryKey; -import net.minecraft.registry.RegistryKeys; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.entity.animal.wolf.WolfVariant; public class PromenadeWolfVariants { - public static final RegistryKey SHIBA_INU = of("shiba_inu"); + public static final ResourceKey SHIBA_INU = of("shiba_inu"); - public static RegistryKey of(String path) { - return RegistryKey.of(RegistryKeys.WOLF_VARIANT, Promenade.id(path)); + public static ResourceKey of(String path) { + return ResourceKey.create(Registries.WOLF_VARIANT, Promenade.id(path)); } } diff --git a/src/main/java/fr/hugman/promenade/entity/variant/SunkenVariant.java b/src/main/java/fr/hugman/promenade/entity/variant/SunkenVariant.java index a8f9f633..90631506 100644 --- a/src/main/java/fr/hugman/promenade/entity/variant/SunkenVariant.java +++ b/src/main/java/fr/hugman/promenade/entity/variant/SunkenVariant.java @@ -3,47 +3,46 @@ import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; import fr.hugman.promenade.registry.PromenadeRegistryKeys; -import net.minecraft.entity.VariantSelectorProvider; -import net.minecraft.entity.spawn.SpawnCondition; -import net.minecraft.entity.spawn.SpawnConditionSelectors; -import net.minecraft.entity.spawn.SpawnContext; -import net.minecraft.loot.LootTable; -import net.minecraft.network.RegistryByteBuf; -import net.minecraft.network.codec.PacketCodec; -import net.minecraft.network.codec.PacketCodecs; -import net.minecraft.registry.RegistryKey; -import net.minecraft.registry.RegistryKeys; -import net.minecraft.registry.entry.RegistryEntry; -import net.minecraft.registry.entry.RegistryFixedCodec; -import net.minecraft.util.AssetInfo.TextureAssetInfo; - import java.util.List; +import net.minecraft.core.ClientAsset.ResourceTexture; +import net.minecraft.core.Holder; +import net.minecraft.core.registries.Registries; +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.ByteBufCodecs; +import net.minecraft.network.codec.StreamCodec; +import net.minecraft.resources.RegistryFixedCodec; +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.entity.variant.PriorityProvider; +import net.minecraft.world.entity.variant.SpawnCondition; +import net.minecraft.world.entity.variant.SpawnContext; +import net.minecraft.world.entity.variant.SpawnPrioritySelectors; +import net.minecraft.world.level.storage.loot.LootTable; public record SunkenVariant( - TextureAssetInfo texture, - RegistryKey lootTable, - SpawnConditionSelectors spawnConditions -) implements VariantSelectorProvider { + ResourceTexture texture, + ResourceKey lootTable, + SpawnPrioritySelectors spawnConditions +) implements PriorityProvider { public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( - TextureAssetInfo.MAP_CODEC.forGetter(SunkenVariant::texture), - RegistryKey.createCodec(RegistryKeys.LOOT_TABLE).fieldOf("loot_table").forGetter(SunkenVariant::lootTable), - SpawnConditionSelectors.CODEC.fieldOf("spawn_conditions").forGetter(SunkenVariant::spawnConditions) + ResourceTexture.DEFAULT_FIELD_CODEC.forGetter(SunkenVariant::texture), + ResourceKey.codec(Registries.LOOT_TABLE).fieldOf("loot_table").forGetter(SunkenVariant::lootTable), + SpawnPrioritySelectors.CODEC.fieldOf("spawn_conditions").forGetter(SunkenVariant::spawnConditions) ).apply(instance, SunkenVariant::new)); public static final Codec NETWORK_CODEC = RecordCodecBuilder.create(instance -> instance.group( - TextureAssetInfo.MAP_CODEC.forGetter(SunkenVariant::texture), - RegistryKey.createCodec(RegistryKeys.LOOT_TABLE).fieldOf("loot_table").forGetter(SunkenVariant::lootTable) + ResourceTexture.DEFAULT_FIELD_CODEC.forGetter(SunkenVariant::texture), + ResourceKey.codec(Registries.LOOT_TABLE).fieldOf("loot_table").forGetter(SunkenVariant::lootTable) ).apply(instance, SunkenVariant::new)); - public static final Codec> ENTRY_CODEC = RegistryFixedCodec.of(PromenadeRegistryKeys.SUNKEN_VARIANT); - public static final PacketCodec> ENTRY_PACKET_CODEC = PacketCodecs.registryEntry(PromenadeRegistryKeys.SUNKEN_VARIANT); + public static final Codec> ENTRY_CODEC = RegistryFixedCodec.create(PromenadeRegistryKeys.SUNKEN_VARIANT); + public static final StreamCodec> ENTRY_PACKET_CODEC = ByteBufCodecs.holderRegistry(PromenadeRegistryKeys.SUNKEN_VARIANT); - public SunkenVariant(TextureAssetInfo texture, RegistryKey lootTable) { - this(texture, lootTable, SpawnConditionSelectors.EMPTY); + public SunkenVariant(ResourceTexture texture, ResourceKey lootTable) { + this(texture, lootTable, SpawnPrioritySelectors.EMPTY); } @Override - public List> getSelectors() { + public List> selectors() { return this.spawnConditions.selectors(); } } diff --git a/src/main/java/fr/hugman/promenade/entity/variant/SunkenVariants.java b/src/main/java/fr/hugman/promenade/entity/variant/SunkenVariants.java index bad75309..c519efde 100644 --- a/src/main/java/fr/hugman/promenade/entity/variant/SunkenVariants.java +++ b/src/main/java/fr/hugman/promenade/entity/variant/SunkenVariants.java @@ -2,34 +2,33 @@ import fr.hugman.promenade.Promenade; import fr.hugman.promenade.registry.PromenadeRegistryKeys; -import net.minecraft.entity.VariantSelectorProvider; -import net.minecraft.entity.spawn.SpawnContext; -import net.minecraft.registry.DynamicRegistryManager; -import net.minecraft.registry.RegistryKey; -import net.minecraft.registry.entry.RegistryEntry; -import net.minecraft.util.Identifier; -import net.minecraft.util.math.random.Random; - import java.util.Optional; +import net.minecraft.core.Holder; +import net.minecraft.core.RegistryAccess; +import net.minecraft.resources.Identifier; +import net.minecraft.resources.ResourceKey; +import net.minecraft.util.RandomSource; +import net.minecraft.world.entity.variant.PriorityProvider; +import net.minecraft.world.entity.variant.SpawnContext; public class SunkenVariants { - public static final RegistryKey TUBE = of("tube"); - public static final RegistryKey BRAIN = of("brain"); - public static final RegistryKey BUBBLE = of("bubble"); - public static final RegistryKey FIRE = of("fire"); - public static final RegistryKey HORN = of("horn"); + public static final ResourceKey TUBE = of("tube"); + public static final ResourceKey BRAIN = of("brain"); + public static final ResourceKey BUBBLE = of("bubble"); + public static final ResourceKey FIRE = of("fire"); + public static final ResourceKey HORN = of("horn"); - public static final RegistryKey DEFAULT = TUBE; + public static final ResourceKey DEFAULT = TUBE; - private static RegistryKey of(String path) { + private static ResourceKey of(String path) { return of(Promenade.id(path)); } - public static RegistryKey of(Identifier id) { - return RegistryKey.of(PromenadeRegistryKeys.SUNKEN_VARIANT, id); + public static ResourceKey of(Identifier id) { + return ResourceKey.create(PromenadeRegistryKeys.SUNKEN_VARIANT, id); } - public static Optional> select(Random random, DynamicRegistryManager registries, SpawnContext context) { - return VariantSelectorProvider.select(registries.getOrThrow(PromenadeRegistryKeys.SUNKEN_VARIANT).streamEntries(), RegistryEntry::value, random, context); + public static Optional> select(RandomSource random, RegistryAccess registries, SpawnContext context) { + return PriorityProvider.pick(registries.lookupOrThrow(PromenadeRegistryKeys.SUNKEN_VARIANT).listElements(), Holder::value, random, context); } } diff --git a/src/main/java/fr/hugman/promenade/item/ItemSettings.java b/src/main/java/fr/hugman/promenade/item/ItemSettings.java index 78fe503e..4668a1a4 100644 --- a/src/main/java/fr/hugman/promenade/item/ItemSettings.java +++ b/src/main/java/fr/hugman/promenade/item/ItemSettings.java @@ -1,24 +1,24 @@ package fr.hugman.promenade.item; -import net.minecraft.component.type.ConsumableComponent; -import net.minecraft.component.type.FoodComponent; -import net.minecraft.item.Item; -import net.minecraft.item.Items; +import net.minecraft.world.food.FoodProperties; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.Items; +import net.minecraft.world.item.component.Consumable; public final class ItemSettings { - public static Item.Settings max1() { - return new Item.Settings().maxCount(1); + public static Item.Properties max1() { + return new Item.Properties().stacksTo(1); } - public static Item.Settings max16() { - return new Item.Settings().maxCount(16); + public static Item.Properties max16() { + return new Item.Properties().stacksTo(16); } - public static Item.Settings stackableDrink(FoodComponent foodComponent, ConsumableComponent consumableComponent) { - return new Item.Settings() - .recipeRemainder(Items.GLASS_BOTTLE) + public static Item.Properties stackableDrink(FoodProperties foodComponent, Consumable consumableComponent) { + return new Item.Properties() + .craftRemainder(Items.GLASS_BOTTLE) .food(foodComponent, consumableComponent) - .useRemainder(Items.GLASS_BOTTLE) - .maxCount(16); + .usingConvertsTo(Items.GLASS_BOTTLE) + .stacksTo(16); } } diff --git a/src/main/java/fr/hugman/promenade/item/PromenadeItemKeys.java b/src/main/java/fr/hugman/promenade/item/PromenadeItemKeys.java index fb27ff3b..7ef72fef 100644 --- a/src/main/java/fr/hugman/promenade/item/PromenadeItemKeys.java +++ b/src/main/java/fr/hugman/promenade/item/PromenadeItemKeys.java @@ -1,14 +1,14 @@ package fr.hugman.promenade.item; import fr.hugman.promenade.Promenade; -import net.minecraft.item.Item; -import net.minecraft.registry.RegistryKey; -import net.minecraft.registry.RegistryKeys; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.item.Item; public class PromenadeItemKeys { - public static final RegistryKey BLUEBERRIES = of("blueberries"); + public static final ResourceKey BLUEBERRIES = of("blueberries"); - private static RegistryKey of(String path) { - return RegistryKey.of(RegistryKeys.ITEM, Promenade.id(path)); + private static ResourceKey of(String path) { + return ResourceKey.create(Registries.ITEM, Promenade.id(path)); } } diff --git a/src/main/java/fr/hugman/promenade/item/PromenadeItems.java b/src/main/java/fr/hugman/promenade/item/PromenadeItems.java index 036d6de6..da118b7d 100644 --- a/src/main/java/fr/hugman/promenade/item/PromenadeItems.java +++ b/src/main/java/fr/hugman/promenade/item/PromenadeItems.java @@ -7,16 +7,16 @@ import fr.hugman.promenade.component.PromenadeFoodComponents; import fr.hugman.promenade.entity.PromenadeEntityTypes; import fr.hugman.promenade.item.helper.ItemFactory; -import net.minecraft.block.Block; -import net.minecraft.component.DataComponentTypes; -import net.minecraft.item.Item; -import net.minecraft.registry.Registries; -import net.minecraft.registry.Registry; -import net.minecraft.registry.RegistryKey; -import net.minecraft.registry.RegistryKeys; - import java.util.function.BiFunction; import java.util.function.Function; +import net.minecraft.core.Registry; +import net.minecraft.core.component.DataComponents; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceKey; +import net.minecraft.tags.BannerPatternTags; +import net.minecraft.world.item.Item; +import net.minecraft.world.level.block.Block; public class PromenadeItems { public static final Item SAKURA_SIGN = register(PromenadeBlocks.SAKURA_SIGN, ItemFactory.sign(PromenadeBlocks.SAKURA_WALL_SIGN), ItemSettings.max16()); @@ -38,48 +38,48 @@ public class PromenadeItems { public static final Item DARK_AMARANTH_SIGN = register(PromenadeBlocks.DARK_AMARANTH_SIGN, ItemFactory.sign(PromenadeBlocks.DARK_AMARANTH_WALL_SIGN), ItemSettings.max16()); public static final Item DARK_AMARANTH_HANGING_SIGN = register(PromenadeBlocks.DARK_AMARANTH_HANGING_SIGN, ItemFactory.hangingSign(PromenadeBlocks.DARK_AMARANTH_WALL_HANGING_SIGN), ItemSettings.max16()); - public static final Item BLUEBERRIES = register(PromenadeItemKeys.BLUEBERRIES, ItemFactory.uniqueNameBlock(PromenadeBlocks.BLUEBERRY_BUSH), new Item.Settings().food(PromenadeFoodComponents.BLUEBERRIES)); + public static final Item BLUEBERRIES = register(PromenadeItemKeys.BLUEBERRIES, ItemFactory.uniqueNameBlock(PromenadeBlocks.BLUEBERRY_BUSH), new Item.Properties().food(PromenadeFoodComponents.BLUEBERRIES)); - public static final Item BANANA = register("banana", new Item.Settings().food(PromenadeFoodComponents.BANANA)); - public static final Item APRICOT = register("apricot", new Item.Settings().food(PromenadeFoodComponents.APRICOT)); - public static final Item MANGO = register("mango", new Item.Settings().food(PromenadeFoodComponents.MANGO)); + public static final Item BANANA = register("banana", new Item.Properties().food(PromenadeFoodComponents.BANANA)); + public static final Item APRICOT = register("apricot", new Item.Properties().food(PromenadeFoodComponents.APRICOT)); + public static final Item MANGO = register("mango", new Item.Properties().food(PromenadeFoodComponents.MANGO)); - public static final Item DUCK = register("duck", new Item.Settings().food(PromenadeFoodComponents.RAW_DUCK, PromenadeConsumableComponents.RAW_DUCK)); - public static final Item COOKED_DUCK = register("cooked_duck", new Item.Settings().food(PromenadeFoodComponents.COOKED_DUCK)); + public static final Item DUCK = register("duck", new Item.Properties().food(PromenadeFoodComponents.RAW_DUCK, PromenadeConsumableComponents.RAW_DUCK)); + public static final Item COOKED_DUCK = register("cooked_duck", new Item.Properties().food(PromenadeFoodComponents.COOKED_DUCK)); - public static final Item BOVINE_BANNER_PATTERN = register("bovine_banner_pattern", ItemSettings.max1().component(DataComponentTypes.PROVIDES_BANNER_PATTERNS, PromenadeBannerPatternTags.BOVINE_PATTERN_ITEM)); + public static final Item BOVINE_BANNER_PATTERN = register("bovine_banner_pattern", ItemSettings.max1().delayedComponent(DataComponents.PROVIDES_BANNER_PATTERNS, context -> context.getOrThrow(PromenadeBannerPatternTags.BOVINE_PATTERN_ITEM))); public static final Item CAPYBARA_SPAWN_EGG = register("capybara_spawn_egg", ItemFactory.spawnEgg(PromenadeEntityTypes.CAPYBARA)); public static final Item DUCK_SPAWN_EGG = register("duck_spawn_egg", ItemFactory.spawnEgg(PromenadeEntityTypes.DUCK)); public static final Item LUSH_CREEPER_SPAWN_EGG = register("lush_creeper_spawn_egg", ItemFactory.spawnEgg(PromenadeEntityTypes.LUSH_CREEPER)); public static final Item SUNKEN_SPAWN_EGG = register("sunken_spawn_egg", ItemFactory.spawnEgg(PromenadeEntityTypes.SUNKEN)); - private static RegistryKey keyOf(String path) { - return RegistryKey.of(RegistryKeys.ITEM, Promenade.id(path)); + private static ResourceKey keyOf(String path) { + return ResourceKey.create(Registries.ITEM, Promenade.id(path)); } - private static RegistryKey keyOf(RegistryKey blockKey) { - return RegistryKey.of(RegistryKeys.ITEM, blockKey.getValue()); + private static ResourceKey keyOf(ResourceKey blockKey) { + return ResourceKey.create(Registries.ITEM, blockKey.identifier()); } - public static O register(Block block, BiFunction factory, Item.Settings settings) { - return register(keyOf(block.getRegistryEntry().registryKey()), itemSettings -> factory.apply(block, itemSettings), settings.useBlockPrefixedTranslationKey()); + public static O register(Block block, BiFunction factory, Item.Properties settings) { + return register(keyOf(block.builtInRegistryHolder().key()), itemSettings -> factory.apply(block, itemSettings), settings.useBlockDescriptionPrefix()); } - public static O register(RegistryKey key, Function factory, Item.Settings settings) { - O item = factory.apply(settings.registryKey(key)); - return Registry.register(Registries.ITEM, key, item); + public static O register(ResourceKey key, Function factory, Item.Properties settings) { + O item = factory.apply(settings.setId(key)); + return Registry.register(BuiltInRegistries.ITEM, key, item); } - public static O register(String id, Function factory, Item.Settings settings) { + public static O register(String id, Function factory, Item.Properties settings) { return register(keyOf(id), factory, settings); } - public static O register(String id, Function factory) { - return register(keyOf(id), factory, new Item.Settings()); + public static O register(String id, Function factory) { + return register(keyOf(id), factory, new Item.Properties()); } - public static Item register(String id, Item.Settings settings) { + public static Item register(String id, Item.Properties settings) { return register(keyOf(id), Item::new, settings); } } diff --git a/src/main/java/fr/hugman/promenade/item/helper/ItemFactory.java b/src/main/java/fr/hugman/promenade/item/helper/ItemFactory.java index 6f0aa80c..50417577 100644 --- a/src/main/java/fr/hugman/promenade/item/helper/ItemFactory.java +++ b/src/main/java/fr/hugman/promenade/item/helper/ItemFactory.java @@ -1,32 +1,36 @@ package fr.hugman.promenade.item.helper; -import net.minecraft.block.Block; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.mob.MobEntity; -import net.minecraft.entity.vehicle.AbstractBoatEntity; -import net.minecraft.item.*; - +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.Mob; +import net.minecraft.world.entity.vehicle.boat.AbstractBoat; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.BoatItem; +import net.minecraft.world.item.HangingSignItem; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.SignItem; +import net.minecraft.world.item.SpawnEggItem; +import net.minecraft.world.level.block.Block; import java.util.function.BiFunction; import java.util.function.Function; public final class ItemFactory { - public static Function uniqueNameBlock(Block block) { - return settings -> new BlockItem(block, settings.useItemPrefixedTranslationKey()); + public static Function uniqueNameBlock(Block block) { + return settings -> new BlockItem(block, settings.useItemDescriptionPrefix()); } - public static BiFunction sign(Block wallSignBlock) { + public static BiFunction sign(Block wallSignBlock) { return (block, settings) -> new SignItem(block, wallSignBlock, settings); } - public static BiFunction hangingSign(Block wallSignBlock) { + public static BiFunction hangingSign(Block wallSignBlock) { return (block, settings) -> new HangingSignItem(block, wallSignBlock, settings); } - public static Function spawnEgg(EntityType entityType) { + public static Function spawnEgg(EntityType entityType) { return s -> new SpawnEggItem(s.spawnEgg(entityType)); } - public static Function boat(EntityType boatEntity) { + public static Function boat(EntityType boatEntity) { return s -> new BoatItem(boatEntity, s); } } diff --git a/src/main/java/fr/hugman/promenade/itemgroup/PromenadeItemGroup.java b/src/main/java/fr/hugman/promenade/itemgroup/PromenadeItemGroup.java index a55ee727..30bfc8cd 100644 --- a/src/main/java/fr/hugman/promenade/itemgroup/PromenadeItemGroup.java +++ b/src/main/java/fr/hugman/promenade/itemgroup/PromenadeItemGroup.java @@ -1,67 +1,66 @@ package fr.hugman.promenade.itemgroup; import fr.hugman.promenade.Promenade; -import net.minecraft.component.DataComponentTypes; -import net.minecraft.entity.decoration.painting.PaintingVariant; -import net.minecraft.item.ItemGroup; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemStackSet; -import net.minecraft.item.Items; -import net.minecraft.registry.Registries; -import net.minecraft.registry.RegistryKey; -import net.minecraft.registry.RegistryKeys; -import net.minecraft.registry.entry.RegistryEntry; - import java.util.Comparator; import java.util.Set; +import net.minecraft.core.Holder; +import net.minecraft.core.component.DataComponents; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.entity.decoration.painting.PaintingVariant; +import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.ItemStackLinkedSet; +import net.minecraft.world.item.Items; public final class PromenadeItemGroup { - public static void fill(ItemGroup.DisplayContext displayContext, ItemGroup.Entries entries) { - Set set = ItemStackSet.create(); + public static void fill(CreativeModeTab.ItemDisplayParameters displayContext, CreativeModeTab.Output entries) { + Set set = ItemStackLinkedSet.createTypeAndComponentsSet(); - for (ItemGroup itemGroup : Registries.ITEM_GROUP) { - if (itemGroup.getType() != ItemGroup.Type.SEARCH) { - for (var stack : itemGroup.getSearchTabStacks()) { - if (isPromenade(Registries.ITEM.getEntry(stack.getItem()))) { + for (CreativeModeTab itemGroup : BuiltInRegistries.CREATIVE_MODE_TAB) { + if (itemGroup.getType() != CreativeModeTab.Type.SEARCH) { + for (var stack : itemGroup.getSearchTabDisplayItems()) { + if (isPromenade(BuiltInRegistries.ITEM.wrapAsHolder(stack.getItem()))) { set.add(stack); } } } } - entries.addAll(set); + entries.acceptAll(set); // Vanilla Entity Variants //TODO: add spawn eggs // Paintings - displayContext.lookup() - .getOptional(RegistryKeys.PAINTING_VARIANT) - .ifPresent(registryWrapper -> registryWrapper.streamEntries() + displayContext.holders() + .lookup(Registries.PAINTING_VARIANT) + .ifPresent(registryWrapper -> registryWrapper.listElements() .filter(PromenadeItemGroup::isPromenade) .sorted(PAINTING_VARIANT_COMPARATOR) .forEach( paintingVariantEntry -> { ItemStack itemStack = new ItemStack(Items.PAINTING); - itemStack.set(DataComponentTypes.PAINTING_VARIANT, paintingVariantEntry); - entries.add(itemStack, ItemGroup.StackVisibility.PARENT_AND_SEARCH_TABS); + itemStack.set(DataComponents.PAINTING_VARIANT, paintingVariantEntry); + entries.accept(itemStack, CreativeModeTab.TabVisibility.PARENT_AND_SEARCH_TABS); } ) ); } - private static boolean isPromenade(RegistryEntry entry) { - return isPromenade(entry.getKey().orElseThrow()); + private static boolean isPromenade(Holder entry) { + return isPromenade(entry.unwrapKey().orElseThrow()); } - private static boolean isPromenade(RegistryKey key) { - return key.getValue().getNamespace().equals(Promenade.MOD_ID); + private static boolean isPromenade(ResourceKey key) { + return key.identifier().getNamespace().equals(Promenade.MOD_ID); } // FROM Vanilla ItemGroups - private static final Comparator> PAINTING_VARIANT_COMPARATOR = Comparator.comparing( - RegistryEntry::value, Comparator.comparingInt(PaintingVariant::getArea).thenComparing(PaintingVariant::width) + private static final Comparator> PAINTING_VARIANT_COMPARATOR = Comparator.comparing( + Holder::value, Comparator.comparingInt(PaintingVariant::area).thenComparing(PaintingVariant::width) ); } diff --git a/src/main/java/fr/hugman/promenade/itemgroup/PromenadeItemGroupAdditions.java b/src/main/java/fr/hugman/promenade/itemgroup/PromenadeItemGroupAdditions.java index da400a4f..11df093b 100644 --- a/src/main/java/fr/hugman/promenade/itemgroup/PromenadeItemGroupAdditions.java +++ b/src/main/java/fr/hugman/promenade/itemgroup/PromenadeItemGroupAdditions.java @@ -2,14 +2,15 @@ import fr.hugman.promenade.block.PromenadeBlocks; import fr.hugman.promenade.item.PromenadeItems; -import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents; -import net.minecraft.block.Blocks; -import net.minecraft.item.*; +import net.fabricmc.fabric.api.creativetab.v1.CreativeModeTabEvents; +import net.minecraft.world.item.CreativeModeTabs; +import net.minecraft.world.item.Items; +import net.minecraft.world.level.block.Blocks; public class PromenadeItemGroupAdditions { public static void appendItemGroups() { - ItemGroupEvents.modifyEntriesEvent(ItemGroups.NATURAL).register(e -> e.addAfter(Blocks.ANDESITE, PromenadeBlocks.BLUNITE, PromenadeBlocks.ASPHALT)); - ItemGroupEvents.modifyEntriesEvent(ItemGroups.BUILDING_BLOCKS).register(e -> e.addAfter(Blocks.POLISHED_ANDESITE_SLAB, + CreativeModeTabEvents.modifyOutputEvent(CreativeModeTabs.NATURAL_BLOCKS).register(e -> e.insertAfter(Blocks.ANDESITE, PromenadeBlocks.BLUNITE, PromenadeBlocks.ASPHALT)); + CreativeModeTabEvents.modifyOutputEvent(CreativeModeTabs.BUILDING_BLOCKS).register(e -> e.insertAfter(Blocks.POLISHED_ANDESITE_SLAB, PromenadeBlocks.BLUNITE, PromenadeBlocks.BLUNITE_SLAB, PromenadeBlocks.BLUNITE_STAIRS, PromenadeBlocks.BLUNITE_WALL, PromenadeBlocks.POLISHED_BLUNITE, PromenadeBlocks.POLISHED_BLUNITE_SLAB, PromenadeBlocks.POLISHED_BLUNITE_STAIRS, PromenadeBlocks.ASPHALT, PromenadeBlocks.ASPHALT_SLAB, PromenadeBlocks.ASPHALT_STAIRS, PromenadeBlocks.ASPHALT_WALL, @@ -18,8 +19,8 @@ public static void appendItemGroups() { // VANILLA PILES - ItemGroupEvents.modifyEntriesEvent(ItemGroups.NATURAL).register(e -> { - e.addAfter(PromenadeBlocks.FALLEN_MIKADO_MAPLE_LEAVES, + CreativeModeTabEvents.modifyOutputEvent(CreativeModeTabs.NATURAL_BLOCKS).register(e -> { + e.insertAfter(PromenadeBlocks.FALLEN_MIKADO_MAPLE_LEAVES, PromenadeBlocks.OAK_LEAF_PILE, PromenadeBlocks.SPRUCE_LEAF_PILE, PromenadeBlocks.BIRCH_LEAF_PILE, @@ -33,7 +34,7 @@ public static void appendItemGroups() { PromenadeBlocks.FLOWERING_AZALEA_LEAF_PILE ); - e.addAfter(Blocks.LILY_OF_THE_VALLEY, + e.insertAfter(Blocks.LILY_OF_THE_VALLEY, PromenadeBlocks.DANDELION_PILE, PromenadeBlocks.POPPY_PILE, PromenadeBlocks.BLUE_ORCHID_PILE, @@ -46,26 +47,27 @@ public static void appendItemGroups() { PromenadeBlocks.OXEYE_DAISY_PILE, PromenadeBlocks.CORNFLOWER_PILE, PromenadeBlocks.LILY_OF_THE_VALLEY_PILE); - e.addAfter(Blocks.WITHER_ROSE, PromenadeBlocks.WITHER_ROSE_PILE); + e.insertAfter(Blocks.WITHER_ROSE, PromenadeBlocks.WITHER_ROSE_PILE); }); // VANILLA SNOWY LEAVES - ItemGroupEvents.modifyEntriesEvent(ItemGroups.NATURAL).register(e -> { - e.addAfter(Blocks.OAK_LEAVES, PromenadeBlocks.SNOWY_OAK_LEAVES); - e.addAfter(Blocks.SPRUCE_LEAVES, PromenadeBlocks.SNOWY_SPRUCE_LEAVES); - e.addAfter(Blocks.BIRCH_LEAVES, PromenadeBlocks.SNOWY_BIRCH_LEAVES); - e.addAfter(Blocks.JUNGLE_LEAVES, PromenadeBlocks.SNOWY_JUNGLE_LEAVES); - e.addAfter(Blocks.ACACIA_LEAVES, PromenadeBlocks.SNOWY_ACACIA_LEAVES); - e.addAfter(Blocks.CHERRY_LEAVES, PromenadeBlocks.SNOWY_CHERRY_LEAVES); - e.addAfter(Blocks.DARK_OAK_LEAVES, PromenadeBlocks.SNOWY_DARK_OAK_LEAVES); - e.addAfter(Blocks.PALE_OAK_LEAVES, PromenadeBlocks.SNOWY_PALE_OAK_LEAVES); - e.addAfter(Blocks.MANGROVE_LEAVES, PromenadeBlocks.SNOWY_MANGROVE_LEAVES); - e.addAfter(Blocks.AZALEA_LEAVES, PromenadeBlocks.SNOWY_AZALEA_LEAVES); - e.addAfter(Blocks.FLOWERING_AZALEA_LEAVES, PromenadeBlocks.SNOWY_FLOWERING_AZALEA_LEAVES); + + CreativeModeTabEvents.modifyOutputEvent(CreativeModeTabs.NATURAL_BLOCKS).register(e -> { + e.insertAfter(Blocks.OAK_LEAVES, PromenadeBlocks.SNOWY_OAK_LEAVES); + e.insertAfter(Blocks.SPRUCE_LEAVES, PromenadeBlocks.SNOWY_SPRUCE_LEAVES); + e.insertAfter(Blocks.BIRCH_LEAVES, PromenadeBlocks.SNOWY_BIRCH_LEAVES); + e.insertAfter(Blocks.JUNGLE_LEAVES, PromenadeBlocks.SNOWY_JUNGLE_LEAVES); + e.insertAfter(Blocks.ACACIA_LEAVES, PromenadeBlocks.SNOWY_ACACIA_LEAVES); + e.insertAfter(Blocks.CHERRY_LEAVES, PromenadeBlocks.SNOWY_CHERRY_LEAVES); + e.insertAfter(Blocks.DARK_OAK_LEAVES, PromenadeBlocks.SNOWY_DARK_OAK_LEAVES); + e.insertAfter(Blocks.PALE_OAK_LEAVES, PromenadeBlocks.SNOWY_PALE_OAK_LEAVES); + e.insertAfter(Blocks.MANGROVE_LEAVES, PromenadeBlocks.SNOWY_MANGROVE_LEAVES); + e.insertAfter(Blocks.AZALEA_LEAVES, PromenadeBlocks.SNOWY_AZALEA_LEAVES); + e.insertAfter(Blocks.FLOWERING_AZALEA_LEAVES, PromenadeBlocks.SNOWY_FLOWERING_AZALEA_LEAVES); }); // SAKURA - ItemGroupEvents.modifyEntriesEvent(ItemGroups.BUILDING_BLOCKS).register(e -> e.addAfter(Blocks.BIRCH_BUTTON, + CreativeModeTabEvents.modifyOutputEvent(CreativeModeTabs.BUILDING_BLOCKS).register(e -> e.insertAfter(Blocks.BIRCH_BUTTON, PromenadeBlocks.SAKURA_LOG, PromenadeBlocks.SAKURA_WOOD, PromenadeBlocks.STRIPPED_SAKURA_LOG, @@ -80,19 +82,19 @@ public static void appendItemGroups() { PromenadeBlocks.SAKURA_PRESSURE_PLATE, PromenadeBlocks.SAKURA_BUTTON )); - ItemGroupEvents.modifyEntriesEvent(ItemGroups.NATURAL).register(e -> { - e.addAfter(Blocks.BIRCH_LOG, PromenadeBlocks.SAKURA_LOG); - e.addAfter(PromenadeBlocks.SNOWY_BIRCH_LEAVES, + CreativeModeTabEvents.modifyOutputEvent(CreativeModeTabs.NATURAL_BLOCKS).register(e -> { + e.insertAfter(Blocks.BIRCH_LOG, PromenadeBlocks.SAKURA_LOG); + e.insertAfter(PromenadeBlocks.SNOWY_BIRCH_LEAVES, PromenadeBlocks.BLUSH_SAKURA_BLOSSOMS, PromenadeBlocks.SNOWY_BLUSH_SAKURA_BLOSSOMS, PromenadeBlocks.COTTON_SAKURA_BLOSSOMS, PromenadeBlocks.SNOWY_COTTON_SAKURA_BLOSSOMS ); - e.addAfter(Blocks.BIRCH_SAPLING, PromenadeBlocks.BLUSH_SAKURA_SAPLING, PromenadeBlocks.COTTON_SAKURA_SAPLING); - e.addAfter(PromenadeBlocks.BIRCH_LEAF_PILE, PromenadeBlocks.BLUSH_SAKURA_BLOSSOM_PILE, PromenadeBlocks.COTTON_SAKURA_BLOSSOM_PILE); + e.insertAfter(Blocks.BIRCH_SAPLING, PromenadeBlocks.BLUSH_SAKURA_SAPLING, PromenadeBlocks.COTTON_SAKURA_SAPLING); + e.insertAfter(PromenadeBlocks.BIRCH_LEAF_PILE, PromenadeBlocks.BLUSH_SAKURA_BLOSSOM_PILE, PromenadeBlocks.COTTON_SAKURA_BLOSSOM_PILE); }); // MAPLE - ItemGroupEvents.modifyEntriesEvent(ItemGroups.BUILDING_BLOCKS).register(e -> - e.addAfter(PromenadeBlocks.SAKURA_BUTTON, + CreativeModeTabEvents.modifyOutputEvent(CreativeModeTabs.BUILDING_BLOCKS).register(e -> + e.insertAfter(PromenadeBlocks.SAKURA_BUTTON, PromenadeBlocks.MAPLE_LOG, PromenadeBlocks.MAPLE_WOOD, PromenadeBlocks.STRIPPED_MAPLE_LOG, @@ -106,17 +108,17 @@ public static void appendItemGroups() { PromenadeBlocks.MAPLE_TRAPDOOR, PromenadeBlocks.MAPLE_PRESSURE_PLATE, PromenadeBlocks.MAPLE_BUTTON)); - ItemGroupEvents.modifyEntriesEvent(ItemGroups.NATURAL).register(e -> { - e.addAfter(PromenadeBlocks.SAKURA_LOG, PromenadeBlocks.MAPLE_LOG); - e.addAfter(PromenadeBlocks.SNOWY_COTTON_SAKURA_BLOSSOMS, + CreativeModeTabEvents.modifyOutputEvent(CreativeModeTabs.NATURAL_BLOCKS).register(e -> { + e.insertAfter(PromenadeBlocks.SAKURA_LOG, PromenadeBlocks.MAPLE_LOG); + e.insertAfter(PromenadeBlocks.SNOWY_COTTON_SAKURA_BLOSSOMS, PromenadeBlocks.SAP_MAPLE_LEAVES, PromenadeBlocks.SNOWY_SAP_MAPLE_LEAVES, PromenadeBlocks.VERMILION_MAPLE_LEAVES, PromenadeBlocks.SNOWY_VERMILION_MAPLE_LEAVES, PromenadeBlocks.FULVOUS_MAPLE_LEAVES, PromenadeBlocks.SNOWY_FULVOUS_MAPLE_LEAVES, PromenadeBlocks.MIKADO_MAPLE_LEAVES, PromenadeBlocks.SNOWY_MIKADO_MAPLE_LEAVES ); - e.addAfter(PromenadeBlocks.COTTON_SAKURA_SAPLING, PromenadeBlocks.SAP_MAPLE_SAPLING, PromenadeBlocks.VERMILION_MAPLE_SAPLING, PromenadeBlocks.FULVOUS_MAPLE_SAPLING, PromenadeBlocks.MIKADO_MAPLE_SAPLING); - e.addAfter(PromenadeBlocks.COTTON_SAKURA_BLOSSOM_PILE, PromenadeBlocks.SAP_MAPLE_LEAF_PILE, PromenadeBlocks.VERMILION_MAPLE_LEAF_PILE, PromenadeBlocks.FULVOUS_MAPLE_LEAF_PILE, PromenadeBlocks.MIKADO_MAPLE_LEAF_PILE); - e.addAfter(Blocks.FLOWERING_AZALEA_LEAVES, + e.insertAfter(PromenadeBlocks.COTTON_SAKURA_SAPLING, PromenadeBlocks.SAP_MAPLE_SAPLING, PromenadeBlocks.VERMILION_MAPLE_SAPLING, PromenadeBlocks.FULVOUS_MAPLE_SAPLING, PromenadeBlocks.MIKADO_MAPLE_SAPLING); + e.insertAfter(PromenadeBlocks.COTTON_SAKURA_BLOSSOM_PILE, PromenadeBlocks.SAP_MAPLE_LEAF_PILE, PromenadeBlocks.VERMILION_MAPLE_LEAF_PILE, PromenadeBlocks.FULVOUS_MAPLE_LEAF_PILE, PromenadeBlocks.MIKADO_MAPLE_LEAF_PILE); + e.insertAfter(Blocks.FLOWERING_AZALEA_LEAVES, PromenadeBlocks.FALLEN_SAP_MAPLE_LEAVES, PromenadeBlocks.FALLEN_VERMILION_MAPLE_LEAVES, PromenadeBlocks.FALLEN_FULVOUS_MAPLE_LEAVES, @@ -125,8 +127,8 @@ public static void appendItemGroups() { }); // PALM - ItemGroupEvents.modifyEntriesEvent(ItemGroups.BUILDING_BLOCKS).register(e -> { - e.addAfter(Blocks.ACACIA_BUTTON, + CreativeModeTabEvents.modifyOutputEvent(CreativeModeTabs.BUILDING_BLOCKS).register(e -> { + e.insertAfter(Blocks.ACACIA_BUTTON, PromenadeBlocks.PALM_LOG, PromenadeBlocks.PALM_WOOD, PromenadeBlocks.STRIPPED_PALM_LOG, @@ -141,15 +143,15 @@ public static void appendItemGroups() { PromenadeBlocks.PALM_PRESSURE_PLATE, PromenadeBlocks.PALM_BUTTON); }); - ItemGroupEvents.modifyEntriesEvent(ItemGroups.NATURAL).register(e -> { - e.addAfter(Blocks.ACACIA_LOG, PromenadeBlocks.PALM_LOG); - e.addAfter(PromenadeBlocks.SNOWY_ACACIA_LEAVES, PromenadeBlocks.PALM_LEAVES, PromenadeBlocks.SNOWY_PALM_LEAVES, PromenadeBlocks.PALM_HANGING_LEAVES); - e.addAfter(Blocks.ACACIA_SAPLING, PromenadeBlocks.PALM_SAPLING); - e.addAfter(PromenadeBlocks.ACACIA_LEAF_PILE, PromenadeBlocks.PALM_LEAF_PILE); + CreativeModeTabEvents.modifyOutputEvent(CreativeModeTabs.NATURAL_BLOCKS).register(e -> { + e.insertAfter(Blocks.ACACIA_LOG, PromenadeBlocks.PALM_LOG); + e.insertAfter(PromenadeBlocks.SNOWY_ACACIA_LEAVES, PromenadeBlocks.PALM_LEAVES, PromenadeBlocks.SNOWY_PALM_LEAVES, PromenadeBlocks.PALM_HANGING_LEAVES); + e.insertAfter(Blocks.ACACIA_SAPLING, PromenadeBlocks.PALM_SAPLING); + e.insertAfter(PromenadeBlocks.ACACIA_LEAF_PILE, PromenadeBlocks.PALM_LEAF_PILE); }); // AMARANTH - ItemGroupEvents.modifyEntriesEvent(ItemGroups.BUILDING_BLOCKS).register(e -> e.addAfter(Blocks.WARPED_BUTTON, + CreativeModeTabEvents.modifyOutputEvent(CreativeModeTabs.BUILDING_BLOCKS).register(e -> e.insertAfter(Blocks.WARPED_BUTTON, PromenadeBlocks.DARK_AMARANTH_STEM, PromenadeBlocks.DARK_AMARANTH_HYPHAE, PromenadeBlocks.STRIPPED_DARK_AMARANTH_STEM, @@ -164,50 +166,50 @@ public static void appendItemGroups() { PromenadeBlocks.DARK_AMARANTH_PRESSURE_PLATE, PromenadeBlocks.DARK_AMARANTH_BUTTON)); - ItemGroupEvents.modifyEntriesEvent(ItemGroups.NATURAL).register(e -> { - e.addAfter(Blocks.WARPED_NYLIUM, PromenadeBlocks.DARK_AMARANTH_NYLIUM); - e.addAfter(Blocks.WARPED_STEM, PromenadeBlocks.DARK_AMARANTH_STEM); - e.addAfter(Blocks.WARPED_WART_BLOCK, PromenadeBlocks.DARK_AMARANTH_WART_BLOCK); - e.addAfter(Blocks.WARPED_FUNGUS, PromenadeBlocks.DARK_AMARANTH_FUNGUS); - e.addAfter(Blocks.WARPED_ROOTS, PromenadeBlocks.DARK_AMARANTH_ROOTS); - e.addAfter(Blocks.TWISTING_VINES, PromenadeBlocks.COILED_VINES); - e.addAfter(Blocks.SHROOMLIGHT, PromenadeBlocks.SOUL_SHROOMLIGHT); + CreativeModeTabEvents.modifyOutputEvent(CreativeModeTabs.NATURAL_BLOCKS).register(e -> { + e.insertAfter(Blocks.WARPED_NYLIUM, PromenadeBlocks.DARK_AMARANTH_NYLIUM); + e.insertAfter(Blocks.WARPED_STEM, PromenadeBlocks.DARK_AMARANTH_STEM); + e.insertAfter(Blocks.WARPED_WART_BLOCK, PromenadeBlocks.DARK_AMARANTH_WART_BLOCK); + e.insertAfter(Blocks.WARPED_FUNGUS, PromenadeBlocks.DARK_AMARANTH_FUNGUS); + e.insertAfter(Blocks.WARPED_ROOTS, PromenadeBlocks.DARK_AMARANTH_ROOTS); + e.insertAfter(Blocks.TWISTING_VINES, PromenadeBlocks.COILED_VINES); + e.insertAfter(Blocks.SHROOMLIGHT, PromenadeBlocks.SOUL_SHROOMLIGHT); }); - ItemGroupEvents.modifyEntriesEvent(ItemGroups.FUNCTIONAL).register(e -> { - e.addAfter(Blocks.SHROOMLIGHT, PromenadeBlocks.SOUL_SHROOMLIGHT); + CreativeModeTabEvents.modifyOutputEvent(CreativeModeTabs.FUNCTIONAL_BLOCKS).register(e -> { + e.insertAfter(Blocks.SHROOMLIGHT, PromenadeBlocks.SOUL_SHROOMLIGHT); }); - ItemGroupEvents.modifyEntriesEvent(ItemGroups.BUILDING_BLOCKS).register(e -> e.addAfter(Blocks.CUT_RED_SANDSTONE_SLAB, PromenadeBlocks.MOAI)); + CreativeModeTabEvents.modifyOutputEvent(CreativeModeTabs.BUILDING_BLOCKS).register(e -> e.insertAfter(Blocks.CUT_RED_SANDSTONE_SLAB, PromenadeBlocks.MOAI)); - ItemGroupEvents.modifyEntriesEvent(ItemGroups.FUNCTIONAL).register(e -> e.addAfter(Blocks.BIRCH_HANGING_SIGN, PromenadeItems.SAKURA_SIGN, PromenadeItems.SAKURA_HANGING_SIGN)); - ItemGroupEvents.modifyEntriesEvent(ItemGroups.FUNCTIONAL).register(e -> e.addAfter(Blocks.BIRCH_SHELF, PromenadeBlocks.SAKURA_SHELF)); - ItemGroupEvents.modifyEntriesEvent(ItemGroups.TOOLS).register(e -> e.addAfter(Items.BIRCH_CHEST_BOAT, PromenadeItems.SAKURA_BOAT, PromenadeItems.SAKURA_CHEST_BOAT)); + CreativeModeTabEvents.modifyOutputEvent(CreativeModeTabs.FUNCTIONAL_BLOCKS).register(e -> e.insertAfter(Blocks.BIRCH_HANGING_SIGN, PromenadeItems.SAKURA_SIGN, PromenadeItems.SAKURA_HANGING_SIGN)); + CreativeModeTabEvents.modifyOutputEvent(CreativeModeTabs.FUNCTIONAL_BLOCKS).register(e -> e.insertAfter(Blocks.BIRCH_SHELF, PromenadeBlocks.SAKURA_SHELF)); + CreativeModeTabEvents.modifyOutputEvent(CreativeModeTabs.TOOLS_AND_UTILITIES).register(e -> e.insertAfter(Items.BIRCH_CHEST_BOAT, PromenadeItems.SAKURA_BOAT, PromenadeItems.SAKURA_CHEST_BOAT)); - ItemGroupEvents.modifyEntriesEvent(ItemGroups.FUNCTIONAL).register(e -> e.addAfter(PromenadeItems.SAKURA_HANGING_SIGN, PromenadeItems.MAPLE_SIGN, PromenadeItems.MAPLE_HANGING_SIGN)); - ItemGroupEvents.modifyEntriesEvent(ItemGroups.FUNCTIONAL).register(e -> e.addAfter(PromenadeBlocks.SAKURA_SHELF, PromenadeBlocks.MAPLE_SHELF)); - ItemGroupEvents.modifyEntriesEvent(ItemGroups.TOOLS).register(e -> e.addAfter(PromenadeItems.SAKURA_CHEST_BOAT, PromenadeItems.MAPLE_BOAT, PromenadeItems.MAPLE_CHEST_BOAT)); - ItemGroupEvents.modifyEntriesEvent(ItemGroups.FOOD_AND_DRINK).register(e -> e.addAfter(Items.HONEY_BOTTLE, PromenadeItems.MAPLE_SYRUP_BOTTLE)); + CreativeModeTabEvents.modifyOutputEvent(CreativeModeTabs.FUNCTIONAL_BLOCKS).register(e -> e.insertAfter(PromenadeItems.SAKURA_HANGING_SIGN, PromenadeItems.MAPLE_SIGN, PromenadeItems.MAPLE_HANGING_SIGN)); + CreativeModeTabEvents.modifyOutputEvent(CreativeModeTabs.FUNCTIONAL_BLOCKS).register(e -> e.insertAfter(PromenadeBlocks.SAKURA_SHELF, PromenadeBlocks.MAPLE_SHELF)); + CreativeModeTabEvents.modifyOutputEvent(CreativeModeTabs.TOOLS_AND_UTILITIES).register(e -> e.insertAfter(PromenadeItems.SAKURA_CHEST_BOAT, PromenadeItems.MAPLE_BOAT, PromenadeItems.MAPLE_CHEST_BOAT)); + CreativeModeTabEvents.modifyOutputEvent(CreativeModeTabs.FOOD_AND_DRINKS).register(e -> e.insertAfter(Items.HONEY_BOTTLE, PromenadeItems.MAPLE_SYRUP_BOTTLE)); - ItemGroupEvents.modifyEntriesEvent(ItemGroups.FUNCTIONAL).register(e -> e.addAfter(Blocks.ACACIA_HANGING_SIGN, PromenadeItems.PALM_SIGN, PromenadeItems.PALM_HANGING_SIGN)); - ItemGroupEvents.modifyEntriesEvent(ItemGroups.FUNCTIONAL).register(e -> e.addAfter(Blocks.ACACIA_SHELF, PromenadeBlocks.PALM_SHELF)); - ItemGroupEvents.modifyEntriesEvent(ItemGroups.TOOLS).register(e -> e.addAfter(Items.ACACIA_CHEST_BOAT, PromenadeItems.PALM_BOAT, PromenadeItems.PALM_CHEST_BOAT)); + CreativeModeTabEvents.modifyOutputEvent(CreativeModeTabs.FUNCTIONAL_BLOCKS).register(e -> e.insertAfter(Blocks.ACACIA_HANGING_SIGN, PromenadeItems.PALM_SIGN, PromenadeItems.PALM_HANGING_SIGN)); + CreativeModeTabEvents.modifyOutputEvent(CreativeModeTabs.FUNCTIONAL_BLOCKS).register(e -> e.insertAfter(Blocks.ACACIA_SHELF, PromenadeBlocks.PALM_SHELF)); + CreativeModeTabEvents.modifyOutputEvent(CreativeModeTabs.TOOLS_AND_UTILITIES).register(e -> e.insertAfter(Items.ACACIA_CHEST_BOAT, PromenadeItems.PALM_BOAT, PromenadeItems.PALM_CHEST_BOAT)); - ItemGroupEvents.modifyEntriesEvent(ItemGroups.FUNCTIONAL).register(e -> e.addAfter(Blocks.WARPED_HANGING_SIGN, PromenadeItems.DARK_AMARANTH_SIGN, PromenadeItems.DARK_AMARANTH_HANGING_SIGN)); - ItemGroupEvents.modifyEntriesEvent(ItemGroups.FUNCTIONAL).register(e -> e.addAfter(Blocks.WARPED_SHELF, PromenadeBlocks.DARK_AMARANTH_SHELF)); + CreativeModeTabEvents.modifyOutputEvent(CreativeModeTabs.FUNCTIONAL_BLOCKS).register(e -> e.insertAfter(Blocks.WARPED_HANGING_SIGN, PromenadeItems.DARK_AMARANTH_SIGN, PromenadeItems.DARK_AMARANTH_HANGING_SIGN)); + CreativeModeTabEvents.modifyOutputEvent(CreativeModeTabs.FUNCTIONAL_BLOCKS).register(e -> e.insertAfter(Blocks.WARPED_SHELF, PromenadeBlocks.DARK_AMARANTH_SHELF)); - ItemGroupEvents.modifyEntriesEvent(ItemGroups.FOOD_AND_DRINK).register(e -> { - e.addAfter(Items.SWEET_BERRIES, PromenadeItems.BLUEBERRIES); - e.addAfter(Items.ENCHANTED_GOLDEN_APPLE, PromenadeItems.BANANA); + CreativeModeTabEvents.modifyOutputEvent(CreativeModeTabs.FOOD_AND_DRINKS).register(e -> { + e.insertAfter(Items.SWEET_BERRIES, PromenadeItems.BLUEBERRIES); + e.insertAfter(Items.ENCHANTED_GOLDEN_APPLE, PromenadeItems.BANANA); //TODO apricot and mango }); - ItemGroupEvents.modifyEntriesEvent(ItemGroups.FOOD_AND_DRINK).register(e -> e.addAfter(Items.COOKED_CHICKEN, PromenadeItems.DUCK, PromenadeItems.COOKED_DUCK)); + CreativeModeTabEvents.modifyOutputEvent(CreativeModeTabs.FOOD_AND_DRINKS).register(e -> e.insertAfter(Items.COOKED_CHICKEN, PromenadeItems.DUCK, PromenadeItems.COOKED_DUCK)); - ItemGroupEvents.modifyEntriesEvent(ItemGroups.INGREDIENTS).register(e -> e.addAfter(Items.FLOWER_BANNER_PATTERN, PromenadeItems.BOVINE_BANNER_PATTERN)); + CreativeModeTabEvents.modifyOutputEvent(CreativeModeTabs.INGREDIENTS).register(e -> e.insertAfter(Items.FLOWER_BANNER_PATTERN, PromenadeItems.BOVINE_BANNER_PATTERN)); - ItemGroupEvents.modifyEntriesEvent(ItemGroups.SPAWN_EGGS).register(e -> e.addAfter(Items.CHICKEN_SPAWN_EGG, PromenadeItems.DUCK_SPAWN_EGG)); - ItemGroupEvents.modifyEntriesEvent(ItemGroups.SPAWN_EGGS).register(e -> e.addAfter(Items.PIG_SPAWN_EGG, PromenadeItems.CAPYBARA_SPAWN_EGG)); - ItemGroupEvents.modifyEntriesEvent(ItemGroups.SPAWN_EGGS).register(e -> e.addAfter(Items.CREEPER_SPAWN_EGG, PromenadeItems.LUSH_CREEPER_SPAWN_EGG)); - ItemGroupEvents.modifyEntriesEvent(ItemGroups.SPAWN_EGGS).register(e -> e.addAfter(Items.DROWNED_SPAWN_EGG, PromenadeItems.SUNKEN_SPAWN_EGG)); + CreativeModeTabEvents.modifyOutputEvent(CreativeModeTabs.SPAWN_EGGS).register(e -> e.insertAfter(Items.CHICKEN_SPAWN_EGG, PromenadeItems.DUCK_SPAWN_EGG)); + CreativeModeTabEvents.modifyOutputEvent(CreativeModeTabs.SPAWN_EGGS).register(e -> e.insertAfter(Items.PIG_SPAWN_EGG, PromenadeItems.CAPYBARA_SPAWN_EGG)); + CreativeModeTabEvents.modifyOutputEvent(CreativeModeTabs.SPAWN_EGGS).register(e -> e.insertAfter(Items.CREEPER_SPAWN_EGG, PromenadeItems.LUSH_CREEPER_SPAWN_EGG)); + CreativeModeTabEvents.modifyOutputEvent(CreativeModeTabs.SPAWN_EGGS).register(e -> e.insertAfter(Items.DROWNED_SPAWN_EGG, PromenadeItems.SUNKEN_SPAWN_EGG)); } } diff --git a/src/main/java/fr/hugman/promenade/itemgroup/PromenadeItemGroupKeys.java b/src/main/java/fr/hugman/promenade/itemgroup/PromenadeItemGroupKeys.java index a484695a..08e4fcfe 100644 --- a/src/main/java/fr/hugman/promenade/itemgroup/PromenadeItemGroupKeys.java +++ b/src/main/java/fr/hugman/promenade/itemgroup/PromenadeItemGroupKeys.java @@ -1,14 +1,14 @@ package fr.hugman.promenade.itemgroup; import fr.hugman.promenade.Promenade; -import net.minecraft.item.ItemGroup; -import net.minecraft.registry.RegistryKey; -import net.minecraft.registry.RegistryKeys; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.item.CreativeModeTab; public class PromenadeItemGroupKeys { - public static final RegistryKey PROMENADE = of("promenade"); + public static final ResourceKey PROMENADE = of("promenade"); - private static RegistryKey of(String path) { - return RegistryKey.of(RegistryKeys.ITEM_GROUP, Promenade.id(path)); + private static ResourceKey of(String path) { + return ResourceKey.create(Registries.CREATIVE_MODE_TAB, Promenade.id(path)); } } diff --git a/src/main/java/fr/hugman/promenade/itemgroup/PromenadeItemGroups.java b/src/main/java/fr/hugman/promenade/itemgroup/PromenadeItemGroups.java index 10ce0bf3..4a1182bd 100644 --- a/src/main/java/fr/hugman/promenade/itemgroup/PromenadeItemGroups.java +++ b/src/main/java/fr/hugman/promenade/itemgroup/PromenadeItemGroups.java @@ -1,22 +1,22 @@ package fr.hugman.promenade.itemgroup; import fr.hugman.promenade.block.PromenadeBlocks; -import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup; -import net.minecraft.item.ItemGroup; -import net.minecraft.item.ItemStack; -import net.minecraft.registry.Registries; -import net.minecraft.registry.Registry; -import net.minecraft.registry.RegistryKey; -import net.minecraft.text.Text; +import net.fabricmc.fabric.api.creativetab.v1.FabricCreativeModeTab; +import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.ItemStack; public class PromenadeItemGroups { - public static final ItemGroup PROMENADE = of(PromenadeItemGroupKeys.PROMENADE, FabricItemGroup.builder() - .displayName(Text.translatable("item_group.promenade.promenade")) + public static final CreativeModeTab PROMENADE = of(PromenadeItemGroupKeys.PROMENADE, FabricCreativeModeTab.builder() + .title(Component.translatable("item_group.promenade.promenade")) .icon(() -> new ItemStack(PromenadeBlocks.BLUSH_SAKURA_SAPLING)) - .entries(PromenadeItemGroup::fill) + .displayItems(PromenadeItemGroup::fill) .build()); - private static ItemGroup of(RegistryKey key, ItemGroup itemGroup) { - return Registry.register(Registries.ITEM_GROUP, key, itemGroup); + private static CreativeModeTab of(ResourceKey key, CreativeModeTab itemGroup) { + return Registry.register(BuiltInRegistries.CREATIVE_MODE_TAB, key, itemGroup); } } diff --git a/src/main/java/fr/hugman/promenade/loot/PromenadeLootTables.java b/src/main/java/fr/hugman/promenade/loot/PromenadeLootTables.java index 1033c719..f82a6203 100644 --- a/src/main/java/fr/hugman/promenade/loot/PromenadeLootTables.java +++ b/src/main/java/fr/hugman/promenade/loot/PromenadeLootTables.java @@ -1,21 +1,21 @@ package fr.hugman.promenade.loot; import fr.hugman.promenade.Promenade; -import net.minecraft.loot.LootTable; -import net.minecraft.registry.RegistryKey; -import net.minecraft.registry.RegistryKeys; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.level.storage.loot.LootTable; public class PromenadeLootTables { - public static final RegistryKey TUBE_SUNKEN = of("entities/sunken/tube"); - public static final RegistryKey BRAIN_SUNKEN = of("entities/sunken/brain"); - public static final RegistryKey BUBBLE_SUNKEN = of("entities/sunken/bubble"); - public static final RegistryKey FIRE_SUNKEN = of("entities/sunken/fire"); - public static final RegistryKey HORN_SUNKEN = of("entities/sunken/horn"); + public static final ResourceKey TUBE_SUNKEN = of("entities/sunken/tube"); + public static final ResourceKey BRAIN_SUNKEN = of("entities/sunken/brain"); + public static final ResourceKey BUBBLE_SUNKEN = of("entities/sunken/bubble"); + public static final ResourceKey FIRE_SUNKEN = of("entities/sunken/fire"); + public static final ResourceKey HORN_SUNKEN = of("entities/sunken/horn"); - public static final RegistryKey WITCH_HUT_CHEST = of("chests/witch_hut"); + public static final ResourceKey WITCH_HUT_CHEST = of("chests/witch_hut"); - private static RegistryKey of(String path) { - return RegistryKey.of(RegistryKeys.LOOT_TABLE, Promenade.id(path)); + private static ResourceKey of(String path) { + return ResourceKey.create(Registries.LOOT_TABLE, Promenade.id(path)); } } diff --git a/src/main/java/fr/hugman/promenade/mixin/AxeItemMixin.java b/src/main/java/fr/hugman/promenade/mixin/AxeItemMixin.java index dee67209..0c551941 100644 --- a/src/main/java/fr/hugman/promenade/mixin/AxeItemMixin.java +++ b/src/main/java/fr/hugman/promenade/mixin/AxeItemMixin.java @@ -3,25 +3,25 @@ import fr.hugman.promenade.block.MapleLogBlock; import fr.hugman.promenade.block.PromenadeBlocks; import fr.hugman.promenade.block.StrippedMapleLogBlock; -import net.minecraft.block.BlockState; -import net.minecraft.block.PillarBlock; -import net.minecraft.item.AxeItem; 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; import java.util.Optional; +import net.minecraft.world.item.AxeItem; +import net.minecraft.world.level.block.RotatedPillarBlock; +import net.minecraft.world.level.block.state.BlockState; @Mixin(AxeItem.class) public class AxeItemMixin { - @Inject(method = "getStrippedState", at = @At("RETURN"), cancellable = true) + @Inject(method = "getStripped", at = @At("RETURN"), cancellable = true) private void promenade$appendCustomStrip(BlockState state, CallbackInfoReturnable> cir) { if (state.getBlock() == PromenadeBlocks.MAPLE_LOG) { // if the log is natural, it has a 10% chance to be stripped into a stripped log with the state "has_syrup" set to true - cir.setReturnValue(Optional.of(PromenadeBlocks.STRIPPED_MAPLE_LOG.getDefaultState() - .with(PillarBlock.AXIS, state.get(PillarBlock.AXIS)) - .with(StrippedMapleLogBlock.DRIP, state.get(MapleLogBlock.NATURAL) && Math.random() < 0.1f))); + cir.setReturnValue(Optional.of(PromenadeBlocks.STRIPPED_MAPLE_LOG.defaultBlockState() + .setValue(RotatedPillarBlock.AXIS, state.getValue(RotatedPillarBlock.AXIS)) + .setValue(StrippedMapleLogBlock.DRIP, state.getValue(MapleLogBlock.NATURAL) && Math.random() < 0.1f))); } } } \ No newline at end of file diff --git a/src/main/java/fr/hugman/promenade/mixin/FallLocationMixin.java b/src/main/java/fr/hugman/promenade/mixin/FallLocationMixin.java index 2322fe61..c4fc168e 100644 --- a/src/main/java/fr/hugman/promenade/mixin/FallLocationMixin.java +++ b/src/main/java/fr/hugman/promenade/mixin/FallLocationMixin.java @@ -2,8 +2,8 @@ import fr.hugman.promenade.block.PromenadeBlocks; import fr.hugman.promenade.entity.damage.PromenadeFallLocations; -import net.minecraft.block.BlockState; -import net.minecraft.entity.damage.FallLocation; +import net.minecraft.world.damagesource.FallLocation; +import net.minecraft.world.level.block.state.BlockState; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -11,9 +11,9 @@ @Mixin(FallLocation.class) public class FallLocationMixin { - @Inject(method = "fromBlockState", at = @At("HEAD"), cancellable = true) + @Inject(method = "blockToFallLocation", at = @At("HEAD"), cancellable = true) private static void promenade$fromBlockState(BlockState state, CallbackInfoReturnable cir) { - if (state.isOf(PromenadeBlocks.COILED_VINES) || state.isOf(PromenadeBlocks.COILED_VINES_PLANT)) { + if (state.is(PromenadeBlocks.COILED_VINES) || state.is(PromenadeBlocks.COILED_VINES_PLANT)) { cir.setReturnValue(PromenadeFallLocations.COILED_VINES); } } diff --git a/src/main/java/fr/hugman/promenade/mixin/LivingEntityMixin.java b/src/main/java/fr/hugman/promenade/mixin/LivingEntityMixin.java index 744abf30..a44e49a6 100644 --- a/src/main/java/fr/hugman/promenade/mixin/LivingEntityMixin.java +++ b/src/main/java/fr/hugman/promenade/mixin/LivingEntityMixin.java @@ -1,9 +1,9 @@ package fr.hugman.promenade.mixin; import fr.hugman.promenade.world.biome.PromenadeBiomes; -import net.minecraft.entity.LivingEntity; -import net.minecraft.registry.tag.EntityTypeTags; -import net.minecraft.server.world.ServerWorld; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.tags.EntityTypeTags; +import net.minecraft.world.entity.LivingEntity; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -11,14 +11,14 @@ @Mixin(LivingEntity.class) public class LivingEntityMixin { - @Inject(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;setFrozenTicks(I)V", ordinal = 0), cancellable = true) + @Inject(method = "aiStep", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/LivingEntity;setTicksFrozen(I)V", ordinal = 0), cancellable = true) private void promenade$tickMovement(CallbackInfo ci) { LivingEntity entity = (LivingEntity) (Object) this; - int frozenTicks = entity.getFrozenTicks(); - if (entity.getEntityWorld() instanceof ServerWorld serverWorld && PromenadeBiomes.canFreezeFromBiomeAndWeather(entity)) { - entity.setFrozenTicks(Math.min(entity.getMinFreezeDamageTicks(), frozenTicks + 1)); - if (entity.age % 40 == 0 && entity.isFrozen()) { - entity.damage(serverWorld, entity.getDamageSources().freeze(), entity.getType().isIn(EntityTypeTags.FREEZE_HURTS_EXTRA_TYPES) ? 5 : 1); + int frozenTicks = entity.getTicksFrozen(); + if (entity.level() instanceof ServerLevel serverWorld && PromenadeBiomes.canFreezeFromBiomeAndWeather(entity)) { + entity.setTicksFrozen(Math.min(entity.getTicksRequiredToFreeze(), frozenTicks + 1)); + if (entity.tickCount % 40 == 0 && entity.isFullyFrozen()) { + entity.hurtServer(serverWorld, entity.damageSources().freeze(), entity.is(EntityTypeTags.FREEZE_HURTS_EXTRA_TYPES) ? 5 : 1); } ci.cancel(); } diff --git a/src/main/java/fr/hugman/promenade/mixin/NetherrackBlockMixin.java b/src/main/java/fr/hugman/promenade/mixin/NetherrackBlockMixin.java index 144cd72d..1dacfa69 100644 --- a/src/main/java/fr/hugman/promenade/mixin/NetherrackBlockMixin.java +++ b/src/main/java/fr/hugman/promenade/mixin/NetherrackBlockMixin.java @@ -1,13 +1,6 @@ package fr.hugman.promenade.mixin; import fr.hugman.promenade.block.PromenadeBlocks; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.NetherrackBlock; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.random.Random; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -16,26 +9,33 @@ import java.util.Arrays; import java.util.List; import java.util.Objects; +import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.util.RandomSource; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.NetherrackBlock; +import net.minecraft.world.level.block.state.BlockState; @Mixin(NetherrackBlock.class) public abstract class NetherrackBlockMixin { - @Inject(method = "grow", at = @At("HEAD"), cancellable = true) - public void promenade$grow(ServerWorld world, Random random, BlockPos pos, BlockState state, CallbackInfo ci) { + @Inject(method = "performBonemeal", at = @At("HEAD"), cancellable = true) + public void promenade$grow(ServerLevel world, RandomSource random, BlockPos pos, BlockState state, CallbackInfo ci) { boolean crimson = false; boolean warped = false; boolean darkAmaranth = false; - for (BlockPos blockPos : BlockPos.iterate(pos.add(-1, -1, -1), pos.add(1, 1, 1))) { + for (BlockPos blockPos : BlockPos.betweenClosed(pos.offset(-1, -1, -1), pos.offset(1, 1, 1))) { BlockState blockState = world.getBlockState(blockPos); - if (blockState.isOf(Blocks.WARPED_NYLIUM)) { + if (blockState.is(Blocks.WARPED_NYLIUM)) { warped = true; } - if (blockState.isOf(Blocks.CRIMSON_NYLIUM)) { + if (blockState.is(Blocks.CRIMSON_NYLIUM)) { crimson = true; } - if (blockState.isOf(PromenadeBlocks.DARK_AMARANTH_NYLIUM)) { + if (blockState.is(PromenadeBlocks.DARK_AMARANTH_NYLIUM)) { darkAmaranth = true; } @@ -46,13 +46,13 @@ public abstract class NetherrackBlockMixin { if (warped || crimson || darkAmaranth) { BlockState[] options = { - warped ? Blocks.WARPED_NYLIUM.getDefaultState() : null, - crimson ? Blocks.CRIMSON_NYLIUM.getDefaultState() : null, - darkAmaranth ? PromenadeBlocks.DARK_AMARANTH_NYLIUM.getDefaultState() : null + warped ? Blocks.WARPED_NYLIUM.defaultBlockState() : null, + crimson ? Blocks.CRIMSON_NYLIUM.defaultBlockState() : null, + darkAmaranth ? PromenadeBlocks.DARK_AMARANTH_NYLIUM.defaultBlockState() : null }; List available = Arrays.stream(options).filter(Objects::nonNull).toList(); - world.setBlockState(pos, available.get(random.nextInt(available.size())), Block.NOTIFY_ALL); + world.setBlock(pos, available.get(random.nextInt(available.size())), Block.UPDATE_ALL); } ci.cancel(); diff --git a/src/main/java/fr/hugman/promenade/mixin/ShearsItemMixin.java b/src/main/java/fr/hugman/promenade/mixin/ShearsItemMixin.java index 1753e6d8..0fe44951 100644 --- a/src/main/java/fr/hugman/promenade/mixin/ShearsItemMixin.java +++ b/src/main/java/fr/hugman/promenade/mixin/ShearsItemMixin.java @@ -1,19 +1,19 @@ package fr.hugman.promenade.mixin; import fr.hugman.promenade.block.AbstractFacingPlantStemBlock; -import net.minecraft.advancement.criterion.Criteria; -import net.minecraft.block.BlockState; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemUsageContext; -import net.minecraft.item.ShearsItem; -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.sound.SoundCategory; -import net.minecraft.sound.SoundEvents; -import net.minecraft.util.ActionResult; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraft.world.event.GameEvent; +import net.minecraft.advancements.CriteriaTriggers; +import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.sounds.SoundSource; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.ShearsItem; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.gameevent.GameEvent; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -21,27 +21,27 @@ @Mixin(ShearsItem.class) public class ShearsItemMixin { - @Inject(method = "useOnBlock", at = @At("HEAD"), cancellable = true) - public void promenade$useOnBlock(ItemUsageContext context, CallbackInfoReturnable cir) { - World world = context.getWorld(); - BlockPos blockPos = context.getBlockPos(); + @Inject(method = "useOn", at = @At("HEAD"), cancellable = true) + public void promenade$useOnBlock(UseOnContext context, CallbackInfoReturnable cir) { + Level world = context.getLevel(); + BlockPos blockPos = context.getClickedPos(); BlockState blockState = world.getBlockState(blockPos); if (blockState.getBlock() instanceof AbstractFacingPlantStemBlock stem && !stem.hasMaxAge(blockState)) { - PlayerEntity playerEntity = context.getPlayer(); - ItemStack itemStack = context.getStack(); - if (playerEntity instanceof ServerPlayerEntity) { - Criteria.ITEM_USED_ON_BLOCK.trigger((ServerPlayerEntity) playerEntity, blockPos, itemStack); + Player playerEntity = context.getPlayer(); + ItemStack itemStack = context.getItemInHand(); + if (playerEntity instanceof ServerPlayer) { + CriteriaTriggers.ITEM_USED_ON_BLOCK.trigger((ServerPlayer) playerEntity, blockPos, itemStack); } - world.playSound(playerEntity, blockPos, SoundEvents.BLOCK_GROWING_PLANT_CROP, SoundCategory.BLOCKS, 1.0F, 1.0F); + world.playSound(playerEntity, blockPos, SoundEvents.GROWING_PLANT_CROP, SoundSource.BLOCKS, 1.0F, 1.0F); BlockState blockState2 = stem.withMaxAge(blockState); - world.setBlockState(blockPos, blockState2); - world.emitGameEvent(GameEvent.BLOCK_CHANGE, blockPos, GameEvent.Emitter.of(context.getPlayer(), blockState2)); + world.setBlockAndUpdate(blockPos, blockState2); + world.gameEvent(GameEvent.BLOCK_CHANGE, blockPos, GameEvent.Context.of(context.getPlayer(), blockState2)); if (playerEntity != null) { - itemStack.damage(1, playerEntity, context.getHand()); + itemStack.hurtAndBreak(1, playerEntity, context.getHand()); } - cir.setReturnValue(ActionResult.SUCCESS); + cir.setReturnValue(InteractionResult.SUCCESS); } } } \ No newline at end of file diff --git a/src/main/java/fr/hugman/promenade/mixin/SnowBlockMixin.java b/src/main/java/fr/hugman/promenade/mixin/SnowBlockMixin.java index db0f9d0d..104d1eb8 100644 --- a/src/main/java/fr/hugman/promenade/mixin/SnowBlockMixin.java +++ b/src/main/java/fr/hugman/promenade/mixin/SnowBlockMixin.java @@ -3,15 +3,6 @@ import fr.hugman.promenade.block.SnowyLeavesBlock; import fr.hugman.promenade.registry.PromenadeRegistryKeys; import fr.hugman.promenade.world.PromenadeGameRules; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.SnowBlock; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.state.property.IntProperty; -import net.minecraft.state.property.Property; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.random.Random; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -21,17 +12,26 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import java.util.Optional; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.util.RandomSource; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.SnowLayerBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import net.minecraft.world.level.block.state.properties.Property; -@Mixin(SnowBlock.class) +@Mixin(SnowLayerBlock.class) public class SnowBlockMixin { - @Shadow @Final public static IntProperty LAYERS; + @Shadow @Final public static IntegerProperty LAYERS; @Inject(method = "randomTick", at = @At("HEAD"), cancellable = true) - private void promenade$randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random, CallbackInfo ci) { - if (! world.getGameRules().getValue(PromenadeGameRules.DO_BLOCKS_GET_SNOWY)) { + private void promenade$randomTick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random, CallbackInfo ci) { + if (! world.getGameRules().get(PromenadeGameRules.DO_BLOCKS_GET_SNOWY)) { return; } - if(state.get(LAYERS) == 8 && world.getBlockState(pos.up()).isOf((SnowBlock)(Object)this)) { + if(state.getValue(LAYERS) == 8 && world.getBlockState(pos.above()).is((SnowLayerBlock)(Object)this)) { return; } var downPos = findNextBottomSnowyBlock(world, pos); @@ -39,32 +39,32 @@ public class SnowBlockMixin { return; } var downState = world.getBlockState(downPos.get()); - var snowyLeaves = world.getRegistryManager().getOrThrow(PromenadeRegistryKeys.SNOWY_BLOCK_TRANSFORMATION).stream().filter( - entry -> entry.baseBlock().matches(downState.getBlock().getRegistryEntry()) + var snowyLeaves = world.registryAccess().lookupOrThrow(PromenadeRegistryKeys.SNOWY_BLOCK_TRANSFORMATION).stream().filter( + entry -> entry.baseBlock().is(downState.getBlock().builtInRegistryHolder()) ).findFirst().map(sbt -> sbt.snowyBlock().value()).orElse(null); if(snowyLeaves != null) { - var layers = state.get(LAYERS) - 1; - var newLeavesState = snowyLeaves.getDefaultState(); + var layers = state.getValue(LAYERS) - 1; + var newLeavesState = snowyLeaves.defaultBlockState(); // copy properties of snowy block for (Property property : downState.getProperties()) { - newLeavesState = newLeavesState.contains(property) ? newLeavesState.with(property, downState.get(property)) : newLeavesState; + newLeavesState = newLeavesState.hasProperty(property) ? newLeavesState.setValue(property, downState.getValue(property)) : newLeavesState; } - newLeavesState = newLeavesState.contains(SnowyLeavesBlock.BOTTOM) ? newLeavesState.with(SnowyLeavesBlock.BOTTOM, true) : newLeavesState; + newLeavesState = newLeavesState.hasProperty(SnowyLeavesBlock.BOTTOM) ? newLeavesState.setValue(SnowyLeavesBlock.BOTTOM, true) : newLeavesState; if(layers < 1) { - world.setBlockState(pos, Blocks.AIR.getDefaultState()); + world.setBlockAndUpdate(pos, Blocks.AIR.defaultBlockState()); } else { - world.setBlockState(pos, state.with(LAYERS, layers)); + world.setBlockAndUpdate(pos, state.setValue(LAYERS, layers)); } - world.setBlockState(downPos.get(), newLeavesState); + world.setBlockAndUpdate(downPos.get(), newLeavesState); ci.cancel(); } } @Unique - private Optional findNextBottomSnowyBlock(ServerWorld world, BlockPos pos) { - BlockPos.Mutable mutable = pos.mutableCopy(); + private Optional findNextBottomSnowyBlock(ServerLevel world, BlockPos pos) { + BlockPos.MutableBlockPos mutable = pos.mutable(); BlockState blockState; do { @@ -73,20 +73,20 @@ private Optional findNextBottomSnowyBlock(ServerWorld world, BlockPos } while (isFullSnowyBlock(world, blockState)); var block = blockState.getBlock(); - return world.getRegistryManager().getOrThrow(PromenadeRegistryKeys.SNOWY_BLOCK_TRANSFORMATION).stream().anyMatch( - entry -> entry.baseBlock().matches(block.getRegistryEntry()) + return world.registryAccess().lookupOrThrow(PromenadeRegistryKeys.SNOWY_BLOCK_TRANSFORMATION).stream().anyMatch( + entry -> entry.baseBlock().is(block.builtInRegistryHolder()) ) ? Optional.of(mutable) : Optional.empty(); } @Unique - private boolean isFullSnowyBlock(ServerWorld world, BlockState state) { + private boolean isFullSnowyBlock(ServerLevel world, BlockState state) { var block = state.getBlock(); - if (world.getRegistryManager().getOrThrow(PromenadeRegistryKeys.SNOWY_BLOCK_TRANSFORMATION).stream().anyMatch( - entry -> entry.snowyBlock().matches(block.getRegistryEntry()) + if (world.registryAccess().lookupOrThrow(PromenadeRegistryKeys.SNOWY_BLOCK_TRANSFORMATION).stream().anyMatch( + entry -> entry.snowyBlock().is(block.builtInRegistryHolder()) )) return true; - if(state.isOf(Blocks.SNOW_BLOCK) || state.isOf(Blocks.POWDER_SNOW)) return true; - if(state.isOf(Blocks.SNOW) && state.contains(LAYERS) && state.get(LAYERS) == 8) return true; + if(state.is(Blocks.SNOW_BLOCK) || state.is(Blocks.POWDER_SNOW)) return true; + if(state.is(Blocks.SNOW) && state.hasProperty(LAYERS) && state.getValue(LAYERS) == 8) return true; return false; } } diff --git a/src/main/java/fr/hugman/promenade/particle/PromenadeParticleTypes.java b/src/main/java/fr/hugman/promenade/particle/PromenadeParticleTypes.java index 2e4e4c58..45986125 100644 --- a/src/main/java/fr/hugman/promenade/particle/PromenadeParticleTypes.java +++ b/src/main/java/fr/hugman/promenade/particle/PromenadeParticleTypes.java @@ -2,10 +2,10 @@ import fr.hugman.promenade.Promenade; import net.fabricmc.fabric.api.particle.v1.FabricParticleTypes; -import net.minecraft.particle.ParticleType; -import net.minecraft.particle.SimpleParticleType; -import net.minecraft.registry.Registries; -import net.minecraft.registry.Registry; +import net.minecraft.core.Registry; +import net.minecraft.core.particles.ParticleType; +import net.minecraft.core.particles.SimpleParticleType; +import net.minecraft.core.registries.BuiltInRegistries; public class PromenadeParticleTypes { public static final SimpleParticleType BLUSH_SAKURA_BLOSSOM = register("blush_sakura_blossom", FabricParticleTypes.simple()); @@ -16,6 +16,6 @@ public class PromenadeParticleTypes { public static final SimpleParticleType MIKADO_MAPLE_LEAF = register("mikado_maple_leaf", FabricParticleTypes.simple()); public static > B register(String path, B particleType) { - return Registry.register(Registries.PARTICLE_TYPE, Promenade.id(path), particleType); + return Registry.register(BuiltInRegistries.PARTICLE_TYPE, Promenade.id(path), particleType); } } diff --git a/src/main/java/fr/hugman/promenade/registry/PromenadeCompostingChances.java b/src/main/java/fr/hugman/promenade/registry/PromenadeCompostingChances.java index 59931413..19bec226 100644 --- a/src/main/java/fr/hugman/promenade/registry/PromenadeCompostingChances.java +++ b/src/main/java/fr/hugman/promenade/registry/PromenadeCompostingChances.java @@ -2,96 +2,97 @@ import fr.hugman.promenade.block.PromenadeBlocks; import fr.hugman.promenade.item.PromenadeItems; -import net.fabricmc.fabric.api.registry.CompostingChanceRegistry; +import net.fabricmc.fabric.api.registry.CompostableRegistry; +import net.fabricmc.fabric.api.registry.CompostableRegistry; public class PromenadeCompostingChances { public static void register() { - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.OAK_LEAF_PILE, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SPRUCE_LEAF_PILE, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.BIRCH_LEAF_PILE, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.JUNGLE_LEAF_PILE, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.ACACIA_LEAF_PILE, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.CHERRY_LEAF_PILE, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.DARK_OAK_LEAF_PILE, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.PALE_OAK_LEAF_PILE, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.MANGROVE_LEAF_PILE, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.AZALEA_LEAF_PILE, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.FLOWERING_AZALEA_LEAF_PILE, 0.5F); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.OAK_LEAF_PILE, 0.3F); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.SPRUCE_LEAF_PILE, 0.3F); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.BIRCH_LEAF_PILE, 0.3F); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.JUNGLE_LEAF_PILE, 0.3F); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.ACACIA_LEAF_PILE, 0.3F); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.CHERRY_LEAF_PILE, 0.3F); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.DARK_OAK_LEAF_PILE, 0.3F); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.PALE_OAK_LEAF_PILE, 0.3F); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.MANGROVE_LEAF_PILE, 0.3F); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.AZALEA_LEAF_PILE, 0.3F); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.FLOWERING_AZALEA_LEAF_PILE, 0.5F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.DANDELION_PILE, 0.65F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.POPPY_PILE, 0.65F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.BLUE_ORCHID_PILE, 0.65F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.ALLIUM_PILE, 0.65F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.AZURE_BLUET_PILE, 0.65F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.RED_TULIP_PILE, 0.65F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.ORANGE_TULIP_PILE, 0.65F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.WHITE_TULIP_PILE, 0.65F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.PINK_TULIP_PILE, 0.65F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.OXEYE_DAISY_PILE, 0.65F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.CORNFLOWER_PILE, 0.65F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.LILY_OF_THE_VALLEY_PILE, 0.65F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.WITHER_ROSE_PILE, 0.65F); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.DANDELION_PILE, 0.65F); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.POPPY_PILE, 0.65F); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.BLUE_ORCHID_PILE, 0.65F); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.ALLIUM_PILE, 0.65F); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.AZURE_BLUET_PILE, 0.65F); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.RED_TULIP_PILE, 0.65F); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.ORANGE_TULIP_PILE, 0.65F); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.WHITE_TULIP_PILE, 0.65F); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.PINK_TULIP_PILE, 0.65F); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.OXEYE_DAISY_PILE, 0.65F); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.CORNFLOWER_PILE, 0.65F); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.LILY_OF_THE_VALLEY_PILE, 0.65F); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.WITHER_ROSE_PILE, 0.65F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_OAK_LEAVES, 0.3f); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_SPRUCE_LEAVES, 0.3f); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_BIRCH_LEAVES, 0.3f); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_JUNGLE_LEAVES, 0.3f); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_ACACIA_LEAVES, 0.3f); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_CHERRY_LEAVES, 0.3f); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_DARK_OAK_LEAVES, 0.3f); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_PALE_OAK_LEAVES, 0.3f); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_MANGROVE_LEAVES, 0.3f); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_AZALEA_LEAVES, 0.3f); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_FLOWERING_AZALEA_LEAVES, 0.3f); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_OAK_LEAVES, 0.3f); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_SPRUCE_LEAVES, 0.3f); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_BIRCH_LEAVES, 0.3f); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_JUNGLE_LEAVES, 0.3f); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_ACACIA_LEAVES, 0.3f); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_CHERRY_LEAVES, 0.3f); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_DARK_OAK_LEAVES, 0.3f); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_PALE_OAK_LEAVES, 0.3f); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_MANGROVE_LEAVES, 0.3f); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_AZALEA_LEAVES, 0.3f); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_FLOWERING_AZALEA_LEAVES, 0.3f); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.BLUSH_SAKURA_SAPLING, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.BLUSH_SAKURA_BLOSSOMS, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_BLUSH_SAKURA_BLOSSOMS, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.BLUSH_SAKURA_BLOSSOM_PILE, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.COTTON_SAKURA_SAPLING, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.COTTON_SAKURA_BLOSSOMS, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_COTTON_SAKURA_BLOSSOMS, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.COTTON_SAKURA_BLOSSOM_PILE, 0.3F); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.BLUSH_SAKURA_SAPLING, 0.3F); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.BLUSH_SAKURA_BLOSSOMS, 0.3F); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_BLUSH_SAKURA_BLOSSOMS, 0.3F); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.BLUSH_SAKURA_BLOSSOM_PILE, 0.3F); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.COTTON_SAKURA_SAPLING, 0.3F); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.COTTON_SAKURA_BLOSSOMS, 0.3F); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_COTTON_SAKURA_BLOSSOMS, 0.3F); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.COTTON_SAKURA_BLOSSOM_PILE, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SAP_MAPLE_SAPLING, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SAP_MAPLE_LEAVES, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_SAP_MAPLE_LEAVES, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.FALLEN_SAP_MAPLE_LEAVES, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SAP_MAPLE_LEAF_PILE, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.VERMILION_MAPLE_SAPLING, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.VERMILION_MAPLE_LEAVES, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_VERMILION_MAPLE_LEAVES, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.FALLEN_VERMILION_MAPLE_LEAVES, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.VERMILION_MAPLE_LEAF_PILE, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.FULVOUS_MAPLE_SAPLING, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.FULVOUS_MAPLE_LEAVES, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_FULVOUS_MAPLE_LEAVES, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.FALLEN_FULVOUS_MAPLE_LEAVES, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.FULVOUS_MAPLE_LEAF_PILE, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.MIKADO_MAPLE_SAPLING, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.MIKADO_MAPLE_LEAVES, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_MIKADO_MAPLE_LEAVES, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.FALLEN_MIKADO_MAPLE_LEAVES, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.MIKADO_MAPLE_LEAF_PILE, 0.3F); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.SAP_MAPLE_SAPLING, 0.3F); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.SAP_MAPLE_LEAVES, 0.3F); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_SAP_MAPLE_LEAVES, 0.3F); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.FALLEN_SAP_MAPLE_LEAVES, 0.3F); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.SAP_MAPLE_LEAF_PILE, 0.3F); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.VERMILION_MAPLE_SAPLING, 0.3F); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.VERMILION_MAPLE_LEAVES, 0.3F); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_VERMILION_MAPLE_LEAVES, 0.3F); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.FALLEN_VERMILION_MAPLE_LEAVES, 0.3F); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.VERMILION_MAPLE_LEAF_PILE, 0.3F); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.FULVOUS_MAPLE_SAPLING, 0.3F); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.FULVOUS_MAPLE_LEAVES, 0.3F); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_FULVOUS_MAPLE_LEAVES, 0.3F); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.FALLEN_FULVOUS_MAPLE_LEAVES, 0.3F); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.FULVOUS_MAPLE_LEAF_PILE, 0.3F); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.MIKADO_MAPLE_SAPLING, 0.3F); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.MIKADO_MAPLE_LEAVES, 0.3F); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_MIKADO_MAPLE_LEAVES, 0.3F); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.FALLEN_MIKADO_MAPLE_LEAVES, 0.3F); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.MIKADO_MAPLE_LEAF_PILE, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.PALM_SAPLING, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.PALM_LEAVES, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_PALM_LEAVES, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.PALM_HANGING_LEAVES, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.PALM_LEAF_PILE, 0.3F); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.PALM_SAPLING, 0.3F); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.PALM_LEAVES, 0.3F); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_PALM_LEAVES, 0.3F); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.PALM_HANGING_LEAVES, 0.3F); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.PALM_LEAF_PILE, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.DARK_AMARANTH_ROOTS, 0.65F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.DARK_AMARANTH_WART_BLOCK, 0.85F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.DARK_AMARANTH_FUNGUS, 0.65F); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.DARK_AMARANTH_ROOTS, 0.65F); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.DARK_AMARANTH_WART_BLOCK, 0.85F); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.DARK_AMARANTH_FUNGUS, 0.65F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SOUL_SHROOMLIGHT, 0.65F); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.SOUL_SHROOMLIGHT, 0.65F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.COILED_VINES, 0.5F); + CompostableRegistry.INSTANCE.add(PromenadeBlocks.COILED_VINES, 0.5F); - CompostingChanceRegistry.INSTANCE.add(PromenadeItems.BLUEBERRIES, 0.3F); + CompostableRegistry.INSTANCE.add(PromenadeItems.BLUEBERRIES, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeItems.BANANA, 0.65F); - CompostingChanceRegistry.INSTANCE.add(PromenadeItems.APRICOT, 0.65F); - CompostingChanceRegistry.INSTANCE.add(PromenadeItems.MANGO, 0.65F); + CompostableRegistry.INSTANCE.add(PromenadeItems.BANANA, 0.65F); + CompostableRegistry.INSTANCE.add(PromenadeItems.APRICOT, 0.65F); + CompostableRegistry.INSTANCE.add(PromenadeItems.MANGO, 0.65F); } } diff --git a/src/main/java/fr/hugman/promenade/registry/PromenadeRegistryAliases.java b/src/main/java/fr/hugman/promenade/registry/PromenadeRegistryAliases.java index 97fd9977..892b9ba6 100644 --- a/src/main/java/fr/hugman/promenade/registry/PromenadeRegistryAliases.java +++ b/src/main/java/fr/hugman/promenade/registry/PromenadeRegistryAliases.java @@ -1,10 +1,9 @@ package fr.hugman.promenade.registry; import fr.hugman.promenade.Promenade; -import net.minecraft.registry.Registries; -import net.minecraft.util.Identifier; - import java.util.HashMap; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.resources.Identifier; /** * Registry aliases for Promenade. Prevents players from losing stuff when content is removed along new versions. @@ -14,7 +13,7 @@ public static void registerAliases() { HashMap blockAliases = new HashMap<>(); // I forgot what version that was in - Registries.ENTITY_TYPE.addAlias(Promenade.id("sunken_skeleton"), Promenade.id("sunken")); + BuiltInRegistries.ENTITY_TYPE.addAlias(Promenade.id("sunken_skeleton"), Promenade.id("sunken")); // v3.0.0 @@ -46,7 +45,7 @@ public static void registerAliases() { blockAliases.put(Promenade.id("cherry_oak_pressure_plate"), Promenade.id("sakura_pressure_plate")); blockAliases.put(Promenade.id("cherry_oak_button"), Promenade.id("sakura_button")); blockAliases.put(Promenade.id("cherry_oak_sign"), Promenade.id("sakura_sign")); - Registries.BLOCK.addAlias(Promenade.id("cherry_oak_wall_sign"), Promenade.id("sakura_wall_sign")); + BuiltInRegistries.BLOCK.addAlias(Promenade.id("cherry_oak_wall_sign"), Promenade.id("sakura_wall_sign")); blockAliases.put(Promenade.id("pink_cherry_oak_sapling"), Promenade.id("blush_sakura_sapling")); blockAliases.put(Promenade.id("potted_pink_cherry_oak_sapling"), Promenade.id("potted_blush_sakura_sapling")); @@ -58,7 +57,7 @@ public static void registerAliases() { blockAliases.put(Promenade.id("white_cherry_oak_leaves"), Promenade.id("cotton_sakura_blossoms")); blockAliases.put(Promenade.id("white_cherry_oak_leaf_pile"), Promenade.id("cotton_sakura_blossom_pile")); - Registries.ITEM.addAlias(Promenade.id("cherry_oak_boat"), Promenade.id("sakura_boat")); + BuiltInRegistries.ITEM.addAlias(Promenade.id("cherry_oak_boat"), Promenade.id("sakura_boat")); // v4.0.0 blockAliases.put(Promenade.id("carbonite"), Promenade.id("asphalt")); @@ -71,7 +70,7 @@ public static void registerAliases() { blockAliases.put(Promenade.id("polished_carbonite_stairs"), Promenade.id("polished_asphalt_stairs")); // v5.0.0 - var grassId = Identifier.ofVanilla("grass_block"); + var grassId = Identifier.withDefaultNamespace("grass_block"); blockAliases.put(Promenade.id("vermilion_carpeted_grass_block"), grassId); blockAliases.put(Promenade.id("fulvous_carpeted_grass_block"), grassId); blockAliases.put(Promenade.id("mikado_carpeted_grass_block"), grassId); @@ -79,8 +78,8 @@ public static void registerAliases() { blockAliases.put(Promenade.id("black_dylium"), Promenade.id("dark_amaranth_nylium")); for (var entry : blockAliases.entrySet()) { - Registries.BLOCK.addAlias(entry.getKey(), entry.getValue()); - Registries.ITEM.addAlias(entry.getKey(), entry.getValue()); + BuiltInRegistries.BLOCK.addAlias(entry.getKey(), entry.getValue()); + BuiltInRegistries.ITEM.addAlias(entry.getKey(), entry.getValue()); } } } diff --git a/src/main/java/fr/hugman/promenade/registry/PromenadeRegistryKeys.java b/src/main/java/fr/hugman/promenade/registry/PromenadeRegistryKeys.java index aeb8d32a..4c8bb26c 100644 --- a/src/main/java/fr/hugman/promenade/registry/PromenadeRegistryKeys.java +++ b/src/main/java/fr/hugman/promenade/registry/PromenadeRegistryKeys.java @@ -5,13 +5,13 @@ import fr.hugman.promenade.entity.variant.CapybaraVariant; import fr.hugman.promenade.entity.variant.DuckVariant; import fr.hugman.promenade.entity.variant.SunkenVariant; -import net.minecraft.registry.Registry; -import net.minecraft.registry.RegistryKey; +import net.minecraft.core.Registry; +import net.minecraft.resources.ResourceKey; public class PromenadeRegistryKeys { - public static final RegistryKey> SNOWY_BLOCK_TRANSFORMATION = RegistryKey.ofRegistry(Promenade.id("snowy_block_transformation")); + public static final ResourceKey> SNOWY_BLOCK_TRANSFORMATION = ResourceKey.createRegistryKey(Promenade.id("snowy_block_transformation")); - public static final RegistryKey> DUCK_VARIANT = RegistryKey.ofRegistry(Promenade.id("duck_variant")); - public static final RegistryKey> CAPYBARA_VARIANT = RegistryKey.ofRegistry(Promenade.id("capybara_variant")); - public static final RegistryKey> SUNKEN_VARIANT = RegistryKey.ofRegistry(Promenade.id("sunken_variant")); + public static final ResourceKey> DUCK_VARIANT = ResourceKey.createRegistryKey(Promenade.id("duck_variant")); + public static final ResourceKey> CAPYBARA_VARIANT = ResourceKey.createRegistryKey(Promenade.id("capybara_variant")); + public static final ResourceKey> SUNKEN_VARIANT = ResourceKey.createRegistryKey(Promenade.id("sunken_variant")); } diff --git a/src/main/java/fr/hugman/promenade/sound/PromenadeBlockSounds.java b/src/main/java/fr/hugman/promenade/sound/PromenadeBlockSounds.java index 81243b48..1e8728ab 100644 --- a/src/main/java/fr/hugman/promenade/sound/PromenadeBlockSounds.java +++ b/src/main/java/fr/hugman/promenade/sound/PromenadeBlockSounds.java @@ -1,14 +1,14 @@ package fr.hugman.promenade.sound; -import net.minecraft.sound.BlockSoundGroup; +import net.minecraft.world.level.block.SoundType; public final class PromenadeBlockSounds { - public static final BlockSoundGroup MAPLE_WOOD = BlockSoundGroup.WOOD; - public static final BlockSoundGroup SAKURA_WOOD = BlockSoundGroup.CHERRY_WOOD; - public static final BlockSoundGroup PALM_WOOD = BlockSoundGroup.WOOD; - public static final BlockSoundGroup AMARANTH_WOOD = BlockSoundGroup.NETHER_WOOD; + public static final SoundType MAPLE_WOOD = SoundType.WOOD; + public static final SoundType SAKURA_WOOD = SoundType.CHERRY_WOOD; + public static final SoundType PALM_WOOD = SoundType.WOOD; + public static final SoundType AMARANTH_WOOD = SoundType.NETHER_WOOD; - public static final BlockSoundGroup SNOWY_LEAVES = new BlockSoundGroup(1.0f, 1.0f, + public static final SoundType SNOWY_LEAVES = new SoundType(1.0f, 1.0f, PromenadeSoundEvents.BLOCK_SNOWY_LEAVES_BREAK, PromenadeSoundEvents.BLOCK_SNOWY_LEAVES_STEP, PromenadeSoundEvents.BLOCK_SNOWY_LEAVES_PLACE, @@ -16,7 +16,7 @@ public final class PromenadeBlockSounds { PromenadeSoundEvents.BLOCK_SNOWY_LEAVES_FALL ); - public static final BlockSoundGroup SNOWY_AZALEA_LEAVES = new BlockSoundGroup(1.0f, 1.0f, + public static final SoundType SNOWY_AZALEA_LEAVES = new SoundType(1.0f, 1.0f, PromenadeSoundEvents.BLOCK_SNOWY_AZALEA_LEAVES_BREAK, PromenadeSoundEvents.BLOCK_SNOWY_AZALEA_LEAVES_STEP, PromenadeSoundEvents.BLOCK_SNOWY_AZALEA_LEAVES_PLACE, @@ -24,7 +24,7 @@ public final class PromenadeBlockSounds { PromenadeSoundEvents.BLOCK_SNOWY_AZALEA_LEAVES_FALL ); - public static final BlockSoundGroup SNOWY_CHERRY_LEAVES = new BlockSoundGroup(1.0f, 1.0f, + public static final SoundType SNOWY_CHERRY_LEAVES = new SoundType(1.0f, 1.0f, PromenadeSoundEvents.BLOCK_SNOWY_CHERRY_LEAVES_BREAK, PromenadeSoundEvents.BLOCK_SNOWY_CHERRY_LEAVES_STEP, PromenadeSoundEvents.BLOCK_SNOWY_CHERRY_LEAVES_PLACE, diff --git a/src/main/java/fr/hugman/promenade/sound/PromenadeSoundEvents.java b/src/main/java/fr/hugman/promenade/sound/PromenadeSoundEvents.java index dc5f4206..2937c12e 100644 --- a/src/main/java/fr/hugman/promenade/sound/PromenadeSoundEvents.java +++ b/src/main/java/fr/hugman/promenade/sound/PromenadeSoundEvents.java @@ -1,15 +1,14 @@ package fr.hugman.promenade.sound; import fr.hugman.promenade.Promenade; -import net.minecraft.registry.Registries; -import net.minecraft.registry.Registry; -import net.minecraft.registry.entry.RegistryEntry; -import net.minecraft.sound.SoundEvent; - import java.util.Optional; +import net.minecraft.core.Holder; +import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.sounds.SoundEvent; public class PromenadeSoundEvents { - public static final RegistryEntry.Reference MUSIC_OVERWORLD_SAKURA_GROVES = ofRef("music.overworld.sakura_groves"); + public static final Holder.Reference MUSIC_OVERWORLD_SAKURA_GROVES = ofRef("music.overworld.sakura_groves"); public static final SoundEvent BLOCK_SNOWY_LEAVES_BREAK = of("block.snowy_leaves.break"); public static final SoundEvent BLOCK_SNOWY_LEAVES_STEP = of("block.snowy_leaves.step"); @@ -44,13 +43,13 @@ public class PromenadeSoundEvents { public static final SoundEvent SUNKEN_STEP = of("entity.sunken.step"); public static final SoundEvent SUNKEN_SHOOT = of("entity.sunken.shoot"); - private static RegistryEntry.Reference ofRef(String path) { + private static Holder.Reference ofRef(String path) { var id = Promenade.id(path); - return Registry.registerReference(Registries.SOUND_EVENT, id, new SoundEvent(id, Optional.empty())); + return Registry.registerForHolder(BuiltInRegistries.SOUND_EVENT, id, new SoundEvent(id, Optional.empty())); } private static SoundEvent of(String path) { var id = Promenade.id(path); - return Registry.register(Registries.SOUND_EVENT, id, new SoundEvent(id, Optional.empty())); + return Registry.register(BuiltInRegistries.SOUND_EVENT, id, new SoundEvent(id, Optional.empty())); } } diff --git a/src/main/java/fr/hugman/promenade/tag/PromenadeBiomeTags.java b/src/main/java/fr/hugman/promenade/tag/PromenadeBiomeTags.java index 8414e8a7..c72e829f 100644 --- a/src/main/java/fr/hugman/promenade/tag/PromenadeBiomeTags.java +++ b/src/main/java/fr/hugman/promenade/tag/PromenadeBiomeTags.java @@ -2,11 +2,10 @@ import fr.hugman.promenade.Promenade; import net.fabricmc.fabric.api.tag.convention.v2.TagUtil; -import net.minecraft.item.Item; -import net.minecraft.registry.RegistryKeys; -import net.minecraft.registry.tag.TagKey; -import net.minecraft.util.Identifier; -import net.minecraft.world.biome.Biome; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.Identifier; +import net.minecraft.tags.TagKey; +import net.minecraft.world.level.biome.Biome; public class PromenadeBiomeTags { public static final TagKey SAKURA_GROVES = of("sakura_groves"); @@ -27,10 +26,10 @@ public class PromenadeBiomeTags { public static final TagKey PRIMARY_WOOD_TYPE_DARK_AMARANTH = ofConventional("primary_wood_type/dark_amaranth"); private static TagKey of(String path) { - return TagKey.of(RegistryKeys.BIOME, Promenade.id(path)); + return TagKey.create(Registries.BIOME, Promenade.id(path)); } private static TagKey ofConventional(String path) { - return TagKey.of(RegistryKeys.BIOME, Identifier.of(TagUtil.C_TAG_NAMESPACE, path)); + return TagKey.create(Registries.BIOME, Identifier.fromNamespaceAndPath(TagUtil.C_TAG_NAMESPACE, path)); } } diff --git a/src/main/java/fr/hugman/promenade/tag/PromenadeBlockTags.java b/src/main/java/fr/hugman/promenade/tag/PromenadeBlockTags.java index 47146ddd..baef47a0 100644 --- a/src/main/java/fr/hugman/promenade/tag/PromenadeBlockTags.java +++ b/src/main/java/fr/hugman/promenade/tag/PromenadeBlockTags.java @@ -2,11 +2,10 @@ import fr.hugman.promenade.Promenade; import net.fabricmc.fabric.api.tag.convention.v2.TagUtil; -import net.minecraft.block.Block; -import net.minecraft.item.Item; -import net.minecraft.registry.RegistryKeys; -import net.minecraft.registry.tag.TagKey; -import net.minecraft.util.Identifier; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.Identifier; +import net.minecraft.tags.TagKey; +import net.minecraft.world.level.block.Block; public class PromenadeBlockTags { public static final TagKey SAKURA_LOGS = of("sakura_logs"); @@ -27,10 +26,10 @@ public class PromenadeBlockTags { public static final TagKey IGNEOUS_ROCKS = ofConventional("igneous_rocks"); public static TagKey of(String path) { - return TagKey.of(RegistryKeys.BLOCK, Promenade.id(path)); + return TagKey.create(Registries.BLOCK, Promenade.id(path)); } private static TagKey ofConventional(String path) { - return TagKey.of(RegistryKeys.BLOCK, Identifier.of(TagUtil.C_TAG_NAMESPACE, path)); + return TagKey.create(Registries.BLOCK, Identifier.fromNamespaceAndPath(TagUtil.C_TAG_NAMESPACE, path)); } } diff --git a/src/main/java/fr/hugman/promenade/tag/PromenadeEntityTypeTags.java b/src/main/java/fr/hugman/promenade/tag/PromenadeEntityTypeTags.java index f86f650c..fcd4615c 100644 --- a/src/main/java/fr/hugman/promenade/tag/PromenadeEntityTypeTags.java +++ b/src/main/java/fr/hugman/promenade/tag/PromenadeEntityTypeTags.java @@ -2,11 +2,10 @@ import fr.hugman.promenade.Promenade; import net.fabricmc.fabric.api.tag.convention.v2.TagUtil; -import net.minecraft.entity.EntityType; -import net.minecraft.item.Item; -import net.minecraft.registry.RegistryKeys; -import net.minecraft.registry.tag.TagKey; -import net.minecraft.util.Identifier; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.Identifier; +import net.minecraft.tags.TagKey; +import net.minecraft.world.entity.EntityType; public class PromenadeEntityTypeTags { public static final TagKey> ANIMALS = ofConventional("animals"); @@ -16,10 +15,10 @@ public class PromenadeEntityTypeTags { public static final TagKey> CREEPERS = ofConventional("creepers"); private static TagKey> of(String path) { - return TagKey.of(RegistryKeys.ENTITY_TYPE, Promenade.id(path)); + return TagKey.create(Registries.ENTITY_TYPE, Promenade.id(path)); } private static TagKey> ofConventional(String path) { - return TagKey.of(RegistryKeys.ENTITY_TYPE, Identifier.of(TagUtil.C_TAG_NAMESPACE, path)); + return TagKey.create(Registries.ENTITY_TYPE, Identifier.fromNamespaceAndPath(TagUtil.C_TAG_NAMESPACE, path)); } } diff --git a/src/main/java/fr/hugman/promenade/tag/PromenadeItemTags.java b/src/main/java/fr/hugman/promenade/tag/PromenadeItemTags.java index 0c638e75..522067b4 100644 --- a/src/main/java/fr/hugman/promenade/tag/PromenadeItemTags.java +++ b/src/main/java/fr/hugman/promenade/tag/PromenadeItemTags.java @@ -2,10 +2,10 @@ import fr.hugman.promenade.Promenade; import net.fabricmc.fabric.api.tag.convention.v2.TagUtil; -import net.minecraft.item.Item; -import net.minecraft.registry.RegistryKeys; -import net.minecraft.registry.tag.TagKey; -import net.minecraft.util.Identifier; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.Identifier; +import net.minecraft.tags.TagKey; +import net.minecraft.world.item.Item; public class PromenadeItemTags { public static final TagKey SAKURA_LOGS = of("sakura_logs"); @@ -28,10 +28,10 @@ public class PromenadeItemTags { public static final TagKey IGNEOUS_ROCKS = ofConventional("igneous_rocks"); private static TagKey of(String path) { - return TagKey.of(RegistryKeys.ITEM, Promenade.id(path)); + return TagKey.create(Registries.ITEM, Promenade.id(path)); } private static TagKey ofConventional(String path) { - return TagKey.of(RegistryKeys.ITEM, Identifier.of(TagUtil.C_TAG_NAMESPACE, path)); + return TagKey.create(Registries.ITEM, Identifier.fromNamespaceAndPath(TagUtil.C_TAG_NAMESPACE, path)); } } diff --git a/src/main/java/fr/hugman/promenade/trade/PromenadeTrades.java b/src/main/java/fr/hugman/promenade/trade/PromenadeTrades.java deleted file mode 100644 index 6b1cf68a..00000000 --- a/src/main/java/fr/hugman/promenade/trade/PromenadeTrades.java +++ /dev/null @@ -1,20 +0,0 @@ -package fr.hugman.promenade.trade; - -import fr.hugman.promenade.block.PromenadeBlocks; -import net.fabricmc.fabric.api.object.builder.v1.trade.TradeOfferHelper; - -public class PromenadeTrades { - public static void appendVillagerTrades() { - TradeOfferHelper.registerWanderingTraderOffers(builder -> builder.addOffersToPool(TradeOfferHelper.WanderingTraderOffersBuilder.SELL_COMMON_ITEMS_POOL, - TradeFactory.sapling(PromenadeBlocks.VERMILION_MAPLE_SAPLING), - TradeFactory.sapling(PromenadeBlocks.FULVOUS_MAPLE_SAPLING), - TradeFactory.sapling(PromenadeBlocks.MIKADO_MAPLE_SAPLING), - TradeFactory.sapling(PromenadeBlocks.SAP_MAPLE_SAPLING), - - TradeFactory.sapling(PromenadeBlocks.BLUSH_SAKURA_SAPLING), - TradeFactory.sapling(PromenadeBlocks.COTTON_SAKURA_SAPLING), - - TradeFactory.sapling(PromenadeBlocks.PALM_SAPLING) - )); - } -} diff --git a/src/main/java/fr/hugman/promenade/trade/TradeFactory.java b/src/main/java/fr/hugman/promenade/trade/TradeFactory.java deleted file mode 100644 index 15563368..00000000 --- a/src/main/java/fr/hugman/promenade/trade/TradeFactory.java +++ /dev/null @@ -1,14 +0,0 @@ -package fr.hugman.promenade.trade; - -import net.minecraft.item.ItemConvertible; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.village.TradeOffer; -import net.minecraft.village.TradeOffers; -import net.minecraft.village.TradedItem; - -public class TradeFactory { - public static TradeOffers.Factory sapling(ItemConvertible sapling) { - return (world, entity, random) -> new TradeOffer(new TradedItem(Items.EMERALD, 5), new ItemStack(sapling), 8, 1, 0.05f); - } -} diff --git a/src/main/java/fr/hugman/promenade/util/NoiseScale.java b/src/main/java/fr/hugman/promenade/util/NoiseScale.java index 85860d61..231f2a99 100644 --- a/src/main/java/fr/hugman/promenade/util/NoiseScale.java +++ b/src/main/java/fr/hugman/promenade/util/NoiseScale.java @@ -3,15 +3,15 @@ import com.mojang.datafixers.util.Either; import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; -import net.minecraft.util.dynamic.Codecs; +import net.minecraft.util.ExtraCodecs; public record NoiseScale(float x, float z) { private static final Codec DIRECT_CODEC = RecordCodecBuilder.create(instance -> instance.group( - Codecs.POSITIVE_FLOAT.fieldOf("x").forGetter(NoiseScale::x), - Codecs.POSITIVE_FLOAT.fieldOf("z").forGetter(NoiseScale::z) + ExtraCodecs.POSITIVE_FLOAT.fieldOf("x").forGetter(NoiseScale::x), + ExtraCodecs.POSITIVE_FLOAT.fieldOf("z").forGetter(NoiseScale::z) ).apply(instance, NoiseScale::new)); - public static final Codec CODEC = Codec.either(Codecs.POSITIVE_FLOAT, DIRECT_CODEC).xmap( + public static final Codec CODEC = Codec.either(ExtraCodecs.POSITIVE_FLOAT, DIRECT_CODEC).xmap( either -> either.map(value -> new NoiseScale(value, value), scale -> scale), scale -> scale.x == scale.z ? Either.left(scale.x) : Either.right(scale) ); diff --git a/src/main/java/fr/hugman/promenade/world/PromenadeGameRules.java b/src/main/java/fr/hugman/promenade/world/PromenadeGameRules.java index 815a0483..3db5f9e8 100644 --- a/src/main/java/fr/hugman/promenade/world/PromenadeGameRules.java +++ b/src/main/java/fr/hugman/promenade/world/PromenadeGameRules.java @@ -2,8 +2,8 @@ import fr.hugman.promenade.Promenade; import net.fabricmc.fabric.api.gamerule.v1.GameRuleBuilder; -import net.minecraft.world.rule.GameRule; -import net.minecraft.world.rule.GameRuleCategory; +import net.minecraft.world.level.gamerules.GameRule; +import net.minecraft.world.level.gamerules.GameRuleCategory; public class PromenadeGameRules { public static final GameRule DO_BLOCKS_GET_SNOWY = GameRuleBuilder.forBoolean(true).category(GameRuleCategory.UPDATES).buildAndRegister(Promenade.id("do_blocks_get_snowy")); diff --git a/src/main/java/fr/hugman/promenade/world/PromenadeSaplingGenerators.java b/src/main/java/fr/hugman/promenade/world/PromenadeSaplingGenerators.java index c0edf215..2c36fd7b 100644 --- a/src/main/java/fr/hugman/promenade/world/PromenadeSaplingGenerators.java +++ b/src/main/java/fr/hugman/promenade/world/PromenadeSaplingGenerators.java @@ -1,36 +1,35 @@ package fr.hugman.promenade.world; import fr.hugman.promenade.world.gen.feature.PromenadeConfiguredFeatures; -import net.minecraft.block.SaplingGenerator; - import java.util.Optional; +import net.minecraft.world.level.block.grower.TreeGrower; public class PromenadeSaplingGenerators { - public static final SaplingGenerator BLUSH_SAKURA = new SaplingGenerator("sakura/blush", 0.1F, Optional.empty(), Optional.empty(), + public static final TreeGrower BLUSH_SAKURA = new TreeGrower("sakura/blush", 0.1F, Optional.empty(), Optional.empty(), Optional.of(PromenadeConfiguredFeatures.BLUSH_SAKURA), Optional.of(PromenadeConfiguredFeatures.FANCY_BLUSH_SAKURA), Optional.of(PromenadeConfiguredFeatures.BLUSH_SAKURA_BEES), Optional.of(PromenadeConfiguredFeatures.FANCY_BLUSH_SAKURA_BEES) ); - public static final SaplingGenerator COTTON_SAKURA = new SaplingGenerator("sakura/cotton", 0.1F, Optional.empty(), Optional.empty(), + public static final TreeGrower COTTON_SAKURA = new TreeGrower("sakura/cotton", 0.1F, Optional.empty(), Optional.empty(), Optional.of(PromenadeConfiguredFeatures.COTTON_SAKURA), Optional.of(PromenadeConfiguredFeatures.FANCY_COTTON_SAKURA), Optional.of(PromenadeConfiguredFeatures.COTTON_SAKURA_BEES), Optional.of(PromenadeConfiguredFeatures.FANCY_COTTON_SAKURA_BEES) ); - public static final SaplingGenerator SAP_MAPLE = new SaplingGenerator("maple/sap", 0.1F, Optional.empty(), Optional.empty(), + public static final TreeGrower SAP_MAPLE = new TreeGrower("maple/sap", 0.1F, Optional.empty(), Optional.empty(), Optional.of(PromenadeConfiguredFeatures.SAP_MAPLE), Optional.of(PromenadeConfiguredFeatures.FANCY_SAP_MAPLE), Optional.of(PromenadeConfiguredFeatures.SAP_MAPLE_BEES), Optional.of(PromenadeConfiguredFeatures.FANCY_SAP_MAPLE_BEES) ); - public static final SaplingGenerator VERMILION_MAPLE = new SaplingGenerator("maple/vermilion", 0.1F, Optional.empty(), Optional.empty(), + public static final TreeGrower VERMILION_MAPLE = new TreeGrower("maple/vermilion", 0.1F, Optional.empty(), Optional.empty(), Optional.of(PromenadeConfiguredFeatures.VERMILION_MAPLE), Optional.of(PromenadeConfiguredFeatures.FANCY_VERMILION_MAPLE), Optional.of(PromenadeConfiguredFeatures.VERMILION_MAPLE_BEES), Optional.of(PromenadeConfiguredFeatures.FANCY_VERMILION_MAPLE_BEES) ); - public static final SaplingGenerator FULVOUS_MAPLE = new SaplingGenerator("maple/fulvous", 0.1F, Optional.empty(), Optional.empty(), + public static final TreeGrower FULVOUS_MAPLE = new TreeGrower("maple/fulvous", 0.1F, Optional.empty(), Optional.empty(), Optional.of(PromenadeConfiguredFeatures.FULVOUS_MAPLE), Optional.of(PromenadeConfiguredFeatures.FANCY_FULVOUS_MAPLE), Optional.of(PromenadeConfiguredFeatures.FULVOUS_MAPLE_BEES), Optional.of(PromenadeConfiguredFeatures.FANCY_FULVOUS_MAPLE_BEES) ); - public static final SaplingGenerator MIKADO_MAPLE = new SaplingGenerator("maple/vermilion", 0.1F, Optional.empty(), Optional.empty(), + public static final TreeGrower MIKADO_MAPLE = new TreeGrower("maple/vermilion", 0.1F, Optional.empty(), Optional.empty(), Optional.of(PromenadeConfiguredFeatures.MIKADO_MAPLE), Optional.of(PromenadeConfiguredFeatures.FANCY_MIKADO_MAPLE), Optional.of(PromenadeConfiguredFeatures.MIKADO_MAPLE_BEES), Optional.of(PromenadeConfiguredFeatures.FANCY_MIKADO_MAPLE_BEES) ); - public static final SaplingGenerator PALM = new SaplingGenerator("palm", Optional.empty(), Optional.of(PromenadeConfiguredFeatures.PALM), Optional.empty()); + public static final TreeGrower PALM = new TreeGrower("palm", Optional.empty(), Optional.of(PromenadeConfiguredFeatures.PALM), Optional.empty()); } diff --git a/src/main/java/fr/hugman/promenade/world/biome/PromenadeBiomes.java b/src/main/java/fr/hugman/promenade/world/biome/PromenadeBiomes.java index ba6c6e98..9437390d 100644 --- a/src/main/java/fr/hugman/promenade/world/biome/PromenadeBiomes.java +++ b/src/main/java/fr/hugman/promenade/world/biome/PromenadeBiomes.java @@ -6,60 +6,61 @@ import fr.hugman.promenade.block.PromenadeBlocks; import fr.hugman.promenade.config.PromenadeConfig; import fr.hugman.promenade.tag.PromenadeBiomeTags; -import net.minecraft.block.Blocks; -import net.minecraft.entity.EquipmentSlot; -import net.minecraft.entity.LivingEntity; -import net.minecraft.registry.RegistryKey; -import net.minecraft.registry.RegistryKeys; -import net.minecraft.registry.entry.RegistryEntry; -import net.minecraft.registry.tag.EntityTypeTags; -import net.minecraft.registry.tag.ItemTags; -import net.minecraft.world.LightType; -import net.minecraft.world.biome.Biome; -import net.minecraft.world.biome.BiomeKeys; -import net.minecraft.world.biome.source.util.MultiNoiseUtil; -import net.minecraft.world.gen.YOffset; -import net.minecraft.world.gen.noise.NoiseParametersKeys; -import net.minecraft.world.gen.surfacebuilder.MaterialRules; -import net.minecraft.world.gen.surfacebuilder.VanillaSurfaceRules; +import net.minecraft.core.Holder; +import net.minecraft.core.registries.Registries; +import net.minecraft.data.worldgen.SurfaceRuleData; +import net.minecraft.resources.ResourceKey; +import net.minecraft.tags.EntityTypeTags; +import net.minecraft.tags.ItemTags; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.level.LightLayer; +import net.minecraft.world.level.biome.Biome; +import net.minecraft.world.level.biome.Biomes; +import net.minecraft.world.level.biome.Climate; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.levelgen.Noises; +import net.minecraft.world.level.levelgen.SurfaceRules; +import net.minecraft.world.level.levelgen.VerticalAnchor; public class PromenadeBiomes { - public static final RegistryKey BLUSH_SAKURA_GROVE = of("blush_sakura_grove"); - public static final RegistryKey COTTON_SAKURA_GROVE = of("cotton_sakura_grove"); - public static final RegistryKey CARNELIAN_TREEWAY = of("carnelian_treeway"); - public static final RegistryKey GLACARIAN_TAIGA = of("glacarian_taiga"); + public static final ResourceKey BLUSH_SAKURA_GROVE = of("blush_sakura_grove"); + public static final ResourceKey COTTON_SAKURA_GROVE = of("cotton_sakura_grove"); + public static final ResourceKey CARNELIAN_TREEWAY = of("carnelian_treeway"); + public static final ResourceKey GLACARIAN_TAIGA = of("glacarian_taiga"); - public static final RegistryKey DARK_AMARANTH_FOREST = of("dark_amaranth_forest"); + public static final ResourceKey DARK_AMARANTH_FOREST = of("dark_amaranth_forest"); - public static final MultiNoiseUtil.NoiseHypercube DEFAULT_DARK_AMARANTH_FOREST_HYPERCUBE = MultiNoiseUtil.createNoiseHypercube(0.15f, -0.3f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f); + public static final Climate.ParameterPoint DEFAULT_DARK_AMARANTH_FOREST_HYPERCUBE = Climate.parameters(0.15f, -0.3f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f); - private static RegistryKey of(String path) { - return RegistryKey.of(RegistryKeys.BIOME, Promenade.id(path)); + private static ResourceKey of(String path) { + return ResourceKey.create(Registries.BIOME, Promenade.id(path)); } public static void appendWorldGen() { + var biomeConfig = PromenadeConfig.get().biomes(); // Sakura Groves if (biomeConfig.sakuraGrovesWeight() > 0) { double sakuraWeight = biomeConfig.sakuraGrovesWeight() / 100.0D; - BiomePlacement.replaceOverworld(BiomeKeys.FOREST, PromenadeBiomes.BLUSH_SAKURA_GROVE, sakuraWeight); - BiomePlacement.replaceOverworld(BiomeKeys.BIRCH_FOREST, PromenadeBiomes.COTTON_SAKURA_GROVE, sakuraWeight); + BiomePlacement.replaceOverworld(Biomes.FOREST, PromenadeBiomes.BLUSH_SAKURA_GROVE, sakuraWeight); + BiomePlacement.replaceOverworld(Biomes.BIRCH_FOREST, PromenadeBiomes.COTTON_SAKURA_GROVE, sakuraWeight); } // Carnelian Treeway if (biomeConfig.carnelianTreewayWeight() > 0) { - BiomePlacement.replaceOverworld(BiomeKeys.PLAINS, PromenadeBiomes.CARNELIAN_TREEWAY, biomeConfig.carnelianTreewayWeight() / 100.0D); + BiomePlacement.replaceOverworld(Biomes.PLAINS, PromenadeBiomes.CARNELIAN_TREEWAY, biomeConfig.carnelianTreewayWeight() / 100.0D); } // Glacarian Taiga if (biomeConfig.glacarianTaigaWeight() > 0) { double glacarianTaigaWeight = biomeConfig.glacarianTaigaWeight() / 100.0D; - BiomePlacement.replaceOverworld(BiomeKeys.TAIGA, PromenadeBiomes.GLACARIAN_TAIGA, glacarianTaigaWeight); - BiomePlacement.replaceOverworld(BiomeKeys.SNOWY_TAIGA, PromenadeBiomes.GLACARIAN_TAIGA, glacarianTaigaWeight); - BiomePlacement.replaceOverworld(BiomeKeys.SNOWY_SLOPES, PromenadeBiomes.GLACARIAN_TAIGA, glacarianTaigaWeight); - BiomePlacement.replaceOverworld(BiomeKeys.JAGGED_PEAKS, PromenadeBiomes.GLACARIAN_TAIGA, glacarianTaigaWeight); - BiomePlacement.replaceOverworld(BiomeKeys.GROVE, PromenadeBiomes.GLACARIAN_TAIGA, glacarianTaigaWeight); + BiomePlacement.replaceOverworld(Biomes.TAIGA, PromenadeBiomes.GLACARIAN_TAIGA, glacarianTaigaWeight); + BiomePlacement.replaceOverworld(Biomes.SNOWY_TAIGA, PromenadeBiomes.GLACARIAN_TAIGA, glacarianTaigaWeight); + BiomePlacement.replaceOverworld(Biomes.SNOWY_SLOPES, PromenadeBiomes.GLACARIAN_TAIGA, glacarianTaigaWeight); + BiomePlacement.replaceOverworld(Biomes.JAGGED_PEAKS, PromenadeBiomes.GLACARIAN_TAIGA, glacarianTaigaWeight); + BiomePlacement.replaceOverworld(Biomes.GROVE, PromenadeBiomes.GLACARIAN_TAIGA, glacarianTaigaWeight); } @@ -67,13 +68,13 @@ public static void appendWorldGen() { BiomePlacement.addNether(PromenadeBiomes.DARK_AMARANTH_FOREST, biomeConfig.darkAmaranthForestsNoise().get()); SurfaceGeneration.addNetherSurfaceRules(Promenade.id("dark_amaranth_forest"), - MaterialRules.condition(MaterialRules.STONE_DEPTH_FLOOR, - MaterialRules.sequence( - MaterialRules.condition(MaterialRules.not(MaterialRules.aboveY(YOffset.fixed(32), 0)), MaterialRules.condition(MaterialRules.hole(), VanillaSurfaceRules.block(Blocks.LAVA))), - MaterialRules.condition(MaterialRules.biome(PromenadeBiomes.DARK_AMARANTH_FOREST), - MaterialRules.condition( - MaterialRules.not(MaterialRules.noiseThreshold(NoiseParametersKeys.NETHERRACK, 0.54)), - MaterialRules.condition(MaterialRules.aboveY(YOffset.fixed(31), 0), MaterialRules.sequence(MaterialRules.condition(MaterialRules.noiseThreshold(NoiseParametersKeys.NETHER_WART, 1.17), VanillaSurfaceRules.block(PromenadeBlocks.DARK_AMARANTH_WART_BLOCK)), VanillaSurfaceRules.block(PromenadeBlocks.DARK_AMARANTH_NYLIUM))) + SurfaceRules.ifTrue(SurfaceRules.ON_FLOOR, + SurfaceRules.sequence( + SurfaceRules.ifTrue(SurfaceRules.not(SurfaceRules.yBlockCheck(VerticalAnchor.absolute(32), 0)), SurfaceRules.ifTrue(SurfaceRules.hole(), SurfaceRuleData.makeStateRule(Blocks.LAVA))), + SurfaceRules.ifTrue(SurfaceRules.isBiome(PromenadeBiomes.DARK_AMARANTH_FOREST), + SurfaceRules.ifTrue( + SurfaceRules.not(SurfaceRules.noiseCondition(Noises.NETHERRACK, 0.54)), + SurfaceRules.ifTrue(SurfaceRules.yBlockCheck(VerticalAnchor.absolute(31), 0), SurfaceRules.sequence(SurfaceRules.ifTrue(SurfaceRules.noiseCondition(Noises.NETHER_WART, 1.17), SurfaceRuleData.makeStateRule(PromenadeBlocks.DARK_AMARANTH_WART_BLOCK)), SurfaceRuleData.makeStateRule(PromenadeBlocks.DARK_AMARANTH_NYLIUM))) ) ) ) @@ -88,31 +89,31 @@ public static void appendWorldGen() { * @return true if the entity can freeze, false otherwise. */ public static boolean canFreezeFromBiomeAndWeather(LivingEntity entity) { - RegistryEntry biome = entity.getEntityWorld().getBiome(entity.getBlockPos()); - if (entity.getType().isIn(EntityTypeTags.FREEZE_IMMUNE_ENTITY_TYPES)) { + Holder biome = entity.level().getBiome(entity.blockPosition()); + if (entity.is(EntityTypeTags.FREEZE_IMMUNE_ENTITY_TYPES)) { // is immune return false; } - if (!biome.isIn(PromenadeBiomeTags.CAN_FREEZE_DURING_SNOWFALL) || entity.isSpectator()) { + if (!biome.is(PromenadeBiomeTags.CAN_FREEZE_DURING_SNOWFALL) || entity.isSpectator()) { // is not the correct biome // is spectator return false; } - if (!entity.getEntityWorld().isRaining()) { + if (!entity.level().isRaining()) { // is not snowing return false; } - boolean exposedToSky = entity.getEntityWorld().getLightLevel(LightType.SKY, entity.getBlockPos()) >= 5; - boolean lightSourceNear = entity.getEntityWorld().getLightLevel(LightType.BLOCK, entity.getBlockPos()) >= 5; + boolean exposedToSky = entity.level().getBrightness(LightLayer.SKY, entity.blockPosition()) >= 5; + boolean lightSourceNear = entity.level().getBrightness(LightLayer.BLOCK, entity.blockPosition()) >= 5; if (lightSourceNear || !exposedToSky) { // is near a light source // is not exposed much to sky return false; } // wear any leather piece - return !entity.getEquippedStack(EquipmentSlot.HEAD).isIn(ItemTags.FREEZE_IMMUNE_WEARABLES) && - !entity.getEquippedStack(EquipmentSlot.CHEST).isIn(ItemTags.FREEZE_IMMUNE_WEARABLES) && - !entity.getEquippedStack(EquipmentSlot.LEGS).isIn(ItemTags.FREEZE_IMMUNE_WEARABLES) && - !entity.getEquippedStack(EquipmentSlot.FEET).isIn(ItemTags.FREEZE_IMMUNE_WEARABLES); + return !entity.getItemBySlot(EquipmentSlot.HEAD).is(ItemTags.FREEZE_IMMUNE_WEARABLES) && + !entity.getItemBySlot(EquipmentSlot.CHEST).is(ItemTags.FREEZE_IMMUNE_WEARABLES) && + !entity.getItemBySlot(EquipmentSlot.LEGS).is(ItemTags.FREEZE_IMMUNE_WEARABLES) && + !entity.getItemBySlot(EquipmentSlot.FEET).is(ItemTags.FREEZE_IMMUNE_WEARABLES); } } diff --git a/src/main/java/fr/hugman/promenade/world/gen/feature/BoulderFeature.java b/src/main/java/fr/hugman/promenade/world/gen/feature/BoulderFeature.java index 0d3f22ac..5e5ff1ad 100644 --- a/src/main/java/fr/hugman/promenade/world/gen/feature/BoulderFeature.java +++ b/src/main/java/fr/hugman/promenade/world/gen/feature/BoulderFeature.java @@ -1,11 +1,11 @@ package fr.hugman.promenade.world.gen.feature; import com.mojang.serialization.Codec; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.random.Random; -import net.minecraft.world.StructureWorldAccess; -import net.minecraft.world.gen.feature.Feature; -import net.minecraft.world.gen.feature.util.FeatureContext; +import net.minecraft.core.BlockPos; +import net.minecraft.util.RandomSource; +import net.minecraft.world.level.WorldGenLevel; +import net.minecraft.world.level.levelgen.feature.Feature; +import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext; public class BoulderFeature extends Feature { public BoulderFeature(Codec codec) { @@ -13,20 +13,20 @@ public BoulderFeature(Codec codec) { } @Override - public boolean generate(FeatureContext context) { - Random random = context.getRandom(); - BoulderFeatureConfig config = context.getConfig(); - StructureWorldAccess world = context.getWorld(); - int radius = config.radius().get(random); - BlockPos pos = context.getOrigin(); - for (; pos.getY() > world.getBottomY() + radius; pos = pos.down()) { - if (!world.isAir(pos)) { + public boolean place(FeaturePlaceContext context) { + RandomSource random = context.random(); + BoulderFeatureConfig config = context.config(); + WorldGenLevel world = context.level(); + int radius = config.radius().sample(random); + BlockPos pos = context.origin(); + for (; pos.getY() > world.getMinY() + radius; pos = pos.below()) { + if (!world.isEmptyBlock(pos)) { if (config.replaceableBlocks().test(world, pos)) { break; } } } - if (pos.getY() <= world.getBottomY() + radius) { + if (pos.getY() <= world.getMinY() + radius) { return false; } else { for (int i = 0; i < 3; ++i) { @@ -34,12 +34,12 @@ public boolean generate(FeatureContext context) { int k = random.nextInt(radius); int l = random.nextInt(radius); float f = (float) (j + k + l) * 0.333F + 0.5F; - for (BlockPos pos2 : BlockPos.iterate(pos.add(-j, -k, -l), pos.add(j, k, l))) { - if (pos2.getSquaredDistance(pos) <= (double) (f * f)) { - this.setBlockState(world, pos2, config.stateProvider().get(random, pos)); + for (BlockPos pos2 : BlockPos.betweenClosed(pos.offset(-j, -k, -l), pos.offset(j, k, l))) { + if (pos2.distSqr(pos) <= (double) (f * f)) { + this.setBlock(world, pos2, config.stateProvider().getState(world, random, pos)); } } - pos = pos.add(-1 + random.nextInt(2), -random.nextInt(2), -1 + random.nextInt(2)); + pos = pos.offset(-1 + random.nextInt(2), -random.nextInt(2), -1 + random.nextInt(2)); } return true; } diff --git a/src/main/java/fr/hugman/promenade/world/gen/feature/BoulderFeatureConfig.java b/src/main/java/fr/hugman/promenade/world/gen/feature/BoulderFeatureConfig.java index 63ec431b..62034c3c 100644 --- a/src/main/java/fr/hugman/promenade/world/gen/feature/BoulderFeatureConfig.java +++ b/src/main/java/fr/hugman/promenade/world/gen/feature/BoulderFeatureConfig.java @@ -2,19 +2,20 @@ import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; -import net.minecraft.util.math.intprovider.IntProvider; -import net.minecraft.world.gen.blockpredicate.BlockPredicate; -import net.minecraft.world.gen.feature.FeatureConfig; -import net.minecraft.world.gen.stateprovider.BlockStateProvider; +import net.minecraft.util.valueproviders.IntProvider; +import net.minecraft.util.valueproviders.IntProviders; +import net.minecraft.world.level.levelgen.blockpredicates.BlockPredicate; +import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration; +import net.minecraft.world.level.levelgen.feature.stateproviders.BlockStateProvider; public record BoulderFeatureConfig( BlockStateProvider stateProvider, BlockPredicate replaceableBlocks, IntProvider radius -) implements FeatureConfig { +) implements FeatureConfiguration { public static final Codec CODEC = RecordCodecBuilder.create((instance) -> instance.group( - BlockStateProvider.TYPE_CODEC.fieldOf("state").forGetter((config) -> config.stateProvider), - BlockPredicate.BASE_CODEC.fieldOf("replaceable").forGetter((config) -> config.replaceableBlocks), - IntProvider.createValidatingCodec(1, 64).fieldOf("count").forGetter((config) -> config.radius) + BlockStateProvider.CODEC.fieldOf("state").forGetter((config) -> config.stateProvider), + BlockPredicate.CODEC.fieldOf("replaceable").forGetter((config) -> config.replaceableBlocks), + IntProviders.codec(1, 64).fieldOf("count").forGetter((config) -> config.radius) ).apply(instance, BoulderFeatureConfig::new)); } \ No newline at end of file diff --git a/src/main/java/fr/hugman/promenade/world/gen/feature/CoiledVinesFeature.java b/src/main/java/fr/hugman/promenade/world/gen/feature/CoiledVinesFeature.java index b047dc87..6ccfd5b6 100644 --- a/src/main/java/fr/hugman/promenade/world/gen/feature/CoiledVinesFeature.java +++ b/src/main/java/fr/hugman/promenade/world/gen/feature/CoiledVinesFeature.java @@ -2,15 +2,19 @@ import com.mojang.serialization.Codec; import fr.hugman.promenade.block.PromenadeBlocks; -import net.minecraft.block.*; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.random.Random; -import net.minecraft.world.StructureWorldAccess; -import net.minecraft.world.WorldAccess; -import net.minecraft.world.gen.feature.Feature; -import net.minecraft.world.gen.feature.util.FeatureContext; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.util.Mth; +import net.minecraft.util.RandomSource; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.WorldGenLevel; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.DirectionalBlock; +import net.minecraft.world.level.block.GrowingPlantHeadBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.levelgen.feature.Feature; +import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext; public class CoiledVinesFeature extends Feature { public CoiledVinesFeature(Codec configCodec) { @@ -18,31 +22,31 @@ public CoiledVinesFeature(Codec configCodec) { } @Override - public boolean generate(FeatureContext context) { - StructureWorldAccess structureWorldAccess = context.getWorld(); - BlockPos blockPos = context.getOrigin(); + public boolean place(FeaturePlaceContext context) { + WorldGenLevel structureWorldAccess = context.level(); + BlockPos blockPos = context.origin(); if (isNotSuitable(structureWorldAccess, blockPos, Direction.UP)) { return false; } else { - Random random = context.getRandom(); - CoiledVinesFeatureConfig config = context.getConfig(); + RandomSource random = context.random(); + CoiledVinesFeatureConfig config = context.config(); int spreadWidth = config.spreadWidth(); int spreadHeight = config.spreadHeight(); int maxLength = config.maxLength(); - BlockPos.Mutable mutable = new BlockPos.Mutable(); + BlockPos.MutableBlockPos mutable = new BlockPos.MutableBlockPos(); for (int l = 0; l < spreadWidth * spreadWidth; l++) { // Pick a random direction var direction = config.directions().get(random.nextInt(config.directions().size())); // Pick a random position mutable.set(blockPos).move( - MathHelper.nextInt(random, -spreadWidth, spreadWidth), - MathHelper.nextInt(random, -spreadHeight, spreadHeight), - MathHelper.nextInt(random, -spreadWidth, spreadWidth) + Mth.nextInt(random, -spreadWidth, spreadWidth), + Mth.nextInt(random, -spreadHeight, spreadHeight), + Mth.nextInt(random, -spreadWidth, spreadWidth) ); if (findNonAirBlock(structureWorldAccess, mutable, direction) && !isNotSuitable(structureWorldAccess, mutable, direction)) { - int lenght = MathHelper.nextInt(random, 1, maxLength); + int lenght = Mth.nextInt(random, 1, maxLength); if (random.nextInt(6) == 0) { lenght *= 2; } @@ -57,11 +61,11 @@ public boolean generate(FeatureContext context) { } } - private static boolean findNonAirBlock(WorldAccess world, BlockPos.Mutable pos, Direction direction) { + private static boolean findNonAirBlock(LevelAccessor world, BlockPos.MutableBlockPos pos, Direction direction) { int max = 16; do { pos.move(direction.getOpposite()); - if (world.isOutOfHeightLimit(pos) || max-- <= 0) { + if (world.isOutsideBuildHeight(pos) || max-- <= 0) { return false; } } while (world.getBlockState(pos).isAir()); @@ -71,42 +75,42 @@ private static boolean findNonAirBlock(WorldAccess world, BlockPos.Mutable pos, } public static void generateVineColumn( - WorldAccess world, - Random random, - BlockPos.Mutable pos, + LevelAccessor world, + RandomSource random, + BlockPos.MutableBlockPos pos, int maxLength, int minAge, int maxAge, Direction direction ) { for (int i = 1; i <= maxLength; i++) { - if (world.isAir(pos)) { - if (i == maxLength || !world.isAir(pos.offset(direction))) { - world.setBlockState( + if (world.isEmptyBlock(pos)) { + if (i == maxLength || !world.isEmptyBlock(pos.relative(direction))) { + world.setBlock( pos, - PromenadeBlocks.COILED_VINES.getDefaultState() - .with(FacingBlock.FACING, direction) - .with(AbstractPlantStemBlock.AGE, MathHelper.nextInt(random, minAge, maxAge)), - Block.NOTIFY_LISTENERS + PromenadeBlocks.COILED_VINES.defaultBlockState() + .setValue(DirectionalBlock.FACING, direction) + .setValue(GrowingPlantHeadBlock.AGE, Mth.nextInt(random, minAge, maxAge)), + Block.UPDATE_CLIENTS ); break; } - world.setBlockState(pos, PromenadeBlocks.COILED_VINES_PLANT.getDefaultState().with(FacingBlock.FACING, direction), Block.NOTIFY_LISTENERS); + world.setBlock(pos, PromenadeBlocks.COILED_VINES_PLANT.defaultBlockState().setValue(DirectionalBlock.FACING, direction), Block.UPDATE_CLIENTS); } pos.move(direction); } } - private static boolean isNotSuitable(WorldAccess world, BlockPos pos, Direction direction) { - if (!world.isAir(pos)) { + private static boolean isNotSuitable(LevelAccessor world, BlockPos pos, Direction direction) { + if (!world.isEmptyBlock(pos)) { return true; } else { - BlockState blockState = world.getBlockState(pos.offset(direction.getOpposite())); - return !blockState.isOf(Blocks.NETHERRACK) && - !blockState.isOf(PromenadeBlocks.DARK_AMARANTH_NYLIUM) && - !blockState.isOf(PromenadeBlocks.DARK_AMARANTH_WART_BLOCK); + BlockState blockState = world.getBlockState(pos.relative(direction.getOpposite())); + return !blockState.is(Blocks.NETHERRACK) && + !blockState.is(PromenadeBlocks.DARK_AMARANTH_NYLIUM) && + !blockState.is(PromenadeBlocks.DARK_AMARANTH_WART_BLOCK); } } } diff --git a/src/main/java/fr/hugman/promenade/world/gen/feature/CoiledVinesFeatureConfig.java b/src/main/java/fr/hugman/promenade/world/gen/feature/CoiledVinesFeatureConfig.java index ed4fe903..632bb35b 100644 --- a/src/main/java/fr/hugman/promenade/world/gen/feature/CoiledVinesFeatureConfig.java +++ b/src/main/java/fr/hugman/promenade/world/gen/feature/CoiledVinesFeatureConfig.java @@ -2,24 +2,23 @@ import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; -import net.minecraft.util.dynamic.Codecs; -import net.minecraft.util.math.Direction; -import net.minecraft.world.gen.feature.FeatureConfig; - import java.util.List; +import net.minecraft.core.Direction; +import net.minecraft.util.ExtraCodecs; +import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration; public record CoiledVinesFeatureConfig( int spreadWidth, int spreadHeight, int maxLength, List directions -) implements FeatureConfig { +) implements FeatureConfiguration { public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( - Codecs.POSITIVE_INT.fieldOf("spread_width").forGetter(CoiledVinesFeatureConfig::spreadWidth), - Codecs.POSITIVE_INT.fieldOf("spread_height").forGetter(CoiledVinesFeatureConfig::spreadHeight), - Codecs.POSITIVE_INT.fieldOf("max_length").forGetter(CoiledVinesFeatureConfig::maxLength), - Codecs.nonEmptyList(Direction.CODEC.listOf()).optionalFieldOf("directions", List.of(Direction.values())).forGetter(CoiledVinesFeatureConfig::directions) + ExtraCodecs.POSITIVE_INT.fieldOf("spread_width").forGetter(CoiledVinesFeatureConfig::spreadWidth), + ExtraCodecs.POSITIVE_INT.fieldOf("spread_height").forGetter(CoiledVinesFeatureConfig::spreadHeight), + ExtraCodecs.POSITIVE_INT.fieldOf("max_length").forGetter(CoiledVinesFeatureConfig::maxLength), + ExtraCodecs.nonEmptyList(Direction.CODEC.listOf()).optionalFieldOf("directions", List.of(Direction.values())).forGetter(CoiledVinesFeatureConfig::directions) ).apply(instance, CoiledVinesFeatureConfig::new) ); } diff --git a/src/main/java/fr/hugman/promenade/world/gen/feature/FreezeTopLayerFeature.java b/src/main/java/fr/hugman/promenade/world/gen/feature/FreezeTopLayerFeature.java index 4bb329bf..3e81b0d2 100644 --- a/src/main/java/fr/hugman/promenade/world/gen/feature/FreezeTopLayerFeature.java +++ b/src/main/java/fr/hugman/promenade/world/gen/feature/FreezeTopLayerFeature.java @@ -1,35 +1,39 @@ package fr.hugman.promenade.world.gen.feature; import com.mojang.serialization.Codec; -import net.minecraft.block.*; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.intprovider.ConstantIntProvider; -import net.minecraft.util.math.intprovider.UniformIntProvider; -import net.minecraft.world.Heightmap; -import net.minecraft.world.biome.Biome; -import net.minecraft.world.gen.feature.DefaultFeatureConfig; -import net.minecraft.world.gen.feature.Feature; -import net.minecraft.world.gen.feature.util.FeatureContext; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.util.valueproviders.ConstantInt; +import net.minecraft.util.valueproviders.UniformInt; +import net.minecraft.world.level.biome.Biome; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.SnowLayerBlock; +import net.minecraft.world.level.block.SnowyBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.levelgen.Heightmap; +import net.minecraft.world.level.levelgen.feature.Feature; +import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext; +import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration; -public class FreezeTopLayerFeature extends Feature { - public FreezeTopLayerFeature(Codec codec) { +public class FreezeTopLayerFeature extends Feature { + public FreezeTopLayerFeature(Codec codec) { super(codec); } @Override - public boolean generate(FeatureContext context) { - var world = context.getWorld(); - var random = context.getRandom(); - var blockPos = context.getOrigin(); - var topMutable = new BlockPos.Mutable(); - var groundMutable = new BlockPos.Mutable(); - var undergroundMutable = new BlockPos.Mutable(); + public boolean place(FeaturePlaceContext context) { + var world = context.level(); + var random = context.random(); + var blockPos = context.origin(); + var topMutable = new BlockPos.MutableBlockPos(); + var groundMutable = new BlockPos.MutableBlockPos(); + var undergroundMutable = new BlockPos.MutableBlockPos(); - var snowDepth = ConstantIntProvider.create(3); - var topSnowLayers = UniformIntProvider.create(2, 3); - var packedIceDepth = UniformIntProvider.create(2, 3); - var normalIceDepth = UniformIntProvider.create(2, 3); + var snowDepth = ConstantInt.of(3); + var topSnowLayers = UniformInt.of(2, 3); + var packedIceDepth = UniformInt.of(2, 3); + var normalIceDepth = UniformInt.of(2, 3); for (int i = 0; i < 16; ++i) { for (int j = 0; j < 16; ++j) { @@ -39,41 +43,41 @@ public boolean generate(FeatureContext context) { /* ==================== */ /* SURFACE GROUND LEVEL */ /* ==================== */ - topMutable.set(x, world.getTopY(Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, x, z), z); + topMutable.set(x, world.getHeight(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, x, z), z); Biome biome = world.getBiome(topMutable).value(); groundMutable.set(topMutable).move(Direction.DOWN, 1); // Layers of Snow - if (biome.canSetSnow(world, topMutable)) { - for (int n = 1; n <= snowDepth.get(random); n++) { - if (!biome.canSetSnow(world, topMutable)) { + if (biome.shouldSnow(world, topMutable)) { + for (int n = 1; n <= snowDepth.sample(random); n++) { + if (!biome.shouldSnow(world, topMutable)) { break; } - world.setBlockState(topMutable, Blocks.SNOW_BLOCK.getDefaultState(), Block.NOTIFY_LISTENERS); + world.setBlock(topMutable, Blocks.SNOW_BLOCK.defaultBlockState(), Block.UPDATE_CLIENTS); topMutable.move(Direction.UP, 1); } BlockState blockState = world.getBlockState(groundMutable); - if (blockState.contains(SnowyBlock.SNOWY)) { - world.setBlockState(groundMutable, blockState.with(SnowyBlock.SNOWY, true), Block.NOTIFY_LISTENERS); + if (blockState.hasProperty(SnowyBlock.SNOWY)) { + world.setBlock(groundMutable, blockState.setValue(SnowyBlock.SNOWY, true), Block.UPDATE_CLIENTS); } } // Water -> Ice - if (biome.canSetIce(world, groundMutable, false)) { + if (biome.shouldFreeze(world, groundMutable, false)) { undergroundMutable.set(groundMutable); - for (int n = 1; n <= packedIceDepth.get(random); n++) { - if (!biome.canSetIce(world, undergroundMutable, false)) { + for (int n = 1; n <= packedIceDepth.sample(random); n++) { + if (!biome.shouldFreeze(world, undergroundMutable, false)) { break; } - world.setBlockState(undergroundMutable, Blocks.PACKED_ICE.getDefaultState(), Block.NOTIFY_LISTENERS); + world.setBlock(undergroundMutable, Blocks.PACKED_ICE.defaultBlockState(), Block.UPDATE_CLIENTS); undergroundMutable.move(Direction.DOWN, 1); } - for (int n = 1; n <= normalIceDepth.get(random); n++) { - if (!biome.canSetIce(world, undergroundMutable, false)) { + for (int n = 1; n <= normalIceDepth.sample(random); n++) { + if (!biome.shouldFreeze(world, undergroundMutable, false)) { break; } - world.setBlockState(undergroundMutable, Blocks.ICE.getDefaultState(), Block.NOTIFY_LISTENERS); + world.setBlock(undergroundMutable, Blocks.ICE.defaultBlockState(), Block.UPDATE_CLIENTS); undergroundMutable.move(Direction.DOWN, 1); } } @@ -81,17 +85,17 @@ public boolean generate(FeatureContext context) { /* ======================= */ /* SURFACE MOTION BLOCKING */ /* ======================= */ - topMutable.set(x, world.getTopY(Heightmap.Type.MOTION_BLOCKING, x, z), z); + topMutable.set(x, world.getHeight(Heightmap.Types.MOTION_BLOCKING, x, z), z); groundMutable.set(topMutable).move(Direction.DOWN, 1); biome = world.getBiome(topMutable).value(); // just in case I guess? // Thin Snow - if (biome.canSetSnow(world, topMutable)) { - world.setBlockState(topMutable, Blocks.SNOW.getDefaultState().with(SnowBlock.LAYERS, topSnowLayers.get(random)), Block.NOTIFY_LISTENERS); + if (biome.shouldSnow(world, topMutable)) { + world.setBlock(topMutable, Blocks.SNOW.defaultBlockState().setValue(SnowLayerBlock.LAYERS, topSnowLayers.sample(random)), Block.UPDATE_CLIENTS); BlockState blockState = world.getBlockState(groundMutable); - if (blockState.contains(SnowyBlock.SNOWY)) { - world.setBlockState(groundMutable, blockState.with(SnowyBlock.SNOWY, true), Block.NOTIFY_LISTENERS); + if (blockState.hasProperty(SnowyBlock.SNOWY)) { + world.setBlock(groundMutable, blockState.setValue(SnowyBlock.SNOWY, true), Block.UPDATE_CLIENTS); } } } diff --git a/src/main/java/fr/hugman/promenade/world/gen/feature/NoisePickedFeature.java b/src/main/java/fr/hugman/promenade/world/gen/feature/NoisePickedFeature.java index 3eda3fc9..047a8c3e 100644 --- a/src/main/java/fr/hugman/promenade/world/gen/feature/NoisePickedFeature.java +++ b/src/main/java/fr/hugman/promenade/world/gen/feature/NoisePickedFeature.java @@ -1,9 +1,9 @@ package fr.hugman.promenade.world.gen.feature; import com.mojang.serialization.Codec; -import net.minecraft.world.biome.Biome; -import net.minecraft.world.gen.feature.Feature; -import net.minecraft.world.gen.feature.util.FeatureContext; +import net.minecraft.world.level.biome.Biome; +import net.minecraft.world.level.levelgen.feature.Feature; +import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext; public class NoisePickedFeature extends Feature { public NoisePickedFeature(Codec codec) { @@ -11,21 +11,21 @@ public NoisePickedFeature(Codec codec) { } @Override - public boolean generate(FeatureContext context) { - var pos = context.getOrigin(); - var random = context.getRandom(); - var structureWorldAccess = context.getWorld(); - var chunkGenerator = context.getGenerator(); - var config = context.getConfig(); + public boolean place(FeaturePlaceContext context) { + var pos = context.origin(); + var random = context.random(); + var structureWorldAccess = context.level(); + var chunkGenerator = context.chunkGenerator(); + var config = context.config(); - double noiseValue = Biome.FOLIAGE_NOISE.sample((double) pos.getX() / config.noiseScale().x(), (double) pos.getZ() / config.noiseScale().z(), false); + double noiseValue = Biome.BIOME_INFO_NOISE.getValue((double) pos.getX() / config.noiseScale().x(), (double) pos.getZ() / config.noiseScale().z(), false); var entries = config.entries().stream() .filter(entry -> entry.min() < noiseValue && noiseValue < entry.max()) .toList(); if (entries.isEmpty()) { return false; } - var entry = entries.get(context.getRandom().nextInt(entries.size())); + var entry = entries.get(context.random().nextInt(entries.size())); return entry.generate(structureWorldAccess, chunkGenerator, random, pos); } } diff --git a/src/main/java/fr/hugman/promenade/world/gen/feature/NoisePickedFeatureConfig.java b/src/main/java/fr/hugman/promenade/world/gen/feature/NoisePickedFeatureConfig.java index 8e79c96c..12e85131 100644 --- a/src/main/java/fr/hugman/promenade/world/gen/feature/NoisePickedFeatureConfig.java +++ b/src/main/java/fr/hugman/promenade/world/gen/feature/NoisePickedFeatureConfig.java @@ -3,23 +3,24 @@ import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; import fr.hugman.promenade.util.NoiseScale; -import net.minecraft.world.gen.feature.ConfiguredFeature; -import net.minecraft.world.gen.feature.FeatureConfig; - import java.util.List; import java.util.stream.Stream; +import net.minecraft.core.Holder; +import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; +import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration; + public record NoisePickedFeatureConfig( NoiseScale noiseScale, List entries -) implements FeatureConfig { +) implements FeatureConfiguration { public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( NoiseScale.CODEC.fieldOf("noise").forGetter(NoisePickedFeatureConfig::noiseScale), NoisePickedFeatureEntry.CODEC.listOf().fieldOf("entries").forGetter(NoisePickedFeatureConfig::entries) ).apply(instance, NoisePickedFeatureConfig::new)); @Override - public Stream> getDecoratedFeatures() { - return entries.stream().flatMap(entry -> entry.feature().value().getDecoratedFeatures()); + public Stream>> getSubFeatures() { + return entries.stream().flatMap(entry -> entry.feature().value().getFeatures()); } } diff --git a/src/main/java/fr/hugman/promenade/world/gen/feature/NoisePickedFeatureEntry.java b/src/main/java/fr/hugman/promenade/world/gen/feature/NoisePickedFeatureEntry.java index dd8c8e26..fbbea840 100644 --- a/src/main/java/fr/hugman/promenade/world/gen/feature/NoisePickedFeatureEntry.java +++ b/src/main/java/fr/hugman/promenade/world/gen/feature/NoisePickedFeatureEntry.java @@ -3,25 +3,25 @@ import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; import fr.hugman.promenade.codec.PromenadeCodecs; -import net.minecraft.registry.entry.RegistryEntry; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.random.Random; -import net.minecraft.world.StructureWorldAccess; -import net.minecraft.world.gen.chunk.ChunkGenerator; -import net.minecraft.world.gen.feature.PlacedFeature; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Holder; +import net.minecraft.util.RandomSource; +import net.minecraft.world.level.WorldGenLevel; +import net.minecraft.world.level.chunk.ChunkGenerator; +import net.minecraft.world.level.levelgen.placement.PlacedFeature; public record NoisePickedFeatureEntry( - RegistryEntry feature, + Holder feature, float min, float max ) { public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( - PlacedFeature.REGISTRY_CODEC.fieldOf("feature").forGetter(NoisePickedFeatureEntry::feature), + PlacedFeature.CODEC.fieldOf("feature").forGetter(NoisePickedFeatureEntry::feature), PromenadeCodecs.SAMPLED_NOISE_VALUE.fieldOf("min").forGetter(NoisePickedFeatureEntry::min), PromenadeCodecs.SAMPLED_NOISE_VALUE.fieldOf("max").forGetter(NoisePickedFeatureEntry::max) ).apply(instance, NoisePickedFeatureEntry::new)); - public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos) { - return this.feature.value().generateUnregistered(world, chunkGenerator, random, pos); + public boolean generate(WorldGenLevel world, ChunkGenerator chunkGenerator, RandomSource random, BlockPos pos) { + return this.feature.value().place(world, chunkGenerator, random, pos); } } diff --git a/src/main/java/fr/hugman/promenade/world/gen/feature/PromenadeConfiguredFeatures.java b/src/main/java/fr/hugman/promenade/world/gen/feature/PromenadeConfiguredFeatures.java index d8a77bc1..381a1bec 100644 --- a/src/main/java/fr/hugman/promenade/world/gen/feature/PromenadeConfiguredFeatures.java +++ b/src/main/java/fr/hugman/promenade/world/gen/feature/PromenadeConfiguredFeatures.java @@ -1,86 +1,85 @@ package fr.hugman.promenade.world.gen.feature; import fr.hugman.promenade.Promenade; -import net.minecraft.registry.RegistryKey; -import net.minecraft.registry.RegistryKeys; -import net.minecraft.world.gen.feature.ConfiguredFeature; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; public class PromenadeConfiguredFeatures { // Ores - public static final RegistryKey> PACKED_ICE_ORE = of("ore/packed_ice"); - public static final RegistryKey> BLUE_ICE_ORE = of("ore/blue_ice"); + public static final ResourceKey> PACKED_ICE_ORE = of("ore/packed_ice"); + public static final ResourceKey> BLUE_ICE_ORE = of("ore/blue_ice"); - public static final RegistryKey> ASPHALT_ORE = of("ore/asphalt"); - public static final RegistryKey> BLUNITE_ORE = of("ore/blunite"); + public static final ResourceKey> ASPHALT_ORE = of("ore/asphalt"); + public static final ResourceKey> BLUNITE_ORE = of("ore/blunite"); // Trees - public static final RegistryKey> BLUSH_SAKURA = of("tree/sakura/blush/regular"); - public static final RegistryKey> FANCY_BLUSH_SAKURA = of("tree/sakura/blush/fancy"); - public static final RegistryKey> BLUSH_SAKURA_BEES = of("tree/sakura/blush/bees"); - public static final RegistryKey> FANCY_BLUSH_SAKURA_BEES = of("tree/sakura/blush/fancy_bees"); + public static final ResourceKey> BLUSH_SAKURA = of("tree/sakura/blush/regular"); + public static final ResourceKey> FANCY_BLUSH_SAKURA = of("tree/sakura/blush/fancy"); + public static final ResourceKey> BLUSH_SAKURA_BEES = of("tree/sakura/blush/bees"); + public static final ResourceKey> FANCY_BLUSH_SAKURA_BEES = of("tree/sakura/blush/fancy_bees"); - public static final RegistryKey> COTTON_SAKURA = of("tree/sakura/cotton/regular"); - public static final RegistryKey> FANCY_COTTON_SAKURA = of("tree/sakura/cotton/fancy"); - public static final RegistryKey> COTTON_SAKURA_BEES = of("tree/sakura/cotton/bees"); - public static final RegistryKey> FANCY_COTTON_SAKURA_BEES = of("tree/sakura/cotton/fancy_bees"); + public static final ResourceKey> COTTON_SAKURA = of("tree/sakura/cotton/regular"); + public static final ResourceKey> FANCY_COTTON_SAKURA = of("tree/sakura/cotton/fancy"); + public static final ResourceKey> COTTON_SAKURA_BEES = of("tree/sakura/cotton/bees"); + public static final ResourceKey> FANCY_COTTON_SAKURA_BEES = of("tree/sakura/cotton/fancy_bees"); - public static final RegistryKey> SAP_MAPLE = of("tree/maple/sap/regular"); - public static final RegistryKey> FANCY_SAP_MAPLE = of("tree/maple/sap/fancy"); - public static final RegistryKey> SAP_MAPLE_BEES = of("tree/maple/sap/bees"); - public static final RegistryKey> FANCY_SAP_MAPLE_BEES = of("tree/maple/sap/fancy_bees"); + public static final ResourceKey> SAP_MAPLE = of("tree/maple/sap/regular"); + public static final ResourceKey> FANCY_SAP_MAPLE = of("tree/maple/sap/fancy"); + public static final ResourceKey> SAP_MAPLE_BEES = of("tree/maple/sap/bees"); + public static final ResourceKey> FANCY_SAP_MAPLE_BEES = of("tree/maple/sap/fancy_bees"); - public static final RegistryKey> VERMILION_MAPLE = of("tree/maple/vermilion/regular"); - public static final RegistryKey> FANCY_VERMILION_MAPLE = of("tree/maple/vermilion/fancy"); - public static final RegistryKey> VERMILION_MAPLE_BEES = of("tree/maple/vermilion/bees"); - public static final RegistryKey> FANCY_VERMILION_MAPLE_BEES = of("tree/maple/vermilion/fancy_bees"); + public static final ResourceKey> VERMILION_MAPLE = of("tree/maple/vermilion/regular"); + public static final ResourceKey> FANCY_VERMILION_MAPLE = of("tree/maple/vermilion/fancy"); + public static final ResourceKey> VERMILION_MAPLE_BEES = of("tree/maple/vermilion/bees"); + public static final ResourceKey> FANCY_VERMILION_MAPLE_BEES = of("tree/maple/vermilion/fancy_bees"); - public static final RegistryKey> FULVOUS_MAPLE = of("tree/maple/fulvous/regular"); - public static final RegistryKey> FANCY_FULVOUS_MAPLE = of("tree/maple/fulvous/fancy"); - public static final RegistryKey> FULVOUS_MAPLE_BEES = of("tree/maple/fulvous/bees"); - public static final RegistryKey> FANCY_FULVOUS_MAPLE_BEES = of("tree/maple/fulvous/fancy_bees"); + public static final ResourceKey> FULVOUS_MAPLE = of("tree/maple/fulvous/regular"); + public static final ResourceKey> FANCY_FULVOUS_MAPLE = of("tree/maple/fulvous/fancy"); + public static final ResourceKey> FULVOUS_MAPLE_BEES = of("tree/maple/fulvous/bees"); + public static final ResourceKey> FANCY_FULVOUS_MAPLE_BEES = of("tree/maple/fulvous/fancy_bees"); - public static final RegistryKey> MIKADO_MAPLE = of("tree/maple/mikado/regular"); - public static final RegistryKey> FANCY_MIKADO_MAPLE = of("tree/maple/mikado/fancy"); - public static final RegistryKey> MIKADO_MAPLE_BEES = of("tree/maple/mikado/bees"); - public static final RegistryKey> FANCY_MIKADO_MAPLE_BEES = of("tree/maple/mikado/fancy_bees"); + public static final ResourceKey> MIKADO_MAPLE = of("tree/maple/mikado/regular"); + public static final ResourceKey> FANCY_MIKADO_MAPLE = of("tree/maple/mikado/fancy"); + public static final ResourceKey> MIKADO_MAPLE_BEES = of("tree/maple/mikado/bees"); + public static final ResourceKey> FANCY_MIKADO_MAPLE_BEES = of("tree/maple/mikado/fancy_bees"); - public static final RegistryKey> PALM = of("tree/palm"); + public static final ResourceKey> PALM = of("tree/palm"); - public static final RegistryKey> SNOWY_MEGA_SPRUCE = of("tree/snowy_mega_spruce"); + public static final ResourceKey> SNOWY_MEGA_SPRUCE = of("tree/snowy_mega_spruce"); - public static final RegistryKey> DARK_AMARANTH_FUNGUS = of("tree/dark_amaranth_fungus"); - public static final RegistryKey> PLANTED_DARK_AMARANTH_FUNGUS = of("tree/dark_amaranth_fungus_planted"); + public static final ResourceKey> DARK_AMARANTH_FUNGUS = of("tree/dark_amaranth_fungus"); + public static final ResourceKey> PLANTED_DARK_AMARANTH_FUNGUS = of("tree/dark_amaranth_fungus_planted"); // Randomized trees - public static final RegistryKey> BLUSH_SAKURA_GROVE_TREE = of("tree/blush_sakura_grove"); - public static final RegistryKey> COTTON_SAKURA_GROVE_TREE = of("tree/cotton_sakura_grove"); + public static final ResourceKey> BLUSH_SAKURA_GROVE_TREE = of("tree/blush_sakura_grove"); + public static final ResourceKey> COTTON_SAKURA_GROVE_TREE = of("tree/cotton_sakura_grove"); - public static final RegistryKey> CARNELIAN_TREEWAY_SAP_TREE = of("tree/carnelian_treeway/sap"); - public static final RegistryKey> CARNELIAN_TREEWAY_VERMILION_TREE = of("tree/carnelian_treeway/vermilion"); - public static final RegistryKey> CARNELIAN_TREEWAY_FULVOUS_TREE = of("tree/carnelian_treeway/fulvous"); - public static final RegistryKey> CARNELIAN_TREEWAY_MIKADO_TREE = of("tree/carnelian_treeway/mikado"); + public static final ResourceKey> CARNELIAN_TREEWAY_SAP_TREE = of("tree/carnelian_treeway/sap"); + public static final ResourceKey> CARNELIAN_TREEWAY_VERMILION_TREE = of("tree/carnelian_treeway/vermilion"); + public static final ResourceKey> CARNELIAN_TREEWAY_FULVOUS_TREE = of("tree/carnelian_treeway/fulvous"); + public static final ResourceKey> CARNELIAN_TREEWAY_MIKADO_TREE = of("tree/carnelian_treeway/mikado"); - public static final RegistryKey> CARNELIAN_TREEWAY_TREE = of("tree/carnelian_treeway"); - public static final RegistryKey> CARNELIAN_TREEWAY_FALLEN_LEAVES = of("patch/carnelian_treeway/fallen_leaves"); + public static final ResourceKey> CARNELIAN_TREEWAY_TREE = of("tree/carnelian_treeway"); // Vegetation - public static final RegistryKey> WATER_POOL_GRAVEL_DECORATED = of("water_pool_gravel_decorated"); + public static final ResourceKey> WATER_POOL_GRAVEL_DECORATED = of("water_pool_gravel_decorated"); - public static final RegistryKey> CUTE_LITTLE_ROCK = of("cute_little_rock"); + public static final ResourceKey> CUTE_LITTLE_ROCK = of("cute_little_rock"); - public static final RegistryKey> BAMBOO_PATCH = of("bamboo_patch"); - public static final RegistryKey> BLUEBERRY_BUSH_PATCH = of("blueberry_bush_patch"); + public static final ResourceKey> BLUEBERRY_BUSH = of("blueberry_bush"); - public static final RegistryKey> DARK_AMARANTH_FOREST_VEGETATION = of("dark_amaranth_forest_vegetation"); - public static final RegistryKey> DARK_AMARANTH_FOREST_BONEMEAL_VEGETATION = of("dark_amaranth_forest_vegetation/bonemeal"); + public static final ResourceKey> DARK_AMARANTH_FOREST_VEGETATION = of("dark_amaranth_forest_vegetation"); + public static final ResourceKey> DARK_AMARANTH_FOREST_BONEMEAL_VEGETATION = of("dark_amaranth_forest_vegetation/bonemeal"); - public static final RegistryKey> COILED_VINES = of("coiled_vines"); + public static final ResourceKey> COILED_VINES = of("coiled_vines"); - public static final RegistryKey> FALLEN_VERMILION_MAPLE_LEAVES = of("patch/fallen_vermilion_maple_leaves"); - public static final RegistryKey> FALLEN_FULVOUS_MAPLE_LEAVES = of("patch/fallen_fulvous_maple_leaves"); - public static final RegistryKey> FALLEN_MIKADO_MAPLE_LEAVES = of("patch/fallen_mikado_maple_leaves"); + public static final ResourceKey> FALLEN_VERMILION_MAPLE_LEAVES = of("fallen_vermilion_maple_leaves"); + public static final ResourceKey> FALLEN_FULVOUS_MAPLE_LEAVES = of("fallen_fulvous_maple_leaves"); + public static final ResourceKey> FALLEN_MIKADO_MAPLE_LEAVES = of("fallen_mikado_maple_leaves"); + public static final ResourceKey> CARNELIAN_TREEWAY_FALLEN_LEAVES = of("carnelian_treeway/fallen_leaves"); - private static RegistryKey> of(String path) { - return RegistryKey.of(RegistryKeys.CONFIGURED_FEATURE, Promenade.id(path)); + private static ResourceKey> of(String path) { + return ResourceKey.create(Registries.CONFIGURED_FEATURE, Promenade.id(path)); } } diff --git a/src/main/java/fr/hugman/promenade/world/gen/feature/PromenadeFeatures.java b/src/main/java/fr/hugman/promenade/world/gen/feature/PromenadeFeatures.java index 598e9854..08e61e2d 100644 --- a/src/main/java/fr/hugman/promenade/world/gen/feature/PromenadeFeatures.java +++ b/src/main/java/fr/hugman/promenade/world/gen/feature/PromenadeFeatures.java @@ -1,22 +1,22 @@ package fr.hugman.promenade.world.gen.feature; import fr.hugman.promenade.Promenade; -import net.minecraft.registry.Registries; -import net.minecraft.registry.Registry; -import net.minecraft.world.gen.feature.DefaultFeatureConfig; -import net.minecraft.world.gen.feature.Feature; -import net.minecraft.world.gen.feature.FeatureConfig; -import net.minecraft.world.gen.feature.HugeFungusFeatureConfig; +import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.world.level.levelgen.feature.Feature; +import net.minecraft.world.level.levelgen.feature.HugeFungusConfiguration; +import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration; +import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration; public class PromenadeFeatures { - public static final Feature TALL_HUGE_FUNGUS = of("tall_huge_fungus", new TallHugeFungusFeature(HugeFungusFeatureConfig.CODEC)); + public static final Feature TALL_HUGE_FUNGUS = of("tall_huge_fungus", new TallHugeFungusFeature(HugeFungusConfiguration.CODEC)); public static final Feature COILED_VINES = of("coiled_vines", new CoiledVinesFeature(CoiledVinesFeatureConfig.CODEC)); public static final Feature NOISE_PICKED = of("noised_picked", new NoisePickedFeature(NoisePickedFeatureConfig.CODEC)); public static final Feature BOULDER = of("boulder", new BoulderFeature(BoulderFeatureConfig.CODEC)); - public static final FreezeTopLayerFeature FREEZE_TOP_LAYER = of("freeze_top_layer", new FreezeTopLayerFeature(DefaultFeatureConfig.CODEC)); + public static final FreezeTopLayerFeature FREEZE_TOP_LAYER = of("freeze_top_layer", new FreezeTopLayerFeature(NoneFeatureConfiguration.CODEC)); - private static > F of(String path, F feature) { - return Registry.register(Registries.FEATURE, Promenade.id(path), feature); + private static > F of(String path, F feature) { + return Registry.register(BuiltInRegistries.FEATURE, Promenade.id(path), feature); } } diff --git a/src/main/java/fr/hugman/promenade/world/gen/feature/PromenadePlacedFeatures.java b/src/main/java/fr/hugman/promenade/world/gen/feature/PromenadePlacedFeatures.java index 858b54bd..6e86a6c9 100644 --- a/src/main/java/fr/hugman/promenade/world/gen/feature/PromenadePlacedFeatures.java +++ b/src/main/java/fr/hugman/promenade/world/gen/feature/PromenadePlacedFeatures.java @@ -6,109 +6,108 @@ import net.fabricmc.fabric.api.biome.v1.BiomeModifications; import net.fabricmc.fabric.api.biome.v1.BiomeSelectionContext; import net.fabricmc.fabric.api.biome.v1.BiomeSelectors; -import net.minecraft.registry.RegistryKey; -import net.minecraft.registry.RegistryKeys; -import net.minecraft.world.gen.GenerationStep; -import net.minecraft.world.gen.feature.OreConfiguredFeatures; -import net.minecraft.world.gen.feature.PlacedFeature; -import net.minecraft.world.gen.feature.VegetationPlacedFeatures; - +import net.minecraft.core.registries.Registries; +import net.minecraft.data.worldgen.features.OreFeatures; +import net.minecraft.data.worldgen.placement.VegetationPlacements; +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.level.levelgen.GenerationStep; +import net.minecraft.world.level.levelgen.placement.PlacedFeature; import java.util.function.Predicate; public class PromenadePlacedFeatures { // Ores - public static final RegistryKey ORE_ASPHALT_UPPER = of("ore/asphalt/upper"); - public static final RegistryKey ORE_ASPHALT_LOWER = of("ore/asphalt/lower"); - public static final RegistryKey ORE_BLUNITE_UPPER = of("ore/blunite/upper"); - public static final RegistryKey ORE_BLUNITE_LOWER = of("ore/blunite/lower"); + public static final ResourceKey ORE_ASPHALT_UPPER = of("ore/asphalt/upper"); + public static final ResourceKey ORE_ASPHALT_LOWER = of("ore/asphalt/lower"); + public static final ResourceKey ORE_BLUNITE_UPPER = of("ore/blunite/upper"); + public static final ResourceKey ORE_BLUNITE_LOWER = of("ore/blunite/lower"); - public static final RegistryKey PACKED_ICE_ORE = of("ore/packed_ice"); - public static final RegistryKey BLUE_ICE_ORE = of("ore/blue_ice"); + public static final ResourceKey PACKED_ICE_ORE = of("ore/packed_ice"); + public static final ResourceKey BLUE_ICE_ORE = of("ore/blue_ice"); // Trees - public static final RegistryKey BLUSH_SAKURA = of("tree/blush_sakura"); - public static final RegistryKey FANCY_BLUSH_SAKURA = of("tree/fancy_blush_sakura"); - public static final RegistryKey BLUSH_SAKURA_BEES = of("tree/blush_sakura_bees"); - public static final RegistryKey FANCY_BLUSH_SAKURA_BEES = of("tree/fancy_blush_sakura_bees"); - - public static final RegistryKey COTTON_SAKURA = of("tree/cotton_sakura"); - public static final RegistryKey FANCY_COTTON_SAKURA = of("tree/fancy_cotton_sakura"); - public static final RegistryKey COTTON_SAKURA_BEES = of("tree/cotton_sakura_bees"); - public static final RegistryKey FANCY_COTTON_SAKURA_BEES = of("tree/fancy_cotton_sakura_bees"); - - public static final RegistryKey SAP_MAPLE = of("tree/sap_maple"); - public static final RegistryKey FANCY_SAP_MAPLE = of("tree/fancy_sap_maple"); - public static final RegistryKey SAP_MAPLE_BEES = of("tree/sap_maple_bees"); - public static final RegistryKey FANCY_SAP_MAPLE_BEES = of("tree/fancy_sap_maple_bees"); - - public static final RegistryKey VERMILION_MAPLE = of("tree/vermilion_maple"); - public static final RegistryKey FANCY_VERMILION_MAPLE = of("tree/fancy_vermilion_maple"); - public static final RegistryKey VERMILION_MAPLE_BEES = of("tree/vermilion_maple_bees"); - public static final RegistryKey FANCY_VERMILION_MAPLE_BEES = of("tree/fancy_vermilion_maple_bees"); - - public static final RegistryKey FULVOUS_MAPLE = of("tree/fulvous_maple"); - public static final RegistryKey FANCY_FULVOUS_MAPLE = of("tree/fancy_fulvous_maple"); - public static final RegistryKey FULVOUS_MAPLE_BEES = of("tree/fulvous_maple_bees"); - public static final RegistryKey FANCY_FULVOUS_MAPLE_BEES = of("tree/fancy_fulvous_maple_bees"); - - public static final RegistryKey MIKADO_MAPLE = of("tree/mikado_maple"); - public static final RegistryKey FANCY_MIKADO_MAPLE = of("tree/fancy_mikado_maple"); - public static final RegistryKey MIKADO_MAPLE_BEES = of("tree/mikado_maple_bees"); - public static final RegistryKey FANCY_MIKADO_MAPLE_BEES = of("tree/fancy_mikado_maple_bees"); + public static final ResourceKey BLUSH_SAKURA = of("tree/blush_sakura"); + public static final ResourceKey FANCY_BLUSH_SAKURA = of("tree/fancy_blush_sakura"); + public static final ResourceKey BLUSH_SAKURA_BEES = of("tree/blush_sakura_bees"); + public static final ResourceKey FANCY_BLUSH_SAKURA_BEES = of("tree/fancy_blush_sakura_bees"); + + public static final ResourceKey COTTON_SAKURA = of("tree/cotton_sakura"); + public static final ResourceKey FANCY_COTTON_SAKURA = of("tree/fancy_cotton_sakura"); + public static final ResourceKey COTTON_SAKURA_BEES = of("tree/cotton_sakura_bees"); + public static final ResourceKey FANCY_COTTON_SAKURA_BEES = of("tree/fancy_cotton_sakura_bees"); + + public static final ResourceKey SAP_MAPLE = of("tree/sap_maple"); + public static final ResourceKey FANCY_SAP_MAPLE = of("tree/fancy_sap_maple"); + public static final ResourceKey SAP_MAPLE_BEES = of("tree/sap_maple_bees"); + public static final ResourceKey FANCY_SAP_MAPLE_BEES = of("tree/fancy_sap_maple_bees"); + + public static final ResourceKey VERMILION_MAPLE = of("tree/vermilion_maple"); + public static final ResourceKey FANCY_VERMILION_MAPLE = of("tree/fancy_vermilion_maple"); + public static final ResourceKey VERMILION_MAPLE_BEES = of("tree/vermilion_maple_bees"); + public static final ResourceKey FANCY_VERMILION_MAPLE_BEES = of("tree/fancy_vermilion_maple_bees"); + + public static final ResourceKey FULVOUS_MAPLE = of("tree/fulvous_maple"); + public static final ResourceKey FANCY_FULVOUS_MAPLE = of("tree/fancy_fulvous_maple"); + public static final ResourceKey FULVOUS_MAPLE_BEES = of("tree/fulvous_maple_bees"); + public static final ResourceKey FANCY_FULVOUS_MAPLE_BEES = of("tree/fancy_fulvous_maple_bees"); + + public static final ResourceKey MIKADO_MAPLE = of("tree/mikado_maple"); + public static final ResourceKey FANCY_MIKADO_MAPLE = of("tree/fancy_mikado_maple"); + public static final ResourceKey MIKADO_MAPLE_BEES = of("tree/mikado_maple_bees"); + public static final ResourceKey FANCY_MIKADO_MAPLE_BEES = of("tree/fancy_mikado_maple_bees"); // Vegetation - public static final RegistryKey BLUEBERRY_BUSH_COMMON_PATCH = of("patch/blueberry_bush/common"); - public static final RegistryKey BLUEBERRY_BUSH_RARE_PATCH = of("patch/blueberry_bush/rare"); + public static final ResourceKey BLUEBERRY_BUSH_COMMON_PATCH = of("patch/blueberry_bush/common"); + public static final ResourceKey BLUEBERRY_BUSH_RARE_PATCH = of("patch/blueberry_bush/rare"); - public static final RegistryKey SAKURA_GROVE_BAMBOO = of("sakura_grove_bamboo"); + public static final ResourceKey SAKURA_GROVE_BAMBOO = of("sakura_grove_bamboo"); - public static final RegistryKey CUTE_LITTLE_ROCKS = of("cute_little_rocks"); + public static final ResourceKey CUTE_LITTLE_ROCKS = of("cute_little_rocks"); - public static final RegistryKey WATER_POOLS_GRAVEL_DECORATED = of("water_pools/gravel_decorated"); + public static final ResourceKey WATER_POOLS_GRAVEL_DECORATED = of("water_pools/gravel_decorated"); - public static final RegistryKey FREEZE_TOP_LAYER = of("freeze_top_layer"); + public static final ResourceKey FREEZE_TOP_LAYER = of("freeze_top_layer"); - public static final RegistryKey DARK_AMARANTH_FOREST_VEGETATION = of("dark_amaranth_forest_vegetation"); + public static final ResourceKey DARK_AMARANTH_FOREST_VEGETATION = of("dark_amaranth_forest_vegetation"); - public static final RegistryKey COILED_VINES = of("coiled_vines"); + public static final ResourceKey COILED_VINES = of("coiled_vines"); - public static final RegistryKey FALLEN_VERMILION_MAPLE_LEAVES = of("patch/fallen_vermilion_maple_leaves"); - public static final RegistryKey FALLEN_FULVOUS_MAPLE_LEAVES = of("patch/fallen_fulvous_maple_leaves"); - public static final RegistryKey FALLEN_MIKADO_MAPLE_LEAVES = of("patch/fallen_mikado_maple_leaves"); + public static final ResourceKey FALLEN_VERMILION_MAPLE_LEAVES = of("fallen_vermilion_maple_leaves"); + public static final ResourceKey FALLEN_FULVOUS_MAPLE_LEAVES = of("fallen_fulvous_maple_leaves"); + public static final ResourceKey FALLEN_MIKADO_MAPLE_LEAVES = of("fallen_mikado_maple_leaves"); // Grouped features - public static final RegistryKey BLUSH_SAKURA_GROVE_TREES = of("trees/blush_sakura_grove"); - public static final RegistryKey COTTON_SAKURA_GROVE_TREES = of("trees/cotton_sakura_grove"); + public static final ResourceKey BLUSH_SAKURA_GROVE_TREES = of("trees/blush_sakura_grove"); + public static final ResourceKey COTTON_SAKURA_GROVE_TREES = of("trees/cotton_sakura_grove"); - public static final RegistryKey CARNELIAN_TREEWAY_TREES = of("trees/carnelian_treeway"); - public static final RegistryKey CARNELIAN_TREEWAY_FALLEN_LEAVES = of("patch/carnelian_treeway_fallen_leaves"); + public static final ResourceKey CARNELIAN_TREEWAY_TREES = of("trees/carnelian_treeway"); + public static final ResourceKey CARNELIAN_TREEWAY_FALLEN_LEAVES = of("patch/carnelian_treeway_fallen_leaves"); - public static final RegistryKey GLACARIAN_TAIGA_TREES = of("trees/glacarian_taiga"); + public static final ResourceKey GLACARIAN_TAIGA_TREES = of("trees/glacarian_taiga"); - public static final RegistryKey PALMS = of("trees/palms"); + public static final ResourceKey PALMS = of("trees/palms"); - public static final RegistryKey DARK_AMARANTH_FUNGI = of("trees/dark_amaranth_fungi"); + public static final ResourceKey DARK_AMARANTH_FUNGI = of("trees/dark_amaranth_fungi"); - private static RegistryKey of(String path) { - return RegistryKey.of(RegistryKeys.PLACED_FEATURE, Promenade.id(path)); + private static ResourceKey of(String path) { + return ResourceKey.create(Registries.PLACED_FEATURE, Promenade.id(path)); } public static void appendWorldGen() { if (PromenadeConfig.get().worldFeatures().igneousRockPatches()) { - Predicate hasIgneousRocks = c -> c.hasFeature(OreConfiguredFeatures.ORE_ANDESITE) && c.hasFeature(OreConfiguredFeatures.ORE_DIORITE) && c.hasFeature(OreConfiguredFeatures.ORE_GRANITE); - BiomeModifications.addFeature(hasIgneousRocks, GenerationStep.Feature.UNDERGROUND_ORES, PromenadePlacedFeatures.ORE_ASPHALT_UPPER); - BiomeModifications.addFeature(hasIgneousRocks, GenerationStep.Feature.UNDERGROUND_ORES, PromenadePlacedFeatures.ORE_ASPHALT_LOWER); - BiomeModifications.addFeature(hasIgneousRocks, GenerationStep.Feature.UNDERGROUND_ORES, PromenadePlacedFeatures.ORE_BLUNITE_UPPER); - BiomeModifications.addFeature(hasIgneousRocks, GenerationStep.Feature.UNDERGROUND_ORES, PromenadePlacedFeatures.ORE_BLUNITE_LOWER); + Predicate hasIgneousRocks = c -> c.hasFeature(OreFeatures.ORE_ANDESITE) && c.hasFeature(OreFeatures.ORE_DIORITE) && c.hasFeature(OreFeatures.ORE_GRANITE); + BiomeModifications.addFeature(hasIgneousRocks, GenerationStep.Decoration.UNDERGROUND_ORES, PromenadePlacedFeatures.ORE_ASPHALT_UPPER); + BiomeModifications.addFeature(hasIgneousRocks, GenerationStep.Decoration.UNDERGROUND_ORES, PromenadePlacedFeatures.ORE_ASPHALT_LOWER); + BiomeModifications.addFeature(hasIgneousRocks, GenerationStep.Decoration.UNDERGROUND_ORES, PromenadePlacedFeatures.ORE_BLUNITE_UPPER); + BiomeModifications.addFeature(hasIgneousRocks, GenerationStep.Decoration.UNDERGROUND_ORES, PromenadePlacedFeatures.ORE_BLUNITE_LOWER); } if (PromenadeConfig.get().worldFeatures().palms()) { - BiomeModifications.addFeature(BiomeSelectors.tag(PromenadeBiomeTags.HAS_PALMS), GenerationStep.Feature.VEGETAL_DECORATION, PromenadePlacedFeatures.PALMS); + BiomeModifications.addFeature(BiomeSelectors.tag(PromenadeBiomeTags.HAS_PALMS), GenerationStep.Decoration.VEGETAL_DECORATION, PromenadePlacedFeatures.PALMS); } if (PromenadeConfig.get().worldFeatures().blueberryBushes()) { - BiomeModifications.addFeature(c -> c.hasPlacedFeature(VegetationPlacedFeatures.PATCH_BERRY_COMMON), GenerationStep.Feature.VEGETAL_DECORATION, PromenadePlacedFeatures.BLUEBERRY_BUSH_COMMON_PATCH); - BiomeModifications.addFeature(c -> c.hasPlacedFeature(VegetationPlacedFeatures.PATCH_BERRY_RARE), GenerationStep.Feature.VEGETAL_DECORATION, PromenadePlacedFeatures.BLUEBERRY_BUSH_RARE_PATCH); + BiomeModifications.addFeature(c -> c.hasPlacedFeature(VegetationPlacements.PATCH_BERRY_COMMON), GenerationStep.Decoration.VEGETAL_DECORATION, PromenadePlacedFeatures.BLUEBERRY_BUSH_COMMON_PATCH); + BiomeModifications.addFeature(c -> c.hasPlacedFeature(VegetationPlacements.PATCH_BERRY_RARE), GenerationStep.Decoration.VEGETAL_DECORATION, PromenadePlacedFeatures.BLUEBERRY_BUSH_RARE_PATCH); } } } diff --git a/src/main/java/fr/hugman/promenade/world/gen/feature/TallHugeFungusFeature.java b/src/main/java/fr/hugman/promenade/world/gen/feature/TallHugeFungusFeature.java index bdb092c8..fe340364 100644 --- a/src/main/java/fr/hugman/promenade/world/gen/feature/TallHugeFungusFeature.java +++ b/src/main/java/fr/hugman/promenade/world/gen/feature/TallHugeFungusFeature.java @@ -1,39 +1,39 @@ package fr.hugman.promenade.world.gen.feature; import com.mojang.serialization.Codec; -import net.minecraft.block.AbstractBlock; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.random.Random; -import net.minecraft.world.StructureWorldAccess; -import net.minecraft.world.WorldAccess; -import net.minecraft.world.gen.feature.Feature; -import net.minecraft.world.gen.feature.HugeFungusFeatureConfig; -import net.minecraft.world.gen.feature.WeepingVinesFeature; -import net.minecraft.world.gen.feature.util.FeatureContext; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.util.Mth; +import net.minecraft.util.RandomSource; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.WorldGenLevel; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.state.BlockBehaviour; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.levelgen.feature.Feature; +import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext; +import net.minecraft.world.level.levelgen.feature.HugeFungusConfiguration; +import net.minecraft.world.level.levelgen.feature.WeepingVinesFeature; -public class TallHugeFungusFeature extends Feature { - public TallHugeFungusFeature(Codec codec) { +public class TallHugeFungusFeature extends Feature { + public TallHugeFungusFeature(Codec codec) { super(codec); } - private static boolean isReplaceable(StructureWorldAccess world, BlockPos pos, HugeFungusFeatureConfig config, boolean checkConfig) { - if (world.testBlockState(pos, AbstractBlock.AbstractBlockState::isReplaceable)) { + private static boolean isReplaceable(WorldGenLevel world, BlockPos pos, HugeFungusConfiguration config, boolean checkConfig) { + if (world.isStateAtPosition(pos, BlockBehaviour.BlockStateBase::canBeReplaced)) { return true; } else { return checkConfig && config.replaceableBlocks.test(world, pos); } } - private static BlockPos.Mutable getStartPos(WorldAccess world, BlockPos origin, Block block) { - BlockPos.Mutable mutable = origin.mutableCopy(); + private static BlockPos.MutableBlockPos getStartPos(LevelAccessor world, BlockPos origin, Block block) { + BlockPos.MutableBlockPos mutable = origin.mutable(); for (int i = origin.getY(); i >= 1; --i) { mutable.setY(i); - Block block2 = world.getBlockState(mutable.down()).getBlock(); + Block block2 = world.getBlockState(mutable.below()).getBlock(); if (block2 == block) { return mutable; } @@ -41,27 +41,27 @@ private static BlockPos.Mutable getStartPos(WorldAccess world, BlockPos origin, return null; } - private static void generateVines(BlockPos blockPos, WorldAccess worldAccess, Random random) { - BlockPos.Mutable mutable = blockPos.mutableCopy().move(Direction.DOWN); - if (worldAccess.isAir(mutable)) { - int i = MathHelper.nextInt(random, 1, 5); + private static void generateVines(BlockPos blockPos, LevelAccessor worldAccess, RandomSource random) { + BlockPos.MutableBlockPos mutable = blockPos.mutable().move(Direction.DOWN); + if (worldAccess.isEmptyBlock(mutable)) { + int i = Mth.nextInt(random, 1, 5); if (random.nextInt(7) == 0) { i *= 2; } - WeepingVinesFeature.generateVineColumn(worldAccess, random, mutable, i, 23, 25); + WeepingVinesFeature.placeWeepingVinesColumn(worldAccess, random, mutable, i, 23, 25); } } @Override - public boolean generate(FeatureContext context) { - Random random = context.getRandom(); - HugeFungusFeatureConfig config = context.getConfig(); - StructureWorldAccess world = context.getWorld(); - BlockPos pos = context.getOrigin(); - Block block = config.validBaseBlock.getBlock(); + public boolean place(FeaturePlaceContext context) { + RandomSource random = context.random(); + HugeFungusConfiguration config = context.config(); + WorldGenLevel world = context.level(); + BlockPos pos = context.origin(); + Block block = config.validBaseState.getBlock(); BlockPos pos2 = null; if (config.planted) { - Block block2 = world.getBlockState(pos.down()).getBlock(); + Block block2 = world.getBlockState(pos.below()).getBlock(); if (block2 == block) { pos2 = pos; } @@ -71,7 +71,7 @@ public boolean generate(FeatureContext context) { if (pos2 == null) { return false; } else { - int i = MathHelper.nextInt(random, 8, 16) * 2; + int i = Mth.nextInt(random, 8, 16) * 2; if (!config.planted) { int j = world.getHeight(); if (pos2.getY() + i + 1 >= j) { @@ -79,34 +79,34 @@ public boolean generate(FeatureContext context) { } } boolean bl = !config.planted && random.nextFloat() < 0.16F; - world.setBlockState(pos, Blocks.AIR.getDefaultState(), 4); + world.setBlock(pos, Blocks.AIR.defaultBlockState(), 4); this.generateStem(world, random, config, pos2, i, bl); this.generateHat(world, random, config, pos2, i, bl); return true; } } - private void generateStem(StructureWorldAccess world, Random random, HugeFungusFeatureConfig config, BlockPos blockPos, int stemHeight, boolean thickStem) { - BlockPos.Mutable mutable = new BlockPos.Mutable(); + private void generateStem(WorldGenLevel world, RandomSource random, HugeFungusConfiguration config, BlockPos blockPos, int stemHeight, boolean thickStem) { + BlockPos.MutableBlockPos mutable = new BlockPos.MutableBlockPos(); BlockState blockState = config.stemState; int i = thickStem ? 1 : 0; for (int j = -i; j <= i; ++j) { for (int k = -i; k <= i; ++k) { - boolean bl = thickStem && MathHelper.abs(j) == i && MathHelper.abs(k) == i; + boolean bl = thickStem && Mth.abs(j) == i && Mth.abs(k) == i; for (int l = 0; l < stemHeight; ++l) { - mutable.set(blockPos, j, l, k); + mutable.setWithOffset(blockPos, j, l, k); if (isReplaceable(world, mutable, config, true)) { if (config.planted) { - if (!world.getBlockState(mutable.down()).isAir()) { - world.breakBlock(mutable, true); + if (!world.getBlockState(mutable.below()).isAir()) { + world.destroyBlock(mutable, true); } - world.setBlockState(mutable, blockState, 3); + world.setBlock(mutable, blockState, 3); } else if (bl) { if (random.nextFloat() < 0.1F) { - this.setBlockState(world, mutable, blockState); + this.setBlock(world, mutable, blockState); } } else { - this.setBlockState(world, mutable, blockState); + this.setBlock(world, mutable, blockState); } } } @@ -115,9 +115,9 @@ private void generateStem(StructureWorldAccess world, Random random, HugeFungusF } - private void generateHat(StructureWorldAccess world, Random random, HugeFungusFeatureConfig config, BlockPos blockPos, int hatHeight, boolean thickStem) { - BlockPos.Mutable mutable = new BlockPos.Mutable(); - boolean bl = config.hatState.isOf(Blocks.NETHER_WART_BLOCK); + private void generateHat(WorldGenLevel world, RandomSource random, HugeFungusConfiguration config, BlockPos blockPos, int hatHeight, boolean thickStem) { + BlockPos.MutableBlockPos mutable = new BlockPos.MutableBlockPos(); + boolean bl = config.hatState.is(Blocks.NETHER_WART_BLOCK); int i = Math.min(random.nextInt(1 + hatHeight / 3) + 5, hatHeight); int j = hatHeight - i; for (int k = j; k <= hatHeight; ++k) { @@ -135,10 +135,10 @@ private void generateHat(StructureWorldAccess world, Random random, HugeFungusFe boolean bl4 = !bl2 && !bl3 && k != hatHeight; boolean bl5 = bl2 && bl3; boolean bl6 = k < j + 3; - mutable.set(blockPos, m, k, n); + mutable.setWithOffset(blockPos, m, k, n); if (isReplaceable(world, mutable, config, false)) { - if (config.planted && !world.getBlockState(mutable.down()).isAir()) { - world.breakBlock(mutable, true); + if (config.planted && !world.getBlockState(mutable.below()).isAir()) { + world.destroyBlock(mutable, true); } if (bl6) { if (!bl4) { @@ -158,11 +158,11 @@ private void generateHat(StructureWorldAccess world, Random random, HugeFungusFe } - private void generateHatBlock(WorldAccess world, Random random, HugeFungusFeatureConfig config, BlockPos.Mutable pos, float decorationChance, float generationChance, float vineChance) { + private void generateHatBlock(LevelAccessor world, RandomSource random, HugeFungusConfiguration config, BlockPos.MutableBlockPos pos, float decorationChance, float generationChance, float vineChance) { if (random.nextFloat() < decorationChance) { - this.setBlockState(world, pos, config.decorationState); + this.setBlock(world, pos, config.decorState); } else if (random.nextFloat() < generationChance) { - this.setBlockState(world, pos, config.hatState); + this.setBlock(world, pos, config.hatState); if (random.nextFloat() < vineChance) { generateVines(pos, world, random); } @@ -170,12 +170,12 @@ private void generateHatBlock(WorldAccess world, Random random, HugeFungusFeatur } - private void tryGenerateVines(WorldAccess world, Random random, BlockPos origin, BlockState state, boolean bl) { - BlockPos.Mutable mutable = origin.mutableCopy(); - if (world.getBlockState(mutable.down()).isOf(state.getBlock())) { - this.setBlockState(world, mutable, state); + private void tryGenerateVines(LevelAccessor world, RandomSource random, BlockPos origin, BlockState state, boolean bl) { + BlockPos.MutableBlockPos mutable = origin.mutable(); + if (world.getBlockState(mutable.below()).is(state.getBlock())) { + this.setBlock(world, mutable, state); } else if ((double) random.nextFloat() < 0.15D) { - this.setBlockState(world, origin, state); + this.setBlock(world, origin, state); if (bl && random.nextInt(11) == 0) { generateVines(mutable, world, random); } diff --git a/src/main/java/fr/hugman/promenade/world/gen/placement_modifier/NoiseIntervalCountPlacementModifier.java b/src/main/java/fr/hugman/promenade/world/gen/placement_modifier/NoiseIntervalCountPlacementModifier.java index a4f3a3ea..a0ad8ae5 100644 --- a/src/main/java/fr/hugman/promenade/world/gen/placement_modifier/NoiseIntervalCountPlacementModifier.java +++ b/src/main/java/fr/hugman/promenade/world/gen/placement_modifier/NoiseIntervalCountPlacementModifier.java @@ -3,13 +3,13 @@ import com.mojang.serialization.Codec; import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.random.Random; -import net.minecraft.world.biome.Biome; -import net.minecraft.world.gen.placementmodifier.AbstractCountPlacementModifier; -import net.minecraft.world.gen.placementmodifier.PlacementModifierType; +import net.minecraft.core.BlockPos; +import net.minecraft.util.RandomSource; +import net.minecraft.world.level.biome.Biome; +import net.minecraft.world.level.levelgen.placement.PlacementModifierType; +import net.minecraft.world.level.levelgen.placement.RepeatingPlacement; -public class NoiseIntervalCountPlacementModifier extends AbstractCountPlacementModifier { +public class NoiseIntervalCountPlacementModifier extends RepeatingPlacement { public static final MapCodec MODIFIER_CODEC = RecordCodecBuilder.mapCodec((instance) -> instance.group( Codec.DOUBLE.fieldOf("noise_level_min").forGetter((pm) -> pm.noiseLevelMin), Codec.DOUBLE.fieldOf("noise_level_max").forGetter((pm) -> pm.noiseLevelMax), @@ -34,12 +34,12 @@ public static NoiseIntervalCountPlacementModifier of(double noiseLevelMin, doubl @Override - protected int getCount(Random random, BlockPos pos) { - double d = Biome.FOLIAGE_NOISE.sample((double) pos.getX() / 200.0, (double) pos.getZ() / 200.0, false); + protected int count(RandomSource random, BlockPos pos) { + double d = Biome.BIOME_INFO_NOISE.getValue((double) pos.getX() / 200.0, (double) pos.getZ() / 200.0, false); return (this.noiseLevelMin < d && d < this.noiseLevelMax) ? this.insideValue : this.outsideValue; } - public PlacementModifierType getType() { + public PlacementModifierType type() { return PromenadePlacementModifierTypes.NOISE_INTERVAL_COUNT; } } diff --git a/src/main/java/fr/hugman/promenade/world/gen/placement_modifier/PromenadePlacementModifierTypes.java b/src/main/java/fr/hugman/promenade/world/gen/placement_modifier/PromenadePlacementModifierTypes.java index dbc1a0de..92feff84 100644 --- a/src/main/java/fr/hugman/promenade/world/gen/placement_modifier/PromenadePlacementModifierTypes.java +++ b/src/main/java/fr/hugman/promenade/world/gen/placement_modifier/PromenadePlacementModifierTypes.java @@ -2,15 +2,15 @@ import com.mojang.serialization.MapCodec; import fr.hugman.promenade.Promenade; -import net.minecraft.registry.Registries; -import net.minecraft.registry.Registry; -import net.minecraft.world.gen.placementmodifier.PlacementModifier; -import net.minecraft.world.gen.placementmodifier.PlacementModifierType; +import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.world.level.levelgen.placement.PlacementModifier; +import net.minecraft.world.level.levelgen.placement.PlacementModifierType; public class PromenadePlacementModifierTypes { public static final PlacementModifierType NOISE_INTERVAL_COUNT = register("noise_interval_count", NoiseIntervalCountPlacementModifier.MODIFIER_CODEC); private static

PlacementModifierType

register(String path, MapCodec

codec) { - return Registry.register(Registries.PLACEMENT_MODIFIER_TYPE, Promenade.id(path), () -> codec); + return Registry.register(BuiltInRegistries.PLACEMENT_MODIFIER_TYPE, Promenade.id(path), () -> codec); } } diff --git a/src/main/java/fr/hugman/promenade/world/gen/structure/PromenadeStructureKeys.java b/src/main/java/fr/hugman/promenade/world/gen/structure/PromenadeStructureKeys.java index ff556249..e381350e 100644 --- a/src/main/java/fr/hugman/promenade/world/gen/structure/PromenadeStructureKeys.java +++ b/src/main/java/fr/hugman/promenade/world/gen/structure/PromenadeStructureKeys.java @@ -1,14 +1,14 @@ package fr.hugman.promenade.world.gen.structure; import fr.hugman.promenade.Promenade; -import net.minecraft.registry.RegistryKey; -import net.minecraft.registry.RegistryKeys; -import net.minecraft.world.gen.structure.Structure; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.level.levelgen.structure.Structure; public class PromenadeStructureKeys { - public static final RegistryKey DARK_FOREST_WITCH_HUT = of("dark_forest_witch_hut"); + public static final ResourceKey DARK_FOREST_WITCH_HUT = of("dark_forest_witch_hut"); - private static RegistryKey of(String id) { - return RegistryKey.of(RegistryKeys.STRUCTURE, Promenade.id(id)); + private static ResourceKey of(String id) { + return ResourceKey.create(Registries.STRUCTURE, Promenade.id(id)); } } diff --git a/src/main/java/fr/hugman/promenade/world/gen/structure/PromenadeStructurePoolsKeys.java b/src/main/java/fr/hugman/promenade/world/gen/structure/PromenadeStructurePoolsKeys.java index 26f1aa68..df5bad2b 100644 --- a/src/main/java/fr/hugman/promenade/world/gen/structure/PromenadeStructurePoolsKeys.java +++ b/src/main/java/fr/hugman/promenade/world/gen/structure/PromenadeStructurePoolsKeys.java @@ -1,15 +1,15 @@ package fr.hugman.promenade.world.gen.structure; import fr.hugman.promenade.Promenade; -import net.minecraft.registry.RegistryKey; -import net.minecraft.registry.RegistryKeys; -import net.minecraft.structure.pool.StructurePool; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.level.levelgen.structure.pools.StructureTemplatePool; public class PromenadeStructurePoolsKeys { - public static final RegistryKey DARK_FOREST_WITCH_HUTS = of("dark_forest_witch_huts"); - public static final RegistryKey WITCH_HUT_INTERIORS = of("witch_huts_interiors"); + public static final ResourceKey DARK_FOREST_WITCH_HUTS = of("dark_forest_witch_huts"); + public static final ResourceKey WITCH_HUT_INTERIORS = of("witch_huts_interiors"); - private static RegistryKey of(String id) { - return RegistryKey.of(RegistryKeys.TEMPLATE_POOL, Promenade.id(id)); + private static ResourceKey of(String id) { + return ResourceKey.create(Registries.TEMPLATE_POOL, Promenade.id(id)); } } diff --git a/src/main/java/fr/hugman/promenade/world/gen/structure/PromenadeStructureSetKeys.java b/src/main/java/fr/hugman/promenade/world/gen/structure/PromenadeStructureSetKeys.java index 94395ec2..853dc27c 100644 --- a/src/main/java/fr/hugman/promenade/world/gen/structure/PromenadeStructureSetKeys.java +++ b/src/main/java/fr/hugman/promenade/world/gen/structure/PromenadeStructureSetKeys.java @@ -1,14 +1,14 @@ package fr.hugman.promenade.world.gen.structure; import fr.hugman.promenade.Promenade; -import net.minecraft.registry.RegistryKey; -import net.minecraft.registry.RegistryKeys; -import net.minecraft.structure.StructureSet; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.level.levelgen.structure.StructureSet; public class PromenadeStructureSetKeys { - public static final RegistryKey WITCH_HUTS = of("witch_huts"); + public static final ResourceKey WITCH_HUTS = of("witch_huts"); - private static RegistryKey of(String id) { - return RegistryKey.of(RegistryKeys.STRUCTURE_SET, Promenade.id(id)); + private static ResourceKey of(String id) { + return ResourceKey.create(Registries.STRUCTURE_SET, Promenade.id(id)); } } diff --git a/src/main/java/fr/hugman/promenade/world/gen/tree/foliage/MapleFoliagePlacer.java b/src/main/java/fr/hugman/promenade/world/gen/tree/foliage/MapleFoliagePlacer.java index 25772794..637316eb 100644 --- a/src/main/java/fr/hugman/promenade/world/gen/tree/foliage/MapleFoliagePlacer.java +++ b/src/main/java/fr/hugman/promenade/world/gen/tree/foliage/MapleFoliagePlacer.java @@ -2,20 +2,22 @@ import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.intprovider.ConstantIntProvider; -import net.minecraft.util.math.intprovider.IntProvider; -import net.minecraft.util.math.random.Random; -import net.minecraft.world.TestableWorld; -import net.minecraft.world.gen.feature.TreeFeatureConfig; -import net.minecraft.world.gen.foliage.FoliagePlacer; -import net.minecraft.world.gen.foliage.FoliagePlacerType; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; +import net.minecraft.util.RandomSource; +import net.minecraft.util.valueproviders.ConstantInt; +import net.minecraft.util.valueproviders.IntProvider; +import net.minecraft.util.valueproviders.IntProviders; +import net.minecraft.world.level.LevelSimulatedReader; +import net.minecraft.world.level.WorldGenLevel; +import net.minecraft.world.level.levelgen.feature.configurations.TreeConfiguration; +import net.minecraft.world.level.levelgen.feature.foliageplacers.FoliagePlacer; +import net.minecraft.world.level.levelgen.feature.foliageplacers.FoliagePlacerType; public class MapleFoliagePlacer extends FoliagePlacer { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> - MapleFoliagePlacer.fillFoliagePlacerFields(instance).and( - IntProvider.createValidatingCodec(0, 32).optionalFieldOf("height", ConstantIntProvider.create(0)).forGetter(placer -> placer.height) + MapleFoliagePlacer.foliagePlacerParts(instance).and( + IntProviders.codec(0, 32).optionalFieldOf("height", ConstantInt.of(0)).forGetter(placer -> placer.height) ).apply(instance, MapleFoliagePlacer::new)); protected final IntProvider height; @@ -26,13 +28,13 @@ public MapleFoliagePlacer(IntProvider radius, IntProvider offset, IntProvider he } @Override - protected FoliagePlacerType getType() { + protected FoliagePlacerType type() { return PromenadeFoliagePlacerTypes.MAPLE; } @Override - protected void generate(TestableWorld world, BlockPlacer placer, Random random, TreeFeatureConfig config, int trunkHeight, TreeNode treeNode, int foliageHeight, int radius, int offset) { - var pos = treeNode.getCenter().down(foliageHeight - offset); + protected void createFoliage(WorldGenLevel world, FoliageSetter placer, RandomSource random, TreeConfiguration config, int trunkHeight, FoliageAttachment treeNode, int foliageHeight, int radius, int offset) { + var pos = treeNode.pos().below(foliageHeight - offset); var curvature = radius; @@ -46,7 +48,7 @@ protected void generate(TestableWorld world, BlockPlacer placer, Random random, for (int dz = -radius; dz <= radius; dz++) { int d = Math.abs(dx) + Math.abs(dz); - int k = MathHelper.ceil(Math.abs(Math.abs(dx) - Math.abs(dz))); + int k = Mth.ceil(Math.abs(Math.abs(dx) - Math.abs(dz))); // the further we are from the trunk, the lower the height int y1 = Math.max(0, d - 1); @@ -59,23 +61,23 @@ protected void generate(TestableWorld world, BlockPlacer placer, Random random, } } - protected void generateColumn(TestableWorld world, BlockPlacer placer, TreeFeatureConfig config, Random random, BlockPos centerPos, int dx, int dz, int y1, int y2) { - BlockPos.Mutable mutable = new BlockPos.Mutable(); - mutable.set(centerPos, dz, y1, dx); + protected void generateColumn(WorldGenLevel world, FoliageSetter placer, TreeConfiguration config, RandomSource random, BlockPos centerPos, int dx, int dz, int y1, int y2) { + BlockPos.MutableBlockPos mutable = new BlockPos.MutableBlockPos(); + mutable.setWithOffset(centerPos, dz, y1, dx); for (int y = y1; y < y2; y++) { mutable.move(0, 1, 0); - FoliagePlacer.placeFoliageBlock(world, placer, random, config, mutable); + FoliagePlacer.tryPlaceLeaf(world, placer, random, config, mutable); } } @Override - public int getRandomHeight(Random random, int trunkHeight, TreeFeatureConfig config) { - return this.height.get(random); + public int foliageHeight(RandomSource random, int trunkHeight, TreeConfiguration config) { + return this.height.sample(random); } @Override - protected boolean isInvalidForLeaves(Random random, int dx, int y, int dz, int radius, boolean giantTrunk) { + protected boolean shouldSkipLocation(RandomSource random, int dx, int y, int dz, int radius, boolean giantTrunk) { return false; } } diff --git a/src/main/java/fr/hugman/promenade/world/gen/tree/foliage/PalmFoliagePlacer.java b/src/main/java/fr/hugman/promenade/world/gen/tree/foliage/PalmFoliagePlacer.java index b91e3881..7f90fa90 100644 --- a/src/main/java/fr/hugman/promenade/world/gen/tree/foliage/PalmFoliagePlacer.java +++ b/src/main/java/fr/hugman/promenade/world/gen/tree/foliage/PalmFoliagePlacer.java @@ -2,17 +2,18 @@ import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.intprovider.IntProvider; -import net.minecraft.util.math.random.Random; -import net.minecraft.world.TestableWorld; -import net.minecraft.world.gen.feature.TreeFeatureConfig; -import net.minecraft.world.gen.foliage.FoliagePlacer; -import net.minecraft.world.gen.foliage.FoliagePlacerType; +import net.minecraft.core.BlockPos; +import net.minecraft.util.RandomSource; +import net.minecraft.util.valueproviders.IntProvider; +import net.minecraft.world.level.LevelSimulatedReader; +import net.minecraft.world.level.WorldGenLevel; +import net.minecraft.world.level.levelgen.feature.configurations.TreeConfiguration; +import net.minecraft.world.level.levelgen.feature.foliageplacers.FoliagePlacer; +import net.minecraft.world.level.levelgen.feature.foliageplacers.FoliagePlacerType; public class PalmFoliagePlacer extends FoliagePlacer { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> - PalmFoliagePlacer.fillFoliagePlacerFields(instance) + PalmFoliagePlacer.foliagePlacerParts(instance) .apply(instance, PalmFoliagePlacer::new)); public PalmFoliagePlacer(IntProvider radius, IntProvider offset) { @@ -20,30 +21,30 @@ public PalmFoliagePlacer(IntProvider radius, IntProvider offset) { } @Override - protected FoliagePlacerType getType() { + protected FoliagePlacerType type() { return PromenadeFoliagePlacerTypes.PALM; } @Override - protected void generate(TestableWorld world, BlockPlacer placer, Random random, TreeFeatureConfig config, int trunkHeight, TreeNode treeNode, int foliageHeight, int radius, int offset) { - boolean bl = treeNode.isGiantTrunk(); - BlockPos blockPos = treeNode.getCenter().down(); + protected void createFoliage(WorldGenLevel world, FoliageSetter placer, RandomSource random, TreeConfiguration config, int trunkHeight, FoliageAttachment treeNode, int foliageHeight, int radius, int offset) { + boolean bl = treeNode.doubleTrunk(); + BlockPos blockPos = treeNode.pos().below(); - int i = radius + treeNode.getFoliageRadius(); - if (i > 1) this.generateSquare(world, placer, random, config, blockPos, i, 2, bl); - this.generateSquare(world, placer, random, config, blockPos, i + 1, 1, bl); - this.generateSquare(world, placer, random, config, blockPos, i + 2, 0, bl); - this.generateSquare(world, placer, random, config, blockPos, i + 2, -1, bl); - this.generateSquare(world, placer, random, config, blockPos, i + 1, -2, bl); + int i = radius + treeNode.radiusOffset(); + if (i > 1) this.placeLeavesRow(world, placer, random, config, blockPos, i, 2, bl); + this.placeLeavesRow(world, placer, random, config, blockPos, i + 1, 1, bl); + this.placeLeavesRow(world, placer, random, config, blockPos, i + 2, 0, bl); + this.placeLeavesRow(world, placer, random, config, blockPos, i + 2, -1, bl); + this.placeLeavesRow(world, placer, random, config, blockPos, i + 1, -2, bl); } @Override - public int getRandomHeight(Random random, int trunkHeight, TreeFeatureConfig config) { + public int foliageHeight(RandomSource random, int trunkHeight, TreeConfiguration config) { return 0; } @Override - protected boolean isInvalidForLeaves(Random random, int dx, int y, int dz, int radius, boolean giantTrunk) { + protected boolean shouldSkipLocation(RandomSource random, int dx, int y, int dz, int radius, boolean giantTrunk) { int d = dx + dz; // Distance from center if (y == 2) { diff --git a/src/main/java/fr/hugman/promenade/world/gen/tree/foliage/PromenadeFoliagePlacerTypes.java b/src/main/java/fr/hugman/promenade/world/gen/tree/foliage/PromenadeFoliagePlacerTypes.java index a81ed2b9..0571f8ce 100644 --- a/src/main/java/fr/hugman/promenade/world/gen/tree/foliage/PromenadeFoliagePlacerTypes.java +++ b/src/main/java/fr/hugman/promenade/world/gen/tree/foliage/PromenadeFoliagePlacerTypes.java @@ -2,17 +2,17 @@ import com.mojang.serialization.MapCodec; import fr.hugman.promenade.Promenade; -import net.minecraft.registry.Registries; -import net.minecraft.registry.Registry; -import net.minecraft.world.gen.foliage.FoliagePlacer; -import net.minecraft.world.gen.foliage.FoliagePlacerType; +import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.world.level.levelgen.feature.foliageplacers.FoliagePlacer; +import net.minecraft.world.level.levelgen.feature.foliageplacers.FoliagePlacerType; public class PromenadeFoliagePlacerTypes { public static final FoliagePlacerType PALM = register("palm", PalmFoliagePlacer.CODEC); public static final FoliagePlacerType MAPLE = register("maple", MapleFoliagePlacer.CODEC); private static

FoliagePlacerType

register(String path, MapCodec

codec) { - return Registry.register(Registries.FOLIAGE_PLACER_TYPE, Promenade.id(path), new FoliagePlacerType<>(codec)); + return Registry.register(BuiltInRegistries.FOLIAGE_PLACER_TYPE, Promenade.id(path), new FoliagePlacerType<>(codec)); } } diff --git a/src/main/java/fr/hugman/promenade/world/gen/tree/trunk/BranchingStraightTrunkPlacer.java b/src/main/java/fr/hugman/promenade/world/gen/tree/trunk/BranchingStraightTrunkPlacer.java index 599f654a..b22c7674 100644 --- a/src/main/java/fr/hugman/promenade/world/gen/tree/trunk/BranchingStraightTrunkPlacer.java +++ b/src/main/java/fr/hugman/promenade/world/gen/tree/trunk/BranchingStraightTrunkPlacer.java @@ -3,23 +3,23 @@ import com.google.common.collect.ImmutableList; import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; -import net.minecraft.block.BlockState; -import net.minecraft.block.PillarBlock; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.random.Random; -import net.minecraft.world.TestableWorld; -import net.minecraft.world.gen.feature.TreeFeatureConfig; -import net.minecraft.world.gen.foliage.FoliagePlacer; -import net.minecraft.world.gen.trunk.TrunkPlacer; -import net.minecraft.world.gen.trunk.TrunkPlacerType; - import java.util.List; import java.util.function.BiConsumer; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.util.RandomSource; +import net.minecraft.world.level.LevelSimulatedReader; +import net.minecraft.world.level.WorldGenLevel; +import net.minecraft.world.level.block.RotatedPillarBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.levelgen.feature.configurations.TreeConfiguration; +import net.minecraft.world.level.levelgen.feature.foliageplacers.FoliagePlacer; +import net.minecraft.world.level.levelgen.feature.trunkplacers.TrunkPlacer; +import net.minecraft.world.level.levelgen.feature.trunkplacers.TrunkPlacerType; public class BranchingStraightTrunkPlacer extends TrunkPlacer { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec( - instance -> fillTrunkPlacerFields(instance).apply(instance, BranchingStraightTrunkPlacer::new) + instance -> trunkPlacerParts(instance).apply(instance, BranchingStraightTrunkPlacer::new) ); public static final List HORIZONTAL = List.of(Direction.NORTH, Direction.SOUTH, Direction.WEST, Direction.EAST); @@ -29,40 +29,40 @@ public BranchingStraightTrunkPlacer(int baseHeight, int firstRandomHeight, int s } @Override - protected TrunkPlacerType getType() { + protected TrunkPlacerType type() { return PromenadeTrunkPlacerTypes.BRANCHING_STRAIGHT; } @Override - public List generate( - TestableWorld world, + public List placeTrunk( + WorldGenLevel world, BiConsumer replacer, - Random random, + RandomSource random, int height, BlockPos startPos, - TreeFeatureConfig config + TreeConfiguration config ) { - setToDirt(world, replacer, random, startPos.down(), config); + placeBelowTrunkBlock(world, replacer, random, startPos.below(), config); Direction branchDirection = null; int branches = 0; //TODO: configurability for (int i = 0; i < height; i++) { - var pos = startPos.up(i); - this.getAndSetState(world, replacer, random, pos, config); + var pos = startPos.above(i); + this.placeLog(world, replacer, random, pos, config); if (random.nextInt(6) == 0 && branches < 2 && i > 2) { if (branchDirection != null) { branchDirection = branchDirection.getOpposite(); } else { - branchDirection = Direction.Type.HORIZONTAL.random(random); + branchDirection = Direction.Plane.HORIZONTAL.getRandomDirection(random); } Direction finalBranchDirection = branchDirection; - this.getAndSetState(world, replacer, random, pos.offset(branchDirection), config, state -> state.withIfExists(PillarBlock.AXIS, finalBranchDirection.getAxis())); + this.placeLog(world, replacer, random, pos.relative(branchDirection), config, state -> state.trySetValue(RotatedPillarBlock.AXIS, finalBranchDirection.getAxis())); branches++; } } - return ImmutableList.of(new FoliagePlacer.TreeNode(startPos.up(height), 0, false)); + return ImmutableList.of(new FoliagePlacer.FoliageAttachment(startPos.above(height), 0, false)); } } diff --git a/src/main/java/fr/hugman/promenade/world/gen/tree/trunk/LeapingTrunkPlacer.java b/src/main/java/fr/hugman/promenade/world/gen/tree/trunk/LeapingTrunkPlacer.java index 919df3bb..bb8f50a6 100644 --- a/src/main/java/fr/hugman/promenade/world/gen/tree/trunk/LeapingTrunkPlacer.java +++ b/src/main/java/fr/hugman/promenade/world/gen/tree/trunk/LeapingTrunkPlacer.java @@ -4,25 +4,26 @@ import com.mojang.serialization.Codec; import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; -import net.minecraft.block.BlockState; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.intprovider.IntProvider; -import net.minecraft.util.math.random.Random; -import net.minecraft.world.TestableWorld; -import net.minecraft.world.gen.feature.TreeFeatureConfig; -import net.minecraft.world.gen.foliage.FoliagePlacer; -import net.minecraft.world.gen.trunk.TrunkPlacer; -import net.minecraft.world.gen.trunk.TrunkPlacerType; - import java.util.List; import java.util.function.BiConsumer; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.util.Mth; +import net.minecraft.util.RandomSource; +import net.minecraft.util.valueproviders.IntProvider; +import net.minecraft.util.valueproviders.IntProviders; +import net.minecraft.world.level.LevelSimulatedReader; +import net.minecraft.world.level.WorldGenLevel; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.levelgen.feature.configurations.TreeConfiguration; +import net.minecraft.world.level.levelgen.feature.foliageplacers.FoliagePlacer; +import net.minecraft.world.level.levelgen.feature.trunkplacers.TrunkPlacer; +import net.minecraft.world.level.levelgen.feature.trunkplacers.TrunkPlacerType; public class LeapingTrunkPlacer extends TrunkPlacer { - public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> fillTrunkPlacerFields(instance).and(instance.group( - IntProvider.createValidatingCodec(0, 80).fieldOf("straight_max").forGetter(placer -> placer.straightMax), - IntProvider.VALUE_CODEC.fieldOf("straight_difference").forGetter(placer -> placer.straightDifference), + public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> trunkPlacerParts(instance).and(instance.group( + IntProviders.codec(0, 80).fieldOf("straight_max").forGetter(placer -> placer.straightMax), + IntProviders.CODEC.fieldOf("straight_difference").forGetter(placer -> placer.straightDifference), Codec.FLOAT.fieldOf("decline_chance").forGetter(placer -> placer.declineChance), Codec.INT.fieldOf("max_foliage_radius_bonus").forGetter(placer -> placer.maxFoliageRadiusBonus)) ).apply(instance, LeapingTrunkPlacer::new)); @@ -41,41 +42,41 @@ public LeapingTrunkPlacer(int baseHeight, int firstRandomHeight, int secondRando } @Override - protected TrunkPlacerType getType() { + protected TrunkPlacerType type() { return PromenadeTrunkPlacerTypes.LEAPING; } @Override - public List generate(TestableWorld world, BiConsumer replacer, Random random, int height, BlockPos startPos, TreeFeatureConfig config) { - Direction direction = Direction.Type.HORIZONTAL.random(random); - BlockPos.Mutable mutable = startPos.mutableCopy().move(Direction.DOWN); + public List placeTrunk(WorldGenLevel world, BiConsumer replacer, RandomSource random, int height, BlockPos startPos, TreeConfiguration config) { + Direction direction = Direction.Plane.HORIZONTAL.getRandomDirection(random); + BlockPos.MutableBlockPos mutable = startPos.mutable().move(Direction.DOWN); - int j = this.straightMax.get(random); + int j = this.straightMax.sample(random); int k = j; - setToDirt(world, replacer, random, mutable, config); + placeBelowTrunkBlock(world, replacer, random, mutable, config); for (int i = 0; i < height; ++i) { mutable.move(Direction.UP); if (k <= 0) { - j += this.straightDifference.get(random); + j += this.straightDifference.sample(random); k = j; if (random.nextFloat() < this.declineChance && i < height - 1) { - getAndSetState(world, replacer, random, mutable, config); + placeLog(world, replacer, random, mutable, config); if (random.nextBoolean()) { - mutable.move(direction.rotateYClockwise()); + mutable.move(direction.getClockWise()); } else { - mutable.move(direction.rotateYCounterclockwise()); + mutable.move(direction.getCounterClockWise()); } } mutable.move(direction); } - getAndSetState(world, replacer, random, mutable, config); + placeLog(world, replacer, random, mutable, config); k--; } mutable.move(Direction.UP); - double heightRatio = MathHelper.clamp((height - this.baseHeight) / (double) (this.firstRandomHeight + this.secondRandomHeight), 0.0D, 0.999D); - return ImmutableList.of(new FoliagePlacer.TreeNode(mutable, MathHelper.floor((this.maxFoliageRadiusBonus + 1) * heightRatio), false)); + double heightRatio = Mth.clamp((height - this.baseHeight) / (double) (this.heightRandA + this.heightRandB), 0.0D, 0.999D); + return ImmutableList.of(new FoliagePlacer.FoliageAttachment(mutable, Mth.floor((this.maxFoliageRadiusBonus + 1) * heightRatio), false)); } } diff --git a/src/main/java/fr/hugman/promenade/world/gen/tree/trunk/PromenadeTrunkPlacerTypes.java b/src/main/java/fr/hugman/promenade/world/gen/tree/trunk/PromenadeTrunkPlacerTypes.java index 23ab8965..1534c74c 100644 --- a/src/main/java/fr/hugman/promenade/world/gen/tree/trunk/PromenadeTrunkPlacerTypes.java +++ b/src/main/java/fr/hugman/promenade/world/gen/tree/trunk/PromenadeTrunkPlacerTypes.java @@ -2,17 +2,17 @@ import com.mojang.serialization.MapCodec; import fr.hugman.promenade.Promenade; -import net.minecraft.registry.Registries; -import net.minecraft.registry.Registry; -import net.minecraft.world.gen.trunk.TrunkPlacer; -import net.minecraft.world.gen.trunk.TrunkPlacerType; +import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.world.level.levelgen.feature.trunkplacers.TrunkPlacer; +import net.minecraft.world.level.levelgen.feature.trunkplacers.TrunkPlacerType; public class PromenadeTrunkPlacerTypes { public static final TrunkPlacerType LEAPING = register("leaping", LeapingTrunkPlacer.CODEC); public static final TrunkPlacerType BRANCHING_STRAIGHT = register("branching_straight", BranchingStraightTrunkPlacer.CODEC); private static

TrunkPlacerType

register(String path, MapCodec

codec) { - return Registry.register(Registries.TRUNK_PLACER_TYPE, Promenade.id(path), new TrunkPlacerType<>(codec)); + return Registry.register(BuiltInRegistries.TRUNK_PLACER_TYPE, Promenade.id(path), new TrunkPlacerType<>(codec)); } } diff --git a/src/main/java/fr/hugman/promenade/world/item/trading/PromenadeVillagerTrades.java b/src/main/java/fr/hugman/promenade/world/item/trading/PromenadeVillagerTrades.java new file mode 100644 index 00000000..e3d80cb1 --- /dev/null +++ b/src/main/java/fr/hugman/promenade/world/item/trading/PromenadeVillagerTrades.java @@ -0,0 +1,20 @@ +package fr.hugman.promenade.world.item.trading; + +import fr.hugman.promenade.Promenade; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.item.trading.VillagerTrade; + +public class PromenadeVillagerTrades { + public static final ResourceKey WANDERING_TRADER_VERMILION_MAPLE_SAPLING = resourceKey("wandering_trader/vermilion_maple_sapling"); + public static final ResourceKey WANDERING_TRADER_FULVOUS_MAPLE_SAPLING = resourceKey("wandering_trader/fulvous_maple_sapling"); + public static final ResourceKey WANDERING_TRADER_MIKADO_MAPLE_SAPLING = resourceKey("wandering_trader/mikado_maple_sapling"); + public static final ResourceKey WANDERING_TRADER_SAP_MAPLE_SAPLING = resourceKey("wandering_trader/sap_maple_sapling"); + public static final ResourceKey WANDERING_TRADER_BLUSH_SAKURA_SAPLING = resourceKey("wandering_trader/blush_sakura_sapling"); + public static final ResourceKey WANDERING_TRADER_COTTON_SAKURA_SAPLING = resourceKey("wandering_trader/cotton_sakura_sapling"); + public static final ResourceKey WANDERING_TRADER_PALM_SAPLING = resourceKey("wandering_trader/palm_sapling"); + + private static ResourceKey resourceKey(String path) { + return ResourceKey.create(Registries.VILLAGER_TRADE, Promenade.id(path)); + } +} diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 6e81c407..937badae 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -30,8 +30,8 @@ ], "accessWidener": "promenade.accesswidener", "depends": { - "minecraft": "^1.21.11", - "fabric": "*", + "minecraft": "~26.1-", + "fabric-api": "*", "biolith": "*" }, "suggests": { diff --git a/src/main/resources/promenade.accesswidener b/src/main/resources/promenade.accesswidener index c5129eb3..2527984a 100644 --- a/src/main/resources/promenade.accesswidener +++ b/src/main/resources/promenade.accesswidener @@ -1,6 +1,6 @@ -accessWidener v1 named -extendable method net/minecraft/entity/mob/AbstractSkeletonEntity getStepSound ()Lnet/minecraft/sound/SoundEvent; -extendable method net/minecraft/entity/mob/CreeperEntity explode ()V -accessible method net/minecraft/world/gen/surfacebuilder/VanillaSurfaceRules block (Lnet/minecraft/block/Block;)Lnet/minecraft/world/gen/surfacebuilder/MaterialRules$MaterialRule; -accessible field net/minecraft/entity/mob/MobEntity lootTable Ljava/util/Optional; -accessible method net/minecraft/client/particle/LeavesParticle (Lnet/minecraft/client/world/ClientWorld;DDDLnet/minecraft/client/texture/Sprite;FFZZFF)V \ No newline at end of file +accessWidener v1 official +extendable method net/minecraft/world/entity/monster/skeleton/AbstractSkeleton getStepSound ()Lnet/minecraft/sounds/SoundEvent; +extendable method net/minecraft/world/entity/monster/Creeper explodeCreeper ()V +accessible method net/minecraft/data/worldgen/SurfaceRuleData makeStateRule (Lnet/minecraft/world/level/block/Block;)Lnet/minecraft/world/level/levelgen/SurfaceRules$RuleSource; +accessible field net/minecraft/world/entity/Mob lootTable Ljava/util/Optional; +accessible method net/minecraft/client/particle/FallingLeavesParticle (Lnet/minecraft/client/multiplayer/ClientLevel;DDDLnet/minecraft/client/renderer/texture/TextureAtlasSprite;FFZZFF)V