diff --git a/build.gradle b/build.gradle index 03d0ceb..124ddb9 100644 --- a/build.gradle +++ b/build.gradle @@ -1,66 +1,142 @@ buildscript { repositories { maven { url = 'https://files.minecraftforge.net/maven' } + maven { url = 'https://maven.parchmentmc.org' } + maven { url = 'https://repo.spongepowered.org/repository/maven-public/' } jcenter() mavenCentral() } dependencies { - classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true + classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true + classpath group: 'org.spongepowered', name: 'mixingradle', version: '0.7-SNAPSHOT' + classpath 'org.parchmentmc:librarian:1.+' } } apply plugin: 'net.minecraftforge.gradle' +apply plugin: 'org.parchmentmc.librarian.forgegradle' +apply plugin: 'org.spongepowered.mixin' apply plugin: 'eclipse' -archivesBaseName = name + '-' + mcVersion +archivesBaseName = "${fileName}-${mcVersion}" -sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' +java.toolchain.languageVersion = JavaLanguageVersion.of(project.properties.javaVersion) minecraft { - mappings 'snapshot', project.properties.mappingsVersion + mappings channel: 'parchment', version: project.properties.parchmentVersion accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') runs { client = { properties 'forge.logging.markers': '' properties 'forge.logging.console.level': 'debug' - workingDirectory project.file('run').canonicalPath - source sourceSets.main + arg project.mixin.toBoolean() ? "-mixin.config=${modid}.mixins.json" : "" + workingDirectory project.file('run') + mods { "${modid}" { source sourceSets.main } } } server = { properties 'forge.logging.markers': '' properties 'forge.logging.console.level': 'debug' - workingDirectory project.file('run').canonicalPath - source sourceSets.main + arg project.mixin.toBoolean() ? "-mixin.config=${modid}.mixins.json" : "" + workingDirectory project.file('run') + mods { "${modid}" { source sourceSets.main } } } + data = { + property 'forge.logging.markers', '' + property 'forge.logging.console.level', 'debug' + args '--mod', modid, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') + workingDirectory project.file('run') + mods { "${modid}" { source sourceSets.main } } + } } } +sourceSets.main.resources { srcDir 'src/generated/resources' } + repositories { - maven { + maven { // JEI url "https://dvs1.progwml6.com/files/maven" } - maven { - url 'https://www.dogforce-games.com/maven/' + maven { // CurseForge + url "https://www.cursemaven.com" + } + maven { // Curios + url "https://maven.theillusivec4.top/" } - maven { - url 'https://maven.tehnut.info' + maven { // The One Probe + url "https://maven.k-4u.nl/" + } + maven { // Patchouli + url "https://maven.blamejared.com" } } dependencies { - minecraft 'net.minecraftforge:forge:' + project.properties.mcVersion + '-' + forgeVersion - compile fileTree(dir: 'libs', include: '*.jar') - compile fg.deobf('mezz.jei:jei-' + jeiVersion) - compile fg.deobf('mcp.mobius.waila:Hwyla:' + hwylaVersion) + minecraft "net.minecraftforge:forge:${mcVersion}-${forgeVersion}" + if(project.mixin.toBoolean()) annotationProcessor "org.spongepowered:mixin:${mixinVersion}:processor" + if(project.hasProperty('jeiVersion')) implementation fg.deobf("mezz.jei:jei-${jeiVersion}") + if(project.hasProperty('jadeFileId')) implementation fg.deobf("curse.maven:jade-324717:${jadeFileId}") + if(project.hasProperty('curiosVer')) implementation fg.deobf("top.theillusivec4.curios:curios-forge:${curiosVer}") + if(project.hasProperty('topVersion')) implementation fg.deobf(project.dependencies.create("mcjty.theoneprobe:theoneprobe:${topVersion}") { + transitive = false + }) + if(project.hasProperty('patchouliVer')) implementation fg.deobf("vazkii.patchouli:Patchouli:${patchouliVer}") + implementation fileTree(dir: 'libs', include: '*.jar') +} + +mixin { + if(project.mixin.toBoolean()) add sourceSets.main, "${modid}.refmap.json" +} + +def resourceTargets = ['META-INF/mods.toml', 'pack.mcmeta', "${modid}.mixins.json".toString()] +def intoTargets = ["$rootDir/out/production/resources/", "$rootDir/out/production/${project.name}.main/", "$rootDir/bin/main/"] +def replaceProperties = [modid: modid, + version: version, + displayName: spacedName, + author: author, + desc: desc, + mcVersion: mcVersion, + forgeVersion: forgeVersion, + mixins: mixins, + clientMixins: clientMixins + ] + +if(project.hasProperty('placeboDep')) replaceProperties.put 'placeboDep', placeboDep +if(project.hasProperty('curiosVer')) replaceProperties.put 'curiosVer', curiosVer +if(project.hasProperty('topVersion')) replaceProperties.put 'topVersion', topVersion +if(project.hasProperty('patchouliVer')) replaceProperties.put 'patchouliVer', patchouliVer + +processResources { + inputs.properties replaceProperties + replaceProperties.put 'project', project + + filesMatching(resourceTargets) { + expand replaceProperties + } + + intoTargets.each { target -> + if (file(target).exists()) { + copy { + from(sourceSets.main.resources) { + include resourceTargets + expand replaceProperties + } + into target + } + } + } } jar { manifest { - attributes(["Specification-Title": project.name, + attributes(["Specification-Title": project.fileName, "Specification-Vendor": project.author, - "Specification-Version": "24.0", // We are version 1 of the modlauncher specification - "Implementation-Title": project.name, + "Specification-Version": "1.0", // We are version 1 of ourselves + "Implementation-Title": project.fileName, "Implementation-Version": project.version, "Implementation-Vendor" : project.author, - "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")],) + "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"), + "MixinConfigs": project.mixin.toBoolean() ? "${modid}.mixins.json" : "" + ]) } -} \ No newline at end of file +} + +jar.finalizedBy('reobfJar') \ No newline at end of file diff --git a/changelog.md b/changelog.md new file mode 100644 index 0000000..e9fe626 --- /dev/null +++ b/changelog.md @@ -0,0 +1,3 @@ +## 1.1.0 +* Added the /open_gateway command which allows spawning a gateway at a position. +* Fixed a bug where a gateway would crash if the summoner ID was unset. \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index db38114..c9b20e7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,12 +1,31 @@ -name=GatewaysToEternity +org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 + +fileName=GatewaysToEternity +spacedName=GatewaysToEternity +modid=gateways author=Shadows_of_Fire -version=1.0.2 -mcVersion=1.16.4 -mappingsVersion=20201028-1.16.3 -forgeVersion=35.1.36 -jeiVersion=1.16.4:7.6.1.65 -hwylaVersion=1.10.11-B78_1.16.2 +desc=Invoke that from the dark beyond. Let it pour into this world. A mod about creating temporary mob spawners in the form of portals. +version=1.1.0 +mcVersion=1.16.5 +javaVersion=8 +forgeVersion=36.2.39 +parchmentVersion=2021.10.03-1.16.5 +jeiVersion=1.16.5:7.7.1.130 +jadeFileId=3910873 +#curiosVer=1.18.2-5.0.6.3 +placeboDep=4.7.0 +#topVersion=1.18-5.1.0-8 +#patchouliVer=1.18.2-66 + +#MIXINS +mixin=false +mixinVersion=0.8.5 +#These should be a comma-separated list of all the mixin classnames in the project. +#Mixins must live at shadows.modid.mixin +mixins= +clientMixins= + #New mappings version to use with the fg updateMappings task. #When commented out, the task is not registered. -#UPDATE_MAPPINGS=20200916-1.16.2 -#UPDATE_MAPPINGS_CHANNEL=snapshot \ No newline at end of file +#UPDATE_MAPPINGS=1.16.5 +#UPDATE_MAPPINGS_CHANNEL=official \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7a3265e..7454180 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 949819d..ffed3a2 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip diff --git a/gradlew b/gradlew index cccdd3d..c53aefa 100644 --- a/gradlew +++ b/gradlew @@ -1,78 +1,129 @@ -#!/usr/bin/env sh +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## # Attempt to set APP_HOME + # Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` +APP_BASE_NAME=${0##*/} # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum warn () { echo "$*" -} +} >&2 die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -81,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" + JAVACMD=java which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the @@ -89,84 +140,95 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac fi -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) fi - i=$((i+1)) + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac fi -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index f955316..107acd3 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,3 +1,19 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + @if "%DEBUG%" == "" @echo off @rem ########################################################################## @rem @@ -13,15 +29,18 @@ if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init +if "%ERRORLEVEL%" == "0" goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -35,7 +54,7 @@ goto fail set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe -if exist "%JAVA_EXE%" goto init +if exist "%JAVA_EXE%" goto execute echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% @@ -45,28 +64,14 @@ echo location of your Java installation. goto fail -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - :execute @rem Setup the command line set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* :end @rem End local scope for the variables with windows NT shell diff --git a/libs/Placebo-1.16.4-4.4.0-dev.jar b/libs/Placebo-1.16.4-4.4.0-dev.jar deleted file mode 100644 index cd4cc36..0000000 Binary files a/libs/Placebo-1.16.4-4.4.0-dev.jar and /dev/null differ diff --git a/libs/Placebo-1.16.5-4.7.0-dev.jar b/libs/Placebo-1.16.5-4.7.0-dev.jar new file mode 100644 index 0000000..4fa5d99 Binary files /dev/null and b/libs/Placebo-1.16.5-4.7.0-dev.jar differ diff --git a/src/main/java/shadows/gateways/GatewaysToEternity.java b/src/main/java/shadows/gateways/GatewaysToEternity.java index 9733636..52eecd0 100644 --- a/src/main/java/shadows/gateways/GatewaysToEternity.java +++ b/src/main/java/shadows/gateways/GatewaysToEternity.java @@ -14,6 +14,8 @@ import net.minecraft.particles.ParticleType; import net.minecraft.util.ResourceLocation; import net.minecraft.util.SoundEvent; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.RegisterCommandsEvent; import net.minecraftforge.event.RegistryEvent.Register; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; @@ -22,6 +24,7 @@ import net.minecraftforge.fml.network.simple.SimpleChannel; import shadows.gateways.client.GatewayParticle; import shadows.gateways.client.GatewayTickableSound; +import shadows.gateways.command.GatewayCommand; import shadows.gateways.entity.AbstractGatewayEntity; import shadows.gateways.entity.SmallGatewayEntity; import shadows.gateways.item.GateOpenerItem; @@ -46,16 +49,17 @@ public class GatewaysToEternity { public GatewaysToEternity() { FMLJavaModLoadingContext.get().getModEventBus().register(this); NetworkUtils.registerMessage(CHANNEL, 0, new ParticleMessage()); + MinecraftForge.EVENT_BUS.addListener(this::commands); } @SubscribeEvent public void registerEntities(Register> e) { //Formatter::off e.getRegistry().register(EntityType.Builder - .create(SmallGatewayEntity::new, EntityClassification.MISC) + .of(SmallGatewayEntity::new, EntityClassification.MISC) .setTrackingRange(5) .setUpdateInterval(20) - .size(2F, 2.5F) + .sized(2F, 2.5F) .setCustomClientFactory((se, w) -> { AbstractGatewayEntity ent = new SmallGatewayEntity(GatewayObjects.SMALL_GATEWAY, w); GatewayTickableSound.startGatewaySound(ent); @@ -68,7 +72,7 @@ public void registerEntities(Register> e) { @SubscribeEvent public void registerItems(Register e) { - e.getRegistry().register(new GateOpenerItem(new Item.Properties().maxStackSize(1).rarity(Rarity.UNCOMMON).group(ItemGroup.MISC), SmallGatewayEntity::new).setRegistryName("small_gate_opener")); + e.getRegistry().register(new GateOpenerItem(new Item.Properties().stacksTo(1).rarity(Rarity.UNCOMMON).tab(ItemGroup.TAB_MISC), SmallGatewayEntity::new).setRegistryName("small_gate_opener")); } @SubscribeEvent @@ -92,10 +96,14 @@ public void registerSounds(Register e) { public void registerParticles(Register> e) { e.getRegistry().register(new ParticleType(false, GatewayParticle.Data.DESERIALIZER) { @Override - public Codec func_230522_e_() { + public Codec codec() { return GatewayParticle.Data.CODEC; } }.setRegistryName("glow")); } + public void commands(RegisterCommandsEvent e) { + GatewayCommand.register(e.getDispatcher()); + } + } diff --git a/src/main/java/shadows/gateways/GatewaysToEternityClient.java b/src/main/java/shadows/gateways/GatewaysToEternityClient.java index 79858ce..0eb2248 100644 --- a/src/main/java/shadows/gateways/GatewaysToEternityClient.java +++ b/src/main/java/shadows/gateways/GatewaysToEternityClient.java @@ -22,11 +22,11 @@ public class GatewaysToEternityClient { @SubscribeEvent public static void setup(FMLClientSetupEvent e) { e.enqueueWork(() -> { - EntityRendererManager mgr = Minecraft.getInstance().getRenderManager(); + EntityRendererManager mgr = Minecraft.getInstance().getEntityRenderDispatcher(); mgr.register(GatewayObjects.SMALL_GATEWAY, new GatewayRenderer(mgr)); Minecraft.getInstance().getItemColors().register((stack, tint) -> { if (stack.hasTag() && stack.getTag().contains("gateway_data")) { - CompoundNBT data = stack.getOrCreateChildTag("gateway_data"); + CompoundNBT data = stack.getOrCreateTagElement("gateway_data"); if (data.contains("color")) { BossInfo.Color color = BossInfo.Color.byName(data.getString("color")); return BossColorMap.getColor(color); @@ -39,7 +39,7 @@ public static void setup(FMLClientSetupEvent e) { @SubscribeEvent public static void factories(ParticleFactoryRegisterEvent e) { - Minecraft.getInstance().particles.registerFactory(GatewayObjects.GLOW, GatewayParticle.Factory::new); + Minecraft.getInstance().particleEngine.register(GatewayObjects.GLOW, GatewayParticle.Factory::new); } public static RecipeManager getClientRecipeManager() { diff --git a/src/main/java/shadows/gateways/client/GatewayParticle.java b/src/main/java/shadows/gateways/client/GatewayParticle.java index 05483c5..d594c0c 100644 --- a/src/main/java/shadows/gateways/client/GatewayParticle.java +++ b/src/main/java/shadows/gateways/client/GatewayParticle.java @@ -36,19 +36,19 @@ public class GatewayParticle extends SpriteTexturedParticle { static final IParticleRenderType RENDER_TYPE = new IParticleRenderType() { - public void beginRender(BufferBuilder bufferBuilder, TextureManager textureManager) { + public void begin(BufferBuilder bufferBuilder, TextureManager textureManager) { RenderSystem.enableAlphaTest(); RenderSystem.depthMask(false); RenderSystem.enableBlend(); - GlStateManager.disableCull(); + GlStateManager._disableCull(); RenderSystem.blendFunc(SourceFactor.SRC_ALPHA, DestFactor.ONE); RenderSystem.alphaFunc(GL11.GL_GREATER, 0.003921569F); - textureManager.bindTexture(AtlasTexture.LOCATION_PARTICLES_TEXTURE); - bufferBuilder.begin(7, DefaultVertexFormats.PARTICLE_POSITION_TEX_COLOR_LMAP); + textureManager.bind(AtlasTexture.LOCATION_PARTICLES); + bufferBuilder.begin(7, DefaultVertexFormats.PARTICLE); } - public void finishRender(Tessellator tesselator) { - tesselator.draw(); + public void end(Tessellator tesselator) { + tesselator.end(); } public String toString() { @@ -58,13 +58,13 @@ public String toString() { public GatewayParticle(GatewayParticle.Data data, World world, double x, double y, double z, double velX, double velY, double velZ) { super((ClientWorld) world, x, y, z, velX, velY, velZ); - this.particleRed = data.red; - this.particleGreen = data.green; - this.particleBlue = data.blue; - this.maxAge = 40; //TODO: Bake age into Data as alpha? - this.motionX = velX; - this.motionY = velY; - this.motionZ = velZ; + this.rCol = data.red; + this.gCol = data.green; + this.bCol = data.blue; + this.lifetime = 40; //TODO: Bake age into Data as alpha? + this.xd = velX; + this.yd = velY; + this.zd = velZ; } @Override @@ -72,30 +72,30 @@ public IParticleRenderType getRenderType() { return RENDER_TYPE; } - public float getScale(float p_217561_1_) { - return 0.75F * this.particleScale * MathHelper.clamp(((float) this.age + p_217561_1_) / (float) this.maxAge * 32.0F, 0.0F, 1.0F); + public float getQuadSize(float p_217561_1_) { + return 0.75F * this.quadSize * MathHelper.clamp(((float) this.age + p_217561_1_) / (float) this.lifetime * 32.0F, 0.0F, 1.0F); } public void tick() { - this.prevPosX = this.posX; - this.prevPosY = this.posY; - this.prevPosZ = this.posZ; - this.particleAlpha = 1 - (float) this.age / this.maxAge; - if (this.age++ >= this.maxAge) { - this.setExpired(); + this.xo = this.x; + this.yo = this.y; + this.zo = this.z; + this.alpha = 1 - (float) this.age / this.lifetime; + if (this.age++ >= this.lifetime) { + this.remove(); } else { - this.move(this.motionX, this.motionY, this.motionZ); - if (this.posY == this.prevPosY) { - this.motionX *= 1.1D; - this.motionZ *= 1.1D; + this.move(this.xd, this.yd, this.zd); + if (this.y == this.yo) { + this.xd *= 1.1D; + this.zd *= 1.1D; } - this.motionX *= (double) 0.86F; - this.motionY *= (double) 0.86F; - this.motionZ *= (double) 0.86F; + this.xd *= (double) 0.86F; + this.yd *= (double) 0.86F; + this.zd *= (double) 0.86F; if (this.onGround) { - this.motionX *= (double) 0.7F; - this.motionZ *= (double) 0.7F; + this.xd *= (double) 0.7F; + this.zd *= (double) 0.7F; } } @@ -108,9 +108,9 @@ public Factory(IAnimatedSprite sprites) { this.sprites = sprites; } - public Particle makeParticle(GatewayParticle.Data data, ClientWorld world, double x, double y, double z, double velX, double velY, double velZ) { + public Particle createParticle(GatewayParticle.Data data, ClientWorld world, double x, double y, double z, double velX, double velY, double velZ) { GatewayParticle particle = new GatewayParticle(data, world, x, y, z, velX, velY, velZ); - particle.selectSpriteRandomly(this.sprites); + particle.pickSprite(this.sprites); return particle; } } @@ -145,7 +145,7 @@ public ParticleType getType() { }); public static final IParticleData.IDeserializer DESERIALIZER = new IParticleData.IDeserializer() { - public Data deserialize(ParticleType type, StringReader reader) throws CommandSyntaxException { + public Data fromCommand(ParticleType type, StringReader reader) throws CommandSyntaxException { reader.expect(' '); float f = (float) reader.readDouble(); reader.expect(' '); @@ -155,20 +155,20 @@ public Data deserialize(ParticleType type, StringReader reader) throws Com return new Data(f, f1, f2); } - public Data read(ParticleType type, PacketBuffer buf) { + public Data fromNetwork(ParticleType type, PacketBuffer buf) { return new Data(buf.readFloat(), buf.readFloat(), buf.readFloat()); } }; @Override - public void write(PacketBuffer buffer) { + public void writeToNetwork(PacketBuffer buffer) { buffer.writeFloat(this.red); buffer.writeFloat(this.green); buffer.writeFloat(this.blue); } @Override - public String getParameters() { + public String writeToString() { return String.format(Locale.ROOT, "%s %.2f %.2f %.2f", Registry.PARTICLE_TYPE.getKey(this.getType()), this.red, this.green, this.blue); } } diff --git a/src/main/java/shadows/gateways/client/GatewayRenderer.java b/src/main/java/shadows/gateways/client/GatewayRenderer.java index c222b08..7b7e80a 100644 --- a/src/main/java/shadows/gateways/client/GatewayRenderer.java +++ b/src/main/java/shadows/gateways/client/GatewayRenderer.java @@ -28,33 +28,33 @@ public GatewayRenderer(EntityRendererManager mgr) { } @Override - public ResourceLocation getEntityTexture(AbstractGatewayEntity entity) { + public ResourceLocation getTextureLocation(AbstractGatewayEntity entity) { return TEXTURE; } @Override public void render(AbstractGatewayEntity entity, float unknown, float partialTicks, MatrixStack matrix, IRenderTypeBuffer buf, int packedLight) { - matrix.push(); + matrix.pushPose(); PlayerEntity player = Minecraft.getInstance().player; Vector3d playerV = player.getEyePosition(partialTicks); - Vector3d portal = entity.getPositionVec(); + Vector3d portal = entity.position(); float scale = 0.35F; double yOffset = 1.5; matrix.translate(0, yOffset, 0); - matrix.rotate(new Quaternion(new Vector3f(0, 1, 0), 90, true)); - matrix.rotate(new Quaternion(new Vector3f(0, 1, 0), 180F - (float) angleOf(portal, playerV), true)); + matrix.mulPose(new Quaternion(new Vector3f(0, 1, 0), 90, true)); + matrix.mulPose(new Quaternion(new Vector3f(0, 1, 0), 180F - (float) angleOf(portal, playerV), true)); - float progress = ((entity.ticksExisted + partialTicks) % 90) / 90F; + float progress = ((entity.tickCount + partialTicks) % 90) / 90F; scale += (float) Math.cos(2 * Math.PI * progress) / 6F; if (!entity.isWaveActive()) { - if (entity.getClientTicks() == -1) entity.setClientTicks(entity.ticksExisted); + if (entity.getClientTicks() == -1) entity.setClientTicks(entity.tickCount); } if (entity.getClientTicks() != -1) { - progress = (entity.ticksExisted - entity.getClientTicks() + partialTicks) / entity.getStats().pauseTime; + progress = (entity.tickCount - entity.getClientTicks() + partialTicks) / entity.getStats().pauseTime; if (progress >= 1.3F) entity.setClientTicks(-1); else { if (progress <= 0.45F) { @@ -70,18 +70,18 @@ public void render(AbstractGatewayEntity entity, float unknown, float partialTic matrix.scale(scale, scale, 1); - this.renderManager.textureManager.bindTexture(this.getEntityTexture(entity)); - IVertexBuilder builder = buf.getBuffer(RenderType.getEntityCutout(getEntityTexture(entity))); + this.entityRenderDispatcher.textureManager.bind(this.getTextureLocation(entity)); + IVertexBuilder builder = buf.getBuffer(RenderType.entityCutout(getTextureLocation(entity))); int color = BossColorMap.getColor(entity.getBossInfo()); int r = color >> 16 & 255, g = color >> 8 & 255, b = color & 255; float frameHeight = 1 / 12F; - int frame = FRAMES[entity.ticksExisted % FRAMES.length]; - builder.pos(matrix.getLast().getMatrix(), -1, -1, 0).color(r, g, b, 255).tex(1, 1 - frame * frameHeight).overlay(OverlayTexture.NO_OVERLAY).lightmap(packedLight).normal(matrix.getLast().getNormal(), 0, 1, 0).endVertex(); - builder.pos(matrix.getLast().getMatrix(), -1, 1, 0).color(r, g, b, 255).tex(1, 11F / 12 - frame * frameHeight).overlay(OverlayTexture.NO_OVERLAY).lightmap(packedLight).normal(matrix.getLast().getNormal(), 0, 1, 0).endVertex(); - builder.pos(matrix.getLast().getMatrix(), 1, 1, 0).color(r, g, b, 255).tex(0, 11F / 12 - frame * frameHeight).overlay(OverlayTexture.NO_OVERLAY).lightmap(packedLight).normal(matrix.getLast().getNormal(), 0, 1, 0).endVertex(); - builder.pos(matrix.getLast().getMatrix(), 1, -1, 0).color(r, g, b, 255).tex(0, 1 - frame * frameHeight).overlay(OverlayTexture.NO_OVERLAY).lightmap(packedLight).normal(matrix.getLast().getNormal(), 0, 1, 0).endVertex(); + int frame = FRAMES[entity.tickCount % FRAMES.length]; + builder.vertex(matrix.last().pose(), -1, -1, 0).color(r, g, b, 255).uv(1, 1 - frame * frameHeight).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(packedLight).normal(matrix.last().normal(), 0, 1, 0).endVertex(); + builder.vertex(matrix.last().pose(), -1, 1, 0).color(r, g, b, 255).uv(1, 11F / 12 - frame * frameHeight).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(packedLight).normal(matrix.last().normal(), 0, 1, 0).endVertex(); + builder.vertex(matrix.last().pose(), 1, 1, 0).color(r, g, b, 255).uv(0, 11F / 12 - frame * frameHeight).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(packedLight).normal(matrix.last().normal(), 0, 1, 0).endVertex(); + builder.vertex(matrix.last().pose(), 1, -1, 0).color(r, g, b, 255).uv(0, 1 - frame * frameHeight).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(packedLight).normal(matrix.last().normal(), 0, 1, 0).endVertex(); - matrix.pop(); + matrix.popPose(); } public static double angleOf(Vector3d p1, Vector3d p2) { diff --git a/src/main/java/shadows/gateways/client/GatewayTickableSound.java b/src/main/java/shadows/gateways/client/GatewayTickableSound.java index 5261384..626e19d 100644 --- a/src/main/java/shadows/gateways/client/GatewayTickableSound.java +++ b/src/main/java/shadows/gateways/client/GatewayTickableSound.java @@ -12,28 +12,28 @@ public class GatewayTickableSound extends TickableSound { public GatewayTickableSound(AbstractGatewayEntity gateway) { super(GatewayObjects.GATE_AMBIENT, SoundCategory.HOSTILE); this.gateway = gateway; - this.repeat = true; - this.repeatDelay = 0; - this.x = (float) gateway.getPosX(); - this.y = (float) gateway.getPosY(); - this.z = (float) gateway.getPosZ(); - this.global = false; + this.looping = true; + this.delay = 0; + this.x = (float) gateway.getX(); + this.y = (float) gateway.getY(); + this.z = (float) gateway.getZ(); + this.relative = false; this.pitch = 0.75F; } - public boolean canBeSilent() { + public boolean canStartSilent() { return true; } public void tick() { if (!this.gateway.isAlive()) { - this.finishPlaying(); + this.stop(); } else { - this.volume = 0.25F - (float) (Minecraft.getInstance().player.getDistanceSq(this.gateway) / (18 * 18F)) / 4F; + this.volume = 0.25F - (float) (Minecraft.getInstance().player.distanceToSqr(this.gateway) / (18 * 18F)) / 4F; } } public static void startGatewaySound(AbstractGatewayEntity entity) { - Minecraft.getInstance().getSoundHandler().play(new GatewayTickableSound(entity)); + Minecraft.getInstance().getSoundManager().play(new GatewayTickableSound(entity)); } } \ No newline at end of file diff --git a/src/main/java/shadows/gateways/client/ParticleHandler.java b/src/main/java/shadows/gateways/client/ParticleHandler.java index 885f1e2..9f60763 100644 --- a/src/main/java/shadows/gateways/client/ParticleHandler.java +++ b/src/main/java/shadows/gateways/client/ParticleHandler.java @@ -13,11 +13,11 @@ public static void handle(ParticleMessage msg) { double x = msg.x, y = msg.y, z = msg.z; int color = msg.color; int type = msg.type; - Entity src = Minecraft.getInstance().world.getEntityByID(msg.gateId); + Entity src = Minecraft.getInstance().level.getEntity(msg.gateId); if (src == null) return; if (type == 0) { //Type 0: Entity spawned from portal. Spawns a cluster of particles around the entity. GatewayParticle.Data data = new GatewayParticle.Data(color >> 16 & 255, color >> 8 & 255, color & 255); - Random rand = src.world.rand; + Random rand = src.level.random; for (int i = 0; i < 15; i++) { double velX = MathHelper.nextDouble(rand, -0.15, 0.15); double velY = MathHelper.nextDouble(rand, -0.15, 0.15); @@ -25,12 +25,12 @@ public static void handle(ParticleMessage msg) { double xOff = MathHelper.nextDouble(rand, -0.25, 0.25); double yOff = MathHelper.nextDouble(rand, -0.2, 0.2); double zOff = MathHelper.nextDouble(rand, -0.25, 0.25); - Minecraft.getInstance().particles.addParticle(data, x + xOff, y + yOff, z + zOff, velX, velY, velZ); + Minecraft.getInstance().particleEngine.createParticle(data, x + xOff, y + yOff, z + zOff, velX, velY, velZ); } } if (type == 1) { //Type 1: Portal idle particles, called every second from the portal itself. GatewayParticle.Data data = new GatewayParticle.Data(color >> 16 & 255, color >> 8 & 255, color & 255); - Random rand = src.world.rand; + Random rand = src.level.random; for (int i = 0; i < 3; i++) { double velX = MathHelper.nextDouble(rand, -0.05, 0.05); double velY = MathHelper.nextDouble(rand, -0.1, -0.05); @@ -38,7 +38,7 @@ public static void handle(ParticleMessage msg) { double xOff = MathHelper.nextDouble(rand, -0.15, 0.15); double yOff = MathHelper.nextDouble(rand, -0.1, 0.1); double zOff = MathHelper.nextDouble(rand, -0.15, 0.15); - Minecraft.getInstance().particles.addParticle(data, x + xOff, y + yOff, z + zOff, velX, velY, velZ); + Minecraft.getInstance().particleEngine.createParticle(data, x + xOff, y + yOff, z + zOff, velX, velY, velZ); } } diff --git a/src/main/java/shadows/gateways/command/GatewayCommand.java b/src/main/java/shadows/gateways/command/GatewayCommand.java new file mode 100644 index 0000000..c8aed49 --- /dev/null +++ b/src/main/java/shadows/gateways/command/GatewayCommand.java @@ -0,0 +1,44 @@ +package shadows.gateways.command; + +import com.mojang.brigadier.CommandDispatcher; +import com.mojang.brigadier.builder.LiteralArgumentBuilder; +import com.mojang.brigadier.suggestion.SuggestionProvider; + +import net.minecraft.command.CommandSource; +import net.minecraft.command.Commands; +import net.minecraft.command.ISuggestionProvider; +import net.minecraft.command.arguments.BlockPosArgument; +import net.minecraft.command.arguments.ResourceLocationArgument; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.math.BlockPos; +import shadows.gateways.entity.SmallGatewayEntity; +import shadows.gateways.item.GateOpenerItem; + +public class GatewayCommand { + + public static final SuggestionProvider SUGGEST_TYPE = (ctx, builder) -> { + return ISuggestionProvider.suggest(ctx.getSource().getServer().getRecipeManager().getRecipes().stream().filter(r -> r.getResultItem().getItem() instanceof GateOpenerItem).map(r -> r.getId().toString()), builder); + }; + + public static void register(CommandDispatcher pDispatcher) { + LiteralArgumentBuilder builder = Commands.literal("open_gateway").requires(s -> s.hasPermission(2)); + + builder.then(Commands.argument("pos", BlockPosArgument.blockPos()).then(Commands.argument("type", ResourceLocationArgument.id()).suggests(SUGGEST_TYPE).executes(c -> { + BlockPos pos = BlockPosArgument.getLoadedBlockPos(c, "pos"); + ResourceLocation type = ResourceLocationArgument.getId(c, "type"); + IRecipe recipe = c.getSource().getServer().getRecipeManager().byKey(type).get(); + Entity nullableSummoner = c.getSource().getEntity(); + PlayerEntity summoner = nullableSummoner instanceof PlayerEntity ? (PlayerEntity) nullableSummoner : c.getSource().getLevel().getNearestPlayer(pos.getX(), pos.getY(), pos.getZ(), 64, true); + + SmallGatewayEntity gate = new SmallGatewayEntity(c.getSource().getLevel(), summoner, recipe.getResultItem().copy()); + gate.moveTo(pos, 0, 0); + c.getSource().getLevel().addFreshEntity(gate); + return 0; + }))); + pDispatcher.register(builder); + } + +} diff --git a/src/main/java/shadows/gateways/entity/AbstractGatewayEntity.java b/src/main/java/shadows/gateways/entity/AbstractGatewayEntity.java index 1ceba28..7087046 100644 --- a/src/main/java/shadows/gateways/entity/AbstractGatewayEntity.java +++ b/src/main/java/shadows/gateways/entity/AbstractGatewayEntity.java @@ -55,9 +55,9 @@ public abstract class AbstractGatewayEntity extends Entity implements IEntityAdditionalSpawnData { - public static final Method DROP_LOOT = ObfuscationReflectionHelper.findMethod(LivingEntity.class, "func_213354_a", DamageSource.class, boolean.class); - public static final DataParameter WAVE_ACTIVE = EntityDataManager.createKey(AbstractGatewayEntity.class, DataSerializers.BOOLEAN); - public static final DataParameter WAVE = EntityDataManager.createKey(AbstractGatewayEntity.class, DataSerializers.BYTE); + public static final Method DROP_LOOT = ObfuscationReflectionHelper.findMethod(LivingEntity.class, "dropFromLootTable", DamageSource.class, boolean.class); + public static final DataParameter WAVE_ACTIVE = EntityDataManager.defineId(AbstractGatewayEntity.class, DataSerializers.BOOLEAN); + public static final DataParameter WAVE = EntityDataManager.defineId(AbstractGatewayEntity.class, DataSerializers.BYTE); protected final ServerBossInfo bossInfo = this.createBossInfo(); protected final GatewayStats stats = this.createStats(); @@ -80,8 +80,8 @@ public abstract class AbstractGatewayEntity extends Entity implements IEntityAdd public AbstractGatewayEntity(EntityType type, World world, PlayerEntity placer, ItemStack source) { super(type, world); CompoundNBT tag = source.getTag().getCompound("gateway_data"); - this.readAdditional(tag); - this.summonerId = placer.getUniqueID(); + this.readAdditionalSaveData(tag); + this.summonerId = placer.getUUID(); } /** @@ -94,17 +94,17 @@ public AbstractGatewayEntity(EntityType type, World world) { @Override public void tick() { super.tick(); - if (!world.isRemote) { + if (!level.isClientSide) { if (!unresolvedWaveEntities.isEmpty()) { for (UUID id : unresolvedWaveEntities) { - Entity e = ((ServerWorld) world).getEntityByUuid(id); + Entity e = ((ServerWorld) level).getEntity(id); if (e instanceof LivingEntity) this.currentWaveEntities.add((LivingEntity) e); } unresolvedWaveEntities.clear(); } - if (this.ticksExisted % 20 == 0) { - spawnParticle(this.bossInfo.getColor(), this.getPosX(), this.getPosY() + 1.5F, this.getPosZ(), 1); + if (this.tickCount % 20 == 0) { + spawnParticle(this.bossInfo.getColor(), this.getX(), this.getY() + 1.5F, this.getZ(), 1); } if (isWaveActive()) { @@ -123,7 +123,7 @@ public void tick() { this.onWaveEnd(wave); this.bossInfo.setPercent(1F - (float) wave / this.stats.maxWaves); this.currentWaveEntities.clear(); - this.dataManager.set(WAVE_ACTIVE, false); + this.entityData.set(WAVE_ACTIVE, false); if (wave == this.stats.maxWaves) { this.onLastWaveEnd(); } @@ -135,7 +135,7 @@ public void tick() { } } - if (this.ticksExisted % 4 == 0 && !undroppedItems.isEmpty()) { + if (this.tickCount % 4 == 0 && !undroppedItems.isEmpty()) { spawnItem(undroppedItems.remove()); } @@ -146,11 +146,11 @@ public void tick() { } public void spawnWave() { - BlockPos blockpos = this.getPosition(); + BlockPos blockpos = this.blockPosition(); for (int i = 0; i < this.stats.entitiesPerWave; ++i) { - CompoundNBT compoundnbt = this.entity.getNbt(); - Optional> optional = EntityType.readEntityType(compoundnbt); + CompoundNBT compoundnbt = this.entity.getTag(); + Optional> optional = EntityType.by(compoundnbt); if (!optional.isPresent()) { this.remove(); GatewaysToEternity.LOGGER.error("GatewayEntity - Failed to read the entity type from spawn data: " + compoundnbt); @@ -160,13 +160,13 @@ public void spawnWave() { ListNBT listnbt = compoundnbt.getList("Pos", 6); int j = listnbt.size(); int tries = 0; - double x = j >= 1 ? listnbt.getDouble(0) : blockpos.getX() + (world.rand.nextDouble() - world.rand.nextDouble()) * this.stats.spawnRange + 0.5D; - double y = j >= 2 ? listnbt.getDouble(1) : (double) (blockpos.getY() + world.rand.nextInt(3) - 1); - double z = j >= 3 ? listnbt.getDouble(2) : blockpos.getZ() + (world.rand.nextDouble() - world.rand.nextDouble()) * this.stats.spawnRange + 0.5D; - while (!world.hasNoCollisions(optional.get().getBoundingBoxWithSizeApplied(x, y, z))) { - x = j >= 1 ? listnbt.getDouble(0) : blockpos.getX() + (world.rand.nextDouble() - world.rand.nextDouble()) * this.stats.spawnRange + 0.5D; - y = j >= 2 ? listnbt.getDouble(1) : (double) (blockpos.getY() + world.rand.nextInt(3) - 1); - z = j >= 3 ? listnbt.getDouble(2) : blockpos.getZ() + (world.rand.nextDouble() - world.rand.nextDouble()) * this.stats.spawnRange + 0.5D; + double x = j >= 1 ? listnbt.getDouble(0) : blockpos.getX() + (level.random.nextDouble() - level.random.nextDouble()) * this.stats.spawnRange + 0.5D; + double y = j >= 2 ? listnbt.getDouble(1) : (double) (blockpos.getY() + level.random.nextInt(3) - 1); + double z = j >= 3 ? listnbt.getDouble(2) : blockpos.getZ() + (level.random.nextDouble() - level.random.nextDouble()) * this.stats.spawnRange + 0.5D; + while (!level.noCollision(optional.get().getAABB(x, y, z))) { + x = j >= 1 ? listnbt.getDouble(0) : blockpos.getX() + (level.random.nextDouble() - level.random.nextDouble()) * this.stats.spawnRange + 0.5D; + y = j >= 2 ? listnbt.getDouble(1) : (double) (blockpos.getY() + level.random.nextInt(3) - 1); + z = j >= 3 ? listnbt.getDouble(2) : blockpos.getZ() + (level.random.nextDouble() - level.random.nextDouble()) * this.stats.spawnRange + 0.5D; if (tries++ >= 4) { break; } @@ -174,9 +174,9 @@ public void spawnWave() { final double fx = x, fy = y, fz = z; - if (world.hasNoCollisions(optional.get().getBoundingBoxWithSizeApplied(x, y, z))) { - Entity entity = EntityType.loadEntityAndExecute(compoundnbt, world, (p_221408_6_) -> { - p_221408_6_.setLocationAndAngles(fx, fy, fz, p_221408_6_.rotationYaw, p_221408_6_.rotationPitch); + if (level.noCollision(optional.get().getAABB(x, y, z))) { + Entity entity = EntityType.loadEntityRecursive(compoundnbt, level, (p_221408_6_) -> { + p_221408_6_.moveTo(fx, fy, fz, p_221408_6_.yRot, p_221408_6_.xRot); return p_221408_6_; }); @@ -188,31 +188,31 @@ public void spawnWave() { modifyEntityForWave(getWave() + 1, (LivingEntity) entity); - entity.setLocationAndAngles(entity.getPosX(), entity.getPosY(), entity.getPosZ(), world.rand.nextFloat() * 360.0F, 0.0F); + entity.moveTo(entity.getX(), entity.getY(), entity.getZ(), level.random.nextFloat() * 360.0F, 0.0F); if (entity instanceof MobEntity) { MobEntity mobentity = (MobEntity) entity; - if (this.entity.getNbt().size() == 1 && this.entity.getNbt().contains("id", 8) && !ForgeEventFactory.doSpecialSpawn((MobEntity) entity, world, (float) entity.getPosX(), (float) entity.getPosY(), (float) entity.getPosZ(), null, SpawnReason.NATURAL)) { - mobentity.onInitialSpawn((ServerWorld) world, world.getDifficultyForLocation(entity.getPosition()), SpawnReason.NATURAL, (ILivingEntityData) null, (CompoundNBT) null); + if (this.entity.getTag().size() == 1 && this.entity.getTag().contains("id", 8) && !ForgeEventFactory.doSpecialSpawn((MobEntity) entity, level, (float) entity.getX(), (float) entity.getY(), (float) entity.getZ(), null, SpawnReason.NATURAL)) { + mobentity.finalizeSpawn((ServerWorld) level, level.getCurrentDifficultyAt(entity.blockPosition()), SpawnReason.NATURAL, (ILivingEntityData) null, (CompoundNBT) null); } } this.spawnEntity(entity); - this.world.playSound(null, this.getPosX(), this.getPosY(), this.getPosZ(), GatewayObjects.GATE_WARP, SoundCategory.HOSTILE, 0.5F, 1); + this.level.playSound(null, this.getX(), this.getY(), this.getZ(), GatewayObjects.GATE_WARP, SoundCategory.HOSTILE, 0.5F, 1); this.currentWaveEntities.add((LivingEntity) entity); - spawnParticle(this.bossInfo.getColor(), entity.getPosX() + entity.getWidth() / 2, entity.getPosY() + entity.getHeight() / 2, entity.getPosZ() + entity.getWidth() / 2, 0); + spawnParticle(this.bossInfo.getColor(), entity.getX() + entity.getBbWidth() / 2, entity.getY() + entity.getBbHeight() / 2, entity.getZ() + entity.getBbWidth() / 2, 0); } else { this.remove(); } } - this.dataManager.set(WAVE, (byte) (getWave() + 1)); - this.dataManager.set(WAVE_ACTIVE, true); + this.entityData.set(WAVE, (byte) (getWave() + 1)); + this.entityData.set(WAVE_ACTIVE, true); this.ticksInactive = 0; this.onWaveStart(getWave(), this.currentWaveEntities); } protected void spawnEntity(Entity entity) { - if (this.world.addEntity(entity)) { + if (this.level.addFreshEntity(entity)) { for (Entity e : entity.getPassengers()) { this.spawnEntity(e); } @@ -223,7 +223,7 @@ protected void onLastWaveEnd() { while (completionXP > 0) { int i = 5; completionXP -= i; - this.world.addEntity(new ExperienceOrbEntity(this.world, this.getPosX(), this.getPosY(), this.getPosZ(), i)); + this.level.addFreshEntity(new ExperienceOrbEntity(this.level, this.getX(), this.getY(), this.getZ(), i)); } } @@ -241,17 +241,17 @@ public void onGateCreated() { } protected void onWaveEnd(int wave) { - PlayerEntity player = world.getPlayerByUuid(summonerId); + PlayerEntity player = this.summonerId == null ? null : level.getPlayerByUUID(summonerId); if (player == null) { - player = world.getClosestPlayer(this, 50); + player = level.getNearestPlayer(this, 50); } try { - Entity entity = EntityType.loadEntityAndExecute(this.entity.getNbt(), world, (p_221408_6_) -> { - p_221408_6_.setLocationAndAngles(this.getPosX(), this.getPosY(), this.getPosZ(), p_221408_6_.rotationYaw, p_221408_6_.rotationPitch); + Entity entity = EntityType.loadEntityRecursive(this.entity.getTag(), level, (p_221408_6_) -> { + p_221408_6_.moveTo(this.getX(), this.getY(), this.getZ(), p_221408_6_.yRot, p_221408_6_.xRot); return p_221408_6_; }); List items = new ArrayList<>(); - entity.attackEntityFrom(DamageSource.causePlayerDamage(player).setDamageIsAbsolute().setDamageAllowedInCreativeMode().setDamageBypassesArmor(), 1); + entity.hurt(DamageSource.playerAttack(player).bypassMagic().bypassInvul().bypassArmor(), 1); entity.captureDrops(items); this.dropBonusLoot(player, (LivingEntity) entity); items.stream().map(ItemEntity::getItem).forEach(undroppedItems::add); @@ -278,41 +278,41 @@ protected void onWaveTimerElapsed(int wave, Set remaining) { protected void dropBonusLoot(PlayerEntity player, LivingEntity entity) throws Exception { for (int i = 0; i < this.stats.entitiesPerWave * getWave(); i++) { - DROP_LOOT.invoke(entity, DamageSource.causePlayerDamage(player), true); + DROP_LOOT.invoke(entity, DamageSource.playerAttack(player), true); } } @Override - protected void readAdditional(CompoundNBT tag) { - this.dataManager.set(WAVE, tag.getByte("wave")); + protected void readAdditionalSaveData(CompoundNBT tag) { + this.entityData.set(WAVE, tag.getByte("wave")); this.entity = new WeightedSpawnerEntity(tag.getCompound("entity")); long[] entities = tag.getLongArray("wave_entities"); for (int i = 0; i < entities.length; i += 2) { unresolvedWaveEntities.add(new UUID(entities[i], entities[i + 1])); } - this.dataManager.set(WAVE_ACTIVE, tag.getBoolean("active")); + this.entityData.set(WAVE_ACTIVE, tag.getBoolean("active")); this.ticksInactive = tag.getShort("ticks_inactive"); this.ticksActive = tag.getInt("ticks_active"); this.completionXP = tag.getInt("completion_xp"); - if (tag.contains("summoner")) this.summonerId = tag.getUniqueId("summoner"); + if (tag.contains("summoner")) this.summonerId = tag.getUUID("summoner"); this.bossInfo.setName(new TranslationTextComponent(tag.getString("name"))); this.maxWaveTime = tag.getInt("max_wave_time"); this.bossInfo.setPercent(1F - (float) getWave() / this.stats.maxWaves); ListNBT stacks = tag.getList("queued_stacks", Constants.NBT.TAG_COMPOUND); for (INBT inbt : stacks) { - undroppedItems.add(ItemStack.read((CompoundNBT) inbt)); + undroppedItems.add(ItemStack.of((CompoundNBT) inbt)); } this.bossInfo.setColor(Color.byName(tag.getString("color"))); } @Override - protected void writeAdditional(CompoundNBT tag) { + protected void addAdditionalSaveData(CompoundNBT tag) { tag.putByte("wave", getWave()); - tag.put("entity", this.entity.toCompoundTag()); + tag.put("entity", this.entity.save()); long[] ids = new long[this.currentWaveEntities.size() * 2]; int idx = 0; for (LivingEntity e : this.currentWaveEntities) { - UUID id = e.getUniqueID(); + UUID id = e.getUUID(); ids[idx++] = id.getMostSignificantBits(); ids[idx++] = id.getLeastSignificantBits(); } @@ -321,7 +321,7 @@ protected void writeAdditional(CompoundNBT tag) { tag.putInt("ticks_active", getTicksActive()); tag.putShort("ticks_inactive", (short) getTicksInactive()); tag.putInt("completion_xp", this.completionXP); - tag.putUniqueId("summoner", this.summonerId); + if (this.summonerId != null) tag.putUUID("summoner", this.summonerId); tag.putString("name", this.bossInfo.getName() == null ? "entity.gateways.gateway" : ((TranslationTextComponent) this.bossInfo.getName()).getKey()); tag.putInt("max_wave_time", this.maxWaveTime); ListNBT stacks = new ListNBT(); @@ -333,25 +333,25 @@ protected void writeAdditional(CompoundNBT tag) { } @Override - protected void registerData() { - this.dataManager.register(WAVE_ACTIVE, false); - this.dataManager.register(WAVE, (byte) 0); + protected void defineSynchedData() { + this.entityData.define(WAVE_ACTIVE, false); + this.entityData.define(WAVE, (byte) 0); } @Override - public IPacket createSpawnPacket() { + public IPacket getAddEntityPacket() { return NetworkHooks.getEntitySpawningPacket(this); } @Override - public void addTrackingPlayer(ServerPlayerEntity player) { - super.addTrackingPlayer(player); + public void startSeenByPlayer(ServerPlayerEntity player) { + super.startSeenByPlayer(player); this.bossInfo.addPlayer(player); } @Override - public void removeTrackingPlayer(ServerPlayerEntity player) { - super.removeTrackingPlayer(player); + public void stopSeenByPlayer(ServerPlayerEntity player) { + super.stopSeenByPlayer(player); this.bossInfo.removePlayer(player); } @@ -364,11 +364,11 @@ public int getTicksInactive() { } public boolean isWaveActive() { - return this.dataManager.get(WAVE_ACTIVE); + return this.entityData.get(WAVE_ACTIVE); } public byte getWave() { - return this.dataManager.get(WAVE); + return this.entityData.get(WAVE); } public GatewayStats getStats() { @@ -388,33 +388,33 @@ public void setClientTicks(int ticks) { } public static void spawnLightningOn(Entity entity, boolean effectOnly) { - LightningBoltEntity bolt = EntityType.LIGHTNING_BOLT.create(entity.world); - bolt.setPosition(entity.getPosX(), entity.getPosY(), entity.getPosZ()); - bolt.setEffectOnly(effectOnly); - entity.world.addEntity(bolt); + LightningBoltEntity bolt = EntityType.LIGHTNING_BOLT.create(entity.level); + bolt.setPos(entity.getX(), entity.getY(), entity.getZ()); + bolt.setVisualOnly(effectOnly); + entity.level.addFreshEntity(bolt); } public void spawnParticle(Color color, double x, double y, double z, int type) { int cInt = BossColorMap.getColor(this.getBossInfo()); - NetworkUtils.sendToTracking(GatewaysToEternity.CHANNEL, new ParticleMessage(this, x, y, z, cInt, type), (ServerWorld) world, new BlockPos((int) x, (int) y, (int) z)); + NetworkUtils.sendToTracking(GatewaysToEternity.CHANNEL, new ParticleMessage(this, x, y, z, cInt, type), (ServerWorld) level, new BlockPos((int) x, (int) y, (int) z)); } public void spawnItem(ItemStack stack) { - ItemEntity i = new ItemEntity(world, 0, 0, 0, stack); - i.setPosition(this.getPosX() + MathHelper.nextDouble(rand, -0.5, 0.5), this.getPosY() + 1.5, this.getPosZ() + MathHelper.nextDouble(rand, -0.5, 0.5)); - i.setMotion(MathHelper.nextDouble(rand, -0.15, 0.15), 0.4, MathHelper.nextDouble(rand, -0.15, 0.15)); - world.addEntity(i); - this.world.playSound(null, i.getPosX(), i.getPosY(), i.getPosZ(), GatewayObjects.GATE_WARP, SoundCategory.HOSTILE, 0.75F, 2.0F); + ItemEntity i = new ItemEntity(level, 0, 0, 0, stack); + i.setPos(this.getX() + MathHelper.nextDouble(random, -0.5, 0.5), this.getY() + 1.5, this.getZ() + MathHelper.nextDouble(random, -0.5, 0.5)); + i.setDeltaMovement(MathHelper.nextDouble(random, -0.15, 0.15), 0.4, MathHelper.nextDouble(random, -0.15, 0.15)); + level.addFreshEntity(i); + this.level.playSound(null, i.getX(), i.getY(), i.getZ(), GatewayObjects.GATE_WARP, SoundCategory.HOSTILE, 0.75F, 2.0F); } @Override public void writeSpawnData(PacketBuffer buf) { - buf.writeString(this.bossInfo.getColor().getName()); + buf.writeUtf(this.bossInfo.getColor().getName()); } @Override public void readSpawnData(PacketBuffer buf) { - this.bossInfo.setColor(Color.byName(buf.readString())); + this.bossInfo.setColor(Color.byName(buf.readUtf())); } public class GatewayStats { diff --git a/src/main/java/shadows/gateways/entity/SmallGatewayEntity.java b/src/main/java/shadows/gateways/entity/SmallGatewayEntity.java index 1db0160..3a09b8a 100644 --- a/src/main/java/shadows/gateways/entity/SmallGatewayEntity.java +++ b/src/main/java/shadows/gateways/entity/SmallGatewayEntity.java @@ -24,7 +24,7 @@ public SmallGatewayEntity(EntityType type, World world) { @Override protected ServerBossInfo createBossInfo() { ServerBossInfo info = new ServerBossInfo(this.getName(), BossInfo.Color.BLUE, BossInfo.Overlay.NOTCHED_6); - info.setCreateFog(true); + info.setCreateWorldFog(true); return info; } diff --git a/src/main/java/shadows/gateways/item/GateOpenerItem.java b/src/main/java/shadows/gateways/item/GateOpenerItem.java index 24c0a48..906da09 100644 --- a/src/main/java/shadows/gateways/item/GateOpenerItem.java +++ b/src/main/java/shadows/gateways/item/GateOpenerItem.java @@ -30,32 +30,32 @@ public GateOpenerItem(Properties props, IGateSupplier factory) { } @Override - public ActionResultType onItemUse(ItemUseContext ctx) { - World world = ctx.getWorld(); - ItemStack stack = ctx.getItem(); - BlockPos pos = ctx.getPos(); + public ActionResultType useOn(ItemUseContext ctx) { + World world = ctx.getLevel(); + ItemStack stack = ctx.getItemInHand(); + BlockPos pos = ctx.getClickedPos(); - if (world.isRemote) return ActionResultType.SUCCESS; + if (world.isClientSide) return ActionResultType.SUCCESS; - if (!world.getEntitiesWithinAABB(AbstractGatewayEntity.class, new AxisAlignedBB(pos).grow(25, 25, 25)).isEmpty()) return ActionResultType.FAIL; + if (!world.getEntitiesOfClass(AbstractGatewayEntity.class, new AxisAlignedBB(pos).inflate(25, 25, 25)).isEmpty()) return ActionResultType.FAIL; AbstractGatewayEntity entity = factory.createGate(world, ctx.getPlayer(), stack); BlockState state = world.getBlockState(pos); - entity.setPosition(pos.getX() + 0.5, pos.getY() + state.getShape(world, pos).getEnd(Axis.Y), pos.getZ() + 0.5); - if (!world.hasNoCollisions(entity)) return ActionResultType.FAIL; - world.addEntity(entity); + entity.setPos(pos.getX() + 0.5, pos.getY() + state.getShape(world, pos).max(Axis.Y), pos.getZ() + 0.5); + if (!world.noCollision(entity)) return ActionResultType.FAIL; + world.addFreshEntity(entity); entity.onGateCreated(); if (!ctx.getPlayer().isCreative()) stack.shrink(1); return ActionResultType.CONSUME; } @Override - public ITextComponent getDisplayName(ItemStack stack) { - if (stack.hasDisplayName()) return super.getDisplayName(stack); + public ITextComponent getName(ItemStack stack) { + if (stack.hasCustomHoverName()) return super.getName(stack); if (stack.hasTag() && stack.getTag().contains("opener_name")) { - return ITextComponent.Serializer.getComponentFromJson(stack.getTag().getString("opener_name")); + return ITextComponent.Serializer.fromJson(stack.getTag().getString("opener_name")); } - return super.getDisplayName(stack); + return super.getName(stack); } public static interface IGateSupplier { @@ -63,8 +63,8 @@ public static interface IGateSupplier { } @Override - public void fillItemGroup(ItemGroup group, NonNullList items) { - if (this.isInGroup(group)) { + public void fillItemCategory(ItemGroup group, NonNullList items) { + if (this.allowdedIn(group)) { RecipeManager mgr = DistExecutor.unsafeRunForDist(() -> () -> { MinecraftServer server = ServerLifecycleHooks.getCurrentServer(); if (server != null) return server.getRecipeManager(); //Integrated Server @@ -75,7 +75,7 @@ public void fillItemGroup(ItemGroup group, NonNullList items) { return server.getRecipeManager(); //Dedicated Server }); if (mgr == null) return; - mgr.getRecipes().stream().map(r -> r.getRecipeOutput()).filter(s -> s.getItem() == this).forEach(items::add); + mgr.getRecipes().stream().map(r -> r.getResultItem()).filter(s -> s.getItem() == this).forEach(items::add); } } diff --git a/src/main/java/shadows/gateways/net/ParticleMessage.java b/src/main/java/shadows/gateways/net/ParticleMessage.java index 21dc25a..bbbcc8b 100644 --- a/src/main/java/shadows/gateways/net/ParticleMessage.java +++ b/src/main/java/shadows/gateways/net/ParticleMessage.java @@ -17,7 +17,7 @@ public class ParticleMessage extends MessageProvider { public int color; public ParticleMessage(AbstractGatewayEntity source, double x, double y, double z, int color, int type) { - this(source.getEntityId(), x, y, z, color, type); + this(source.getId(), x, y, z, color, type); } public ParticleMessage(int id, double x, double y, double z, int color, int type) { diff --git a/src/main/java/shadows/gateways/recipe/GatewayRecipeSerializer.java b/src/main/java/shadows/gateways/recipe/GatewayRecipeSerializer.java index edfde71..515d6da 100644 --- a/src/main/java/shadows/gateways/recipe/GatewayRecipeSerializer.java +++ b/src/main/java/shadows/gateways/recipe/GatewayRecipeSerializer.java @@ -19,9 +19,9 @@ public class GatewayRecipeSerializer extends ShapedRecipe.Serializer { public static final GatewayRecipeSerializer INSTANCE = new GatewayRecipeSerializer(); @Override - public GatewayRecipe read(ResourceLocation id, JsonObject json) { - ShapedRecipe recipe = super.read(id, json); - ItemStack gateway = recipe.getRecipeOutput(); + public GatewayRecipe fromJson(ResourceLocation id, JsonObject json) { + ShapedRecipe recipe = super.fromJson(id, json); + ItemStack gateway = recipe.getResultItem(); if (!(gateway.getItem() instanceof GateOpenerItem)) { throw new JsonSyntaxException("Gateway Recipe output must be a gate opener item. Provided: " + gateway.getItem().getRegistryName()); } @@ -42,7 +42,7 @@ public static CompoundNBT toNBT(JsonObject data) { CompoundNBT tag = new CompoundNBT(); tag.putString("name", name); WeightedSpawnerEntity ws = new WeightedSpawnerEntity(1, TagBuilder.getDefaultTag(ForgeRegistries.ENTITIES.getValue(entity))); - tag.put("entity", ws.toCompoundTag()); + tag.put("entity", ws.save()); tag.putInt("completion_xp", completionXP); tag.putInt("max_wave_time", maxWaveTime); tag.putString("color", color); diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index bcf5ae9..65394b9 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -1,41 +1,38 @@ modLoader="javafml" #mandatory -loaderVersion="[28,)" #mandatory +loaderVersion="[32,)" #mandatory -authors="Shadows_of_Fire" #optional +authors="${author}" #optional license="MIT License" #mandatory [[mods]] #mandatory -modId="gateways" #mandatory +modId="${modid}" #mandatory -version="${file.jarVersion}" #mandatory +version="${version}" #mandatory -displayName="Gateways To Eternity" #mandatory +displayName="${displayName}" #mandatory -description=''' -Invoke that from the dark beyond. Let it pour into this world. -A mod about creating temporary mob spawners in the form of portals. -''' +description='''${desc}''' -[[dependencies.gateways]] #optional +[[dependencies.${modid}]] #optional modId="forge" #mandatory mandatory=true #mandatory - versionRange="[34.1.0,)" #mandatory + versionRange="[${forgeVersion},)" #mandatory ordering="NONE" side="BOTH" -[[dependencies.gateways]] +[[dependencies.${modid}]] modId="minecraft" mandatory=true - versionRange="[1.16.3,)" + versionRange="[${mcVersion},)" ordering="NONE" side="BOTH" -[[dependencies.gateways]] +[[dependencies.${modid}]] modId="placebo" mandatory=true - versionRange="[4.3,)" + versionRange="[${placeboDep},)" ordering="NONE" side="BOTH" \ No newline at end of file