diff --git a/build.gradle b/build.gradle index 716c1c7..e93a696 100644 --- a/build.gradle +++ b/build.gradle @@ -1,17 +1,9 @@ -buildscript { - repositories { - mavenCentral() - maven { url = 'https://maven.minecraftforge.net' } - } - dependencies { - classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true - } +plugins { + id 'eclipse' + id 'idea' + id 'maven-publish' + id 'net.minecraftforge.gradle' version '[6.0,6.2)' } -apply plugin: 'net.minecraftforge.gradle' -// Only edit below this line, the above code adds and enables the necessary things for Forge to be setup. -apply plugin: 'idea' -apply plugin: 'maven-publish' -apply from: 'https://raw.githubusercontent.com/SizableShrimp/Forge-Class-Remapper/main/classremapper.gradle' version = "1.6.0" @@ -31,7 +23,7 @@ minecraft { // Simply re-run your setup task after changing the mappings to update your workspace. // mappings channel: 'snapshot', version: '20201028-1.16.3' // mappings channel: 'official', version: '1.16.5' - mappings channel: 'official', version: '1.19.2' + mappings channel: 'official', version: '1.20.1' // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable. accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') @@ -113,22 +105,27 @@ repositories { mavenCentral() mavenLocal() - maven { url = "https://www.cursemaven.com" } // curse mods + maven { + url "https://cursemaven.com" + content { + includeGroup "curse.maven" + } + } // curse mods } dependencies { // Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed // that the dep is a ForgeGradle 'patcher' dependency. And it's patches will be applied. // The userdev artifact is a special name and will get all sorts of transformations applied to it. - minecraft 'net.minecraftforge:forge:1.19.2-43.1.3' + minecraft 'net.minecraftforge:forge:1.20.1-47.1.3' //Integrated dynamics - implementation fg.deobf("curse.maven:cyclops-core-232758:3929867"); - implementation fg.deobf("curse.maven:common-capabilities-247007:3929863"); - implementation fg.deobf("curse.maven:integrated-dynamics-236307:3957305"); - implementation fg.deobf("curse.maven:integrated-tunnels-251389:3957245"); - implementation fg.deobf("curse.maven:integrated-crafting-287357:3929880"); - implementation fg.deobf("curse.maven:integrated-terminals-295910:3929892"); + implementation fg.deobf("curse.maven:cyclops-core-232758:5262063"); + implementation fg.deobf("curse.maven:common-capabilities-247007:4987207"); + implementation fg.deobf("curse.maven:integrated-dynamics-236307:5297722"); + implementation fg.deobf("curse.maven:integrated-tunnels-251389:5314672"); + implementation fg.deobf("curse.maven:integrated-crafting-287357:4987228"); + implementation fg.deobf("curse.maven:integrated-terminals-295910:5264620"); modLib "com.google.re2j:re2j:1.1" diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7a3265e..943f0cb 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 e7fa367..37aef8d 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip +networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip diff --git a/gradlew b/gradlew index cccdd3d..65dcd68 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/HEAD/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_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # 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,105 @@ 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*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=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=SC3045 + 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")" +# 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 \ + "$@" + +# 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' ' ' + )" '"$@"' + exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index f955316..93e3f59 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,4 +1,20 @@ -@if "%DEBUG%" == "" @echo off +@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 @rem Gradle startup script for Windows @@ -9,19 +25,23 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused 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% equ 0 goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -35,7 +55,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,38 +65,26 @@ 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 -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 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! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 +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% :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..291d399 --- /dev/null +++ b/settings.gradle @@ -0,0 +1,13 @@ +pluginManagement { + repositories { + gradlePluginPortal() + maven { + name = 'MinecraftForge' + url = 'https://maven.minecraftforge.net/' + } + } +} + +plugins { + id 'org.gradle.toolchains.foojay-resolver-convention' version '0.5.0' +} \ No newline at end of file diff --git a/src/main/java/me/tepis/integratednbt/Additions.java b/src/main/java/me/tepis/integratednbt/Additions.java index 21925fc..7251fc6 100644 --- a/src/main/java/me/tepis/integratednbt/Additions.java +++ b/src/main/java/me/tepis/integratednbt/Additions.java @@ -1,17 +1,24 @@ package me.tepis.integratednbt; import me.tepis.integratednbt.NBTExtractor.NBTExtractorBlockItem; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.SoundType; -import net.minecraft.world.level.material.Material; +import net.minecraft.core.registries.Registries; +import net.minecraft.network.chat.Component; import net.minecraft.world.inventory.MenuType; +import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.CreativeModeTabs; import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.world.level.material.MapColor; import net.minecraftforge.common.extensions.IForgeMenuType; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.RegistryObject; +import java.util.List; + public abstract class Additions { public static final DeferredRegister BLOCKS = DeferredRegister.create( ForgeRegistries.BLOCKS, @@ -20,7 +27,7 @@ public abstract class Additions { public static final RegistryObject NBT_EXTRACTOR_BLOCK = BLOCKS.register( NBTExtractor.REGISTRY_NAME, - () -> new NBTExtractor(Block.Properties.of(Material.HEAVY_METAL) + () -> new NBTExtractor(Block.Properties.of().mapColor(MapColor.METAL) .strength(5.0F) .sound(SoundType.METAL)) ); @@ -40,6 +47,23 @@ public abstract class Additions { NBTExtractorRemote::new ); + public static final DeferredRegister CREATIVE_MODE_TABS = DeferredRegister.create( + Registries.CREATIVE_MODE_TAB, + IntegratedNBT.MODID + ); + + public static final RegistryObject NBT_TAB = CREATIVE_MODE_TABS.register( + "tab", + () -> CreativeModeTab.builder() + .icon(() -> new ItemStack(NBT_EXTRACTOR_BLOCK_ITEM.get())) + .withTabsBefore(CreativeModeTabs.SPAWN_EGGS) + .title(Component.translatable("itemGroup.integratednbt")) + .displayItems((parameters, output) -> { + List stacks = Additions.ITEMS.getEntries().stream().map(reg -> new ItemStack(reg.get())).toList(); + output.acceptAll(stacks); + }).build() + ); + public static final DeferredRegister> CONTAINER_TYPES = DeferredRegister.create( ForgeRegistries.MENU_TYPES, IntegratedNBT.MODID diff --git a/src/main/java/me/tepis/integratednbt/ClientModEventSubscriber.java b/src/main/java/me/tepis/integratednbt/ClientModEventSubscriber.java index f655037..85b749f 100644 --- a/src/main/java/me/tepis/integratednbt/ClientModEventSubscriber.java +++ b/src/main/java/me/tepis/integratednbt/ClientModEventSubscriber.java @@ -3,7 +3,6 @@ import net.minecraft.client.gui.screens.MenuScreens; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.DeferredWorkQueue; import net.minecraftforge.fml.common.Mod.EventBusSubscriber; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; diff --git a/src/main/java/me/tepis/integratednbt/ExtendedContainerScreen.java b/src/main/java/me/tepis/integratednbt/ExtendedContainerScreen.java index 1f176c1..3f1eead 100644 --- a/src/main/java/me/tepis/integratednbt/ExtendedContainerScreen.java +++ b/src/main/java/me/tepis/integratednbt/ExtendedContainerScreen.java @@ -1,10 +1,8 @@ package me.tepis.integratednbt; -import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.blaze3d.vertex.VertexFormat; import com.mojang.blaze3d.vertex.VertexFormat.Mode; -import com.mojang.math.Matrix4f; import net.minecraft.client.gui.Font; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; import com.mojang.blaze3d.vertex.BufferBuilder; import com.mojang.blaze3d.vertex.Tesselator; @@ -14,6 +12,7 @@ import net.minecraft.util.FormattedCharSequence; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.FormattedText; +import org.joml.Matrix4f; public abstract class ExtendedContainerScreen extends AbstractContainerScreen { public ExtendedContainerScreen( @@ -49,9 +48,9 @@ public void drawTexturedModalRectScalable( tesselator.end(); } - public void drawSplitString(PoseStack matrixStack, Font fontRenderer, FormattedText text, int x, int y, int maxLength, int color) { + public void drawSplitString(GuiGraphics guiGraphics, Font fontRenderer, FormattedText text, int x, int y, int maxLength, int color) { for(FormattedCharSequence ireorderingprocessor : fontRenderer.split(text, maxLength)) { - fontRenderer.drawShadow(matrixStack, ireorderingprocessor, (float) x, (float) y, color); + guiGraphics.drawString(font, ireorderingprocessor, x, y, color); y += 9; } diff --git a/src/main/java/me/tepis/integratednbt/HoverTextImageButton.java b/src/main/java/me/tepis/integratednbt/HoverTextImageButton.java index b740302..7952ed8 100644 --- a/src/main/java/me/tepis/integratednbt/HoverTextImageButton.java +++ b/src/main/java/me/tepis/integratednbt/HoverTextImageButton.java @@ -1,8 +1,6 @@ package me.tepis.integratednbt; -import com.mojang.blaze3d.vertex.PoseStack; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Font; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.components.Button; import net.minecraft.network.chat.Component; @@ -45,10 +43,10 @@ public void setHoverTextRaw(List hoverText) { /** * Draw hover text if is hovered */ - public void drawHover(PoseStack matrixStack, int mouseX, int mouseY) { + public void drawHover(GuiGraphics guiGraphics, int mouseX, int mouseY) { if (this.isHovered) { - this.gui.renderTooltip( - matrixStack, + guiGraphics.renderTooltip( + this.gui.getMinecraft().font, FontHelper.wrap(this.hoverText, 200), mouseX, mouseY diff --git a/src/main/java/me/tepis/integratednbt/ImageButton.java b/src/main/java/me/tepis/integratednbt/ImageButton.java index ff9a56a..c5f51d7 100644 --- a/src/main/java/me/tepis/integratednbt/ImageButton.java +++ b/src/main/java/me/tepis/integratednbt/ImageButton.java @@ -1,13 +1,11 @@ package me.tepis.integratednbt; -import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.Button; import net.minecraft.network.chat.Component; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import org.lwjgl.opengl.GL11; /** * Basically net.minecraft.client.gui.ImageButton, but more dynamic @@ -24,7 +22,7 @@ public ImageButton( int y, Button.OnPress onPress ) { - super(x, y, textureNormal.getWidth(), textureNormal.getHeight(), Component.literal(""), onPress); + super(x, y, textureNormal.getWidth(), textureNormal.getHeight(), Component.literal(""), onPress, DEFAULT_NARRATION); this.textureNormal = textureNormal; this.textureHover = textureHover; } @@ -33,7 +31,7 @@ public ImageButton( * For lazy initialization of textures. */ public ImageButton(int x, int y, Button.OnPress onPress) { - super(x, y, 1, 1, Component.literal(""), onPress); + super(x, y, 1, 1, Component.literal(""), onPress, DEFAULT_NARRATION); } public void setTexture(TexturePart textureNormal, TexturePart textureHover) { @@ -47,17 +45,17 @@ public void setTexture(TexturePart textureNormal, TexturePart textureHover) { * Draws this button to the screen. */ @Override - public void renderButton(PoseStack matrixStack, int mouseX, int mouseY, float wtf) { + public void renderWidget(GuiGraphics guiGraphics, int mouseX, int mouseY, float wtf) { if (this.visible) { - this.isHovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && - mouseY < this.y + this.height; + this.isHovered = mouseX >= this.getX() && mouseY >= this.getY() && mouseX < this.getX() + this.width && + mouseY < this.getY() + this.height; TexturePart texturePart = this.isHovered ? this.textureHover : this.textureNormal; RenderSystem.defaultBlendFunc(); RenderSystem.enableDepthTest(); // RenderSystem.disableDepthTest(); - texturePart.renderTo(this, matrixStack, this.x, this.y, 0xffffff); + texturePart.renderTo(guiGraphics, this.getX(), this.getY(), 0xffffff); // GlStateManager._enableDepthTest(); } } diff --git a/src/main/java/me/tepis/integratednbt/IntegratedNBT.java b/src/main/java/me/tepis/integratednbt/IntegratedNBT.java index f178839..ae7126b 100644 --- a/src/main/java/me/tepis/integratednbt/IntegratedNBT.java +++ b/src/main/java/me/tepis/integratednbt/IntegratedNBT.java @@ -16,6 +16,7 @@ public IntegratedNBT() { IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); Additions.BLOCKS.register(modEventBus); Additions.ITEMS.register(modEventBus); + Additions.CREATIVE_MODE_TABS.register(modEventBus); Additions.CONTAINER_TYPES.register(modEventBus); Additions.BLOCK_ENTITIES.register(modEventBus); PacketHandler.register(); diff --git a/src/main/java/me/tepis/integratednbt/ItemGroups.java b/src/main/java/me/tepis/integratednbt/ItemGroups.java deleted file mode 100644 index 56cfc29..0000000 --- a/src/main/java/me/tepis/integratednbt/ItemGroups.java +++ /dev/null @@ -1,29 +0,0 @@ -package me.tepis.integratednbt; - -import net.minecraft.world.item.CreativeModeTab; -import net.minecraft.world.item.ItemStack; - -import javax.annotation.Nonnull; -import java.util.function.Supplier; - -public abstract class ItemGroups { - public static class ModItemGroup extends CreativeModeTab { - private final Supplier iconSupplier; - - public ModItemGroup(@Nonnull String name, @Nonnull Supplier iconSupplier) { - super(name); - this.iconSupplier = iconSupplier; - } - - @Override - @Nonnull - public ItemStack makeIcon() { - return this.iconSupplier.get(); - } - } - - public static final CreativeModeTab ITEM_GROUP = new ModItemGroup( - IntegratedNBT.MODID, - () -> new ItemStack(Additions.NBT_EXTRACTOR_BLOCK_ITEM.get()) - ); -} diff --git a/src/main/java/me/tepis/integratednbt/ModEventSubscriber.java b/src/main/java/me/tepis/integratednbt/ModEventSubscriber.java index 3d0491a..bcf5f9f 100644 --- a/src/main/java/me/tepis/integratednbt/ModEventSubscriber.java +++ b/src/main/java/me/tepis/integratednbt/ModEventSubscriber.java @@ -1,7 +1,6 @@ package me.tepis.integratednbt; import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.DeferredWorkQueue; import net.minecraftforge.fml.common.Mod.EventBusSubscriber; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import org.cyclops.integrateddynamics.core.evaluate.operator.OperatorRegistry; diff --git a/src/main/java/me/tepis/integratednbt/NBTExtractedVariableFacadeHandler.java b/src/main/java/me/tepis/integratednbt/NBTExtractedVariableFacadeHandler.java index 6ae4f72..0bd4406 100644 --- a/src/main/java/me/tepis/integratednbt/NBTExtractedVariableFacadeHandler.java +++ b/src/main/java/me/tepis/integratednbt/NBTExtractedVariableFacadeHandler.java @@ -2,6 +2,7 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.resources.ResourceLocation; +import org.cyclops.integrateddynamics.api.evaluate.variable.ValueDeseralizationContext; import org.cyclops.integrateddynamics.api.item.IVariableFacadeHandler; import java.util.Optional; @@ -26,7 +27,7 @@ public ResourceLocation getUniqueName() { } @Override - public NBTExtractedVariableFacade getVariableFacade(int id, CompoundTag tag) { + public NBTExtractedVariableFacade getVariableFacade(ValueDeseralizationContext valueDeseralizationContext, int id, CompoundTag tag) { int sourceNBTId = tag.getInt(KEY_SOURCE_NBT_ID); Optional extractionPath = NBTPath.fromNBT(tag.get(KEY_EXTRACTION_PATH)); byte defaultNBTId = tag.getByte(KEY_DEFAULT_NBT_ID); diff --git a/src/main/java/me/tepis/integratednbt/NBTExtractionOperator.java b/src/main/java/me/tepis/integratednbt/NBTExtractionOperator.java index 7cdf02c..9cebe73 100644 --- a/src/main/java/me/tepis/integratednbt/NBTExtractionOperator.java +++ b/src/main/java/me/tepis/integratednbt/NBTExtractionOperator.java @@ -16,6 +16,7 @@ import org.cyclops.integrateddynamics.core.evaluate.variable.ValueTypeNbt.ValueNbt; import org.cyclops.integrateddynamics.core.evaluate.variable.ValueTypes; import org.cyclops.integrateddynamics.core.helper.L10NValues; +import org.jetbrains.annotations.Nullable; import java.util.List; @@ -45,6 +46,22 @@ public ResourceLocation getUniqueName() { return UNIQUE_NAME; } + @Override + public String getInteractName() { + return "nbt_extraction"; + } + + @Nullable + @Override + public String getGlobalInteractNamePrefix() { + return null; + } + + @Override + public boolean shouldAlsoPrefixLocalScope() { + return false; + } + @Override public MutableComponent getLocalizedNameFull() { return Component.translatable("integratednbt:nbt_extraction_operator.full_name"); diff --git a/src/main/java/me/tepis/integratednbt/NBTExtractionOperatorSerializer.java b/src/main/java/me/tepis/integratednbt/NBTExtractionOperatorSerializer.java index 76b956f..5c07f89 100644 --- a/src/main/java/me/tepis/integratednbt/NBTExtractionOperatorSerializer.java +++ b/src/main/java/me/tepis/integratednbt/NBTExtractionOperatorSerializer.java @@ -7,6 +7,7 @@ import org.cyclops.integrateddynamics.api.evaluate.EvaluationException; import org.cyclops.integrateddynamics.api.evaluate.operator.IOperator; import org.cyclops.integrateddynamics.api.evaluate.operator.IOperatorSerializer; +import org.cyclops.integrateddynamics.api.evaluate.variable.ValueDeseralizationContext; public class NBTExtractionOperatorSerializer implements IOperatorSerializer { @Override @@ -28,7 +29,7 @@ public Tag serialize(NBTExtractionOperator operator) { } @Override - public NBTExtractionOperator deserialize(Tag nbt) throws EvaluationException { + public NBTExtractionOperator deserialize(ValueDeseralizationContext valueDeseralizationContext, Tag nbt) throws EvaluationException { try { CompoundTag tag = (CompoundTag) nbt; return new NBTExtractionOperator(NBTPath.fromNBT(tag.get("path")) diff --git a/src/main/java/me/tepis/integratednbt/NBTExtractor.java b/src/main/java/me/tepis/integratednbt/NBTExtractor.java index 327fca6..4fc0f0c 100644 --- a/src/main/java/me/tepis/integratednbt/NBTExtractor.java +++ b/src/main/java/me/tepis/integratednbt/NBTExtractor.java @@ -2,7 +2,6 @@ import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.EntityBlock; -import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.entity.BlockEntityTicker; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; @@ -23,10 +22,8 @@ import net.minecraft.world.level.block.Mirror; import net.minecraft.world.level.block.Rotation; import net.minecraft.core.BlockPos; -import net.minecraft.world.level.material.Material; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.network.chat.Component; -import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; import net.minecraftforge.network.NetworkHooks; import org.cyclops.integrateddynamics.core.helper.WrenchHelpers; @@ -41,7 +38,7 @@ public class NBTExtractor extends CabledHorizontalBlock implements EntityBlock { public static class NBTExtractorBlockItem extends BlockItem { public NBTExtractorBlockItem() { - super(NBT_EXTRACTOR_BLOCK.get(), new Item.Properties().tab(ItemGroups.ITEM_GROUP)); + super(NBT_EXTRACTOR_BLOCK.get(), new Item.Properties()); } @Override diff --git a/src/main/java/me/tepis/integratednbt/NBTExtractorBE.java b/src/main/java/me/tepis/integratednbt/NBTExtractorBE.java index ae66eca..6ef239c 100644 --- a/src/main/java/me/tepis/integratednbt/NBTExtractorBE.java +++ b/src/main/java/me/tepis/integratednbt/NBTExtractorBE.java @@ -31,6 +31,7 @@ import org.cyclops.integrateddynamics.api.block.cable.ICable; import org.cyclops.integrateddynamics.api.evaluate.variable.IValue; import org.cyclops.integrateddynamics.api.evaluate.variable.IVariable; +import org.cyclops.integrateddynamics.api.evaluate.variable.ValueDeseralizationContext; import org.cyclops.integrateddynamics.api.network.IEventListenableNetworkElement; import org.cyclops.integrateddynamics.api.network.INetwork; import org.cyclops.integrateddynamics.api.network.INetworkElement; @@ -246,11 +247,7 @@ public INetworkElement createNetworkElement(Level world, BlockPos blockPos) { } }; private NonNullList itemStacks = NonNullList.withSize(2, ItemStack.EMPTY); - private InventoryVariableEvaluator evaluator = new InventoryVariableEvaluator<>( - this, - SRC_NBT_SLOT, - ValueTypes.CATEGORY_ANY - ); + private InventoryVariableEvaluator evaluator; /** * A set of expanded paths in this extractor; *

@@ -287,6 +284,17 @@ public NBTExtractorBE(BlockPos pos, BlockState state) { super(Additions.NBT_EXTRACTOR_BE.get(), pos, state); this.expandedPaths = new HashSet<>(); this.expandedPaths.add(new NBTPath()); + + this.evaluator = createEvaluator(); + } + + protected InventoryVariableEvaluator createEvaluator() { + return new InventoryVariableEvaluator<>( + this, + SRC_NBT_SLOT, + ValueDeseralizationContext.of(getLevel()), + ValueTypes.CATEGORY_ANY + ); } public NBTExtractorOutputMode getOutputMode() { @@ -325,7 +333,8 @@ public void refreshVariables(boolean sendVariablesUpdateEvent) { this.variableContainerCapability.refreshVariables( this.networkCarrierCapability.getNetwork(), this, - sendVariablesUpdateEvent + sendVariablesUpdateEvent, + ValueDeseralizationContext.of(getLevel()) ); } @@ -588,7 +597,7 @@ public void saveAdditional(CompoundTag tag) { @Nonnull @Override public Component getDisplayName() { - return Component.translatable("tile.integratednbt:nbt_extractor.name"); + return Component.translatable("block.integratednbt.nbt_extractor"); } @Override @@ -665,6 +674,7 @@ private void updateOutVariable() { : this.lastEvaluatedNBT, this.extractionPath, this.defaultNBTId, + this.getLevel(), this.getBlockState() ); if (result != null) { diff --git a/src/main/java/me/tepis/integratednbt/NBTExtractorContainer.java b/src/main/java/me/tepis/integratednbt/NBTExtractorContainer.java index a8660f2..31d8e7b 100644 --- a/src/main/java/me/tepis/integratednbt/NBTExtractorContainer.java +++ b/src/main/java/me/tepis/integratednbt/NBTExtractorContainer.java @@ -128,7 +128,7 @@ private static NBTExtractorBE getTileEntity( ) { Objects.requireNonNull(playerInventory); Objects.requireNonNull(data); - BlockEntity tileAtPos = playerInventory.player.level.getBlockEntity(data.readBlockPos()); + BlockEntity tileAtPos = playerInventory.player.level().getBlockEntity(data.readBlockPos()); if (tileAtPos instanceof NBTExtractorBE) { return (NBTExtractorBE) tileAtPos; } diff --git a/src/main/java/me/tepis/integratednbt/NBTExtractorOutputMode.java b/src/main/java/me/tepis/integratednbt/NBTExtractorOutputMode.java index 156349e..161bd1a 100644 --- a/src/main/java/me/tepis/integratednbt/NBTExtractorOutputMode.java +++ b/src/main/java/me/tepis/integratednbt/NBTExtractorOutputMode.java @@ -1,6 +1,7 @@ package me.tepis.integratednbt; +import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.item.ItemStack; import net.minecraft.nbt.Tag; @@ -35,6 +36,7 @@ public ItemStack writeItemStack( Tag currentNBT, NBTPath extractionPath, byte defaultNBTId, + Level level, BlockState blockState ) { IVariableFacadeHandlerRegistry registry = @@ -70,6 +72,7 @@ public NBTExtractedVariableFacade create(int id) { outputVariableItemStack, NBTExtractedVariableFacadeHandler.getInstance(), factory, + level, null, blockState ); @@ -91,12 +94,13 @@ public ItemStack writeItemStack( Tag currentNBT, NBTPath extractionPath, byte defaultNBTId, + Level level, BlockState blockState ) { return getVariableUsingValue(ValueOperator.of(new NBTExtractionOperator( extractionPath, defaultNBTId - )), outputVariableItemStack, blockState); + )), outputVariableItemStack, level, blockState); } }, VALUE( @@ -112,6 +116,7 @@ public ItemStack writeItemStack( Tag currentNBT, NBTPath extractionPath, byte defaultNBTId, + Level level, BlockState blockState ) { sourceVariableFacadeSupplier.get(); // Refresh variable @@ -119,7 +124,7 @@ public ItemStack writeItemStack( IValue value = extractedNBT == null ? NBTValueConverter.getDefaultValue(defaultNBTId) : NBTValueConverter.mapNBTToValue(extractedNBT); - return getVariableUsingValue(value, outputVariableItemStack, blockState); + return getVariableUsingValue(value, outputVariableItemStack, level, blockState); } }, NBT_PATH( @@ -135,11 +140,13 @@ public ItemStack writeItemStack( Tag currentNBT, NBTPath extractionPath, byte defaultNBTId, + Level level, BlockState blockState ) { return getVariableUsingValue( ValueString.of(extractionPath.getCyclopsNBTPath()), outputVariableItemStack, + level, blockState ); } @@ -175,6 +182,7 @@ private static class Nest { private static ItemStack getVariableUsingValue( IValue value, ItemStack outputVariableItemStack, + Level level, BlockState blockState ) { IVariableFacadeHandlerRegistry registry = IntegratedDynamics._instance.getRegistryManager() @@ -197,6 +205,7 @@ public IValueTypeVariableFacade create(int id) { return new ValueTypeVariableFacade(id, value.getType(), value); } }, + level, null, blockState ); @@ -216,6 +225,7 @@ public abstract ItemStack writeItemStack( Tag currentNBT, NBTPath extractionPath, byte defaultNBTId, + Level level, BlockState blockState ); diff --git a/src/main/java/me/tepis/integratednbt/NBTExtractorRemote.java b/src/main/java/me/tepis/integratednbt/NBTExtractorRemote.java index 7834e74..509f87f 100644 --- a/src/main/java/me/tepis/integratednbt/NBTExtractorRemote.java +++ b/src/main/java/me/tepis/integratednbt/NBTExtractorRemote.java @@ -2,26 +2,25 @@ import me.tepis.integratednbt.network.PacketHandler; import me.tepis.integratednbt.network.serverbound.NBTExtractorRemoteRequestMessage; +import net.minecraft.ChatFormatting; import net.minecraft.client.Minecraft; -import net.minecraft.world.item.TooltipFlag; import net.minecraft.client.multiplayer.ClientLevel; -import net.minecraft.world.entity.player.Player; +import net.minecraft.core.BlockPos; +import net.minecraft.core.registries.Registries; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.InteractionResultHolder; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.TooltipFlag; import net.minecraft.world.item.context.UseOnContext; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.server.MinecraftServer; -import net.minecraft.world.InteractionResultHolder; -import net.minecraft.world.InteractionResult; -import net.minecraft.world.InteractionHand; -import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.Util; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Registry; -import net.minecraft.network.chat.Component; -import net.minecraft.ChatFormatting; import net.minecraft.world.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -35,7 +34,7 @@ public class NBTExtractorRemote extends Item { public static final String REGISTRY_NAME = "nbt_extractor_remote"; public NBTExtractorRemote() { - super(new Item.Properties().tab(ItemGroups.ITEM_GROUP).stacksTo(1)); + super(new Item.Properties().stacksTo(1)); } @Override @@ -102,7 +101,7 @@ public void serverUse(ItemStack itemStack, ServerPlayer player) { "integratednbt:nbt_extractor_remote.need_bind")); return; } - ResourceKey dimensionKey = ResourceKey.create(Registry.DIMENSION_REGISTRY, new ResourceLocation(nbt.getString("world"))); + ResourceKey dimensionKey = ResourceKey.create(Registries.DIMENSION, new ResourceLocation(nbt.getString("world"))); MinecraftServer server = player.getServer(); if (server == null) { player.sendSystemMessage(Component.translatable( diff --git a/src/main/java/me/tepis/integratednbt/NBTExtractorScreen.java b/src/main/java/me/tepis/integratednbt/NBTExtractorScreen.java index b75b565..838bdda 100644 --- a/src/main/java/me/tepis/integratednbt/NBTExtractorScreen.java +++ b/src/main/java/me/tepis/integratednbt/NBTExtractorScreen.java @@ -8,6 +8,7 @@ import me.tepis.integratednbt.network.serverbound.NBTExtractorUpdateOutputModeMessage; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.Button; import net.minecraft.client.resources.language.I18n; import net.minecraft.world.entity.player.Inventory; @@ -364,29 +365,30 @@ public boolean mouseScrolled( } @Override - protected void renderLabels(PoseStack matrixStack, int mouseX, int mouseY) { - this.outputModeButton.drawHover(matrixStack, mouseX, mouseY); - this.autoRefreshButton.drawHover(matrixStack, mouseX, mouseY); + protected void renderLabels(GuiGraphics guiGraphics, int mouseX, int mouseY) { + this.outputModeButton.drawHover(guiGraphics, mouseX, mouseY); + this.autoRefreshButton.drawHover(guiGraphics, mouseX, mouseY); } @Override - public void render(PoseStack matrixStack, int mouseX, int mouseY, float partialTicks) { - this.renderBackground(matrixStack); - super.render(matrixStack, mouseX, mouseY, partialTicks); - this.outputModeButton.render(matrixStack, mouseX, mouseY, partialTicks); - this.autoRefreshButton.render(matrixStack, mouseX, mouseY, partialTicks); - this.renderTooltip(matrixStack, mouseX, mouseY); + public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks) { + this.renderBackground(guiGraphics); + super.render(guiGraphics, mouseX, mouseY, partialTicks); + this.outputModeButton.render(guiGraphics, mouseX, mouseY, partialTicks); + this.autoRefreshButton.render(guiGraphics, mouseX, mouseY, partialTicks); + this.renderTooltip(guiGraphics, mouseX, mouseY); } @Override - protected void renderBg(PoseStack matrixStack, float partialTicks, int mouseX, int mouseY) { - this.renderGuiParts(matrixStack); - this.fontRenderer.draw( - matrixStack, + protected void renderBg(GuiGraphics guiGraphics, float partialTicks, int mouseX, int mouseY) { + this.renderGuiParts(guiGraphics); + guiGraphics.drawString( + font, I18n.get("block.integratednbt.nbt_extractor"), this.padding + 8, this.padding + 9, - 4210752 + 4210752, + false ); // Scissor test allows restricting rendering to a rectangular portion of the screen. // In this case, we only want to render in the screen area of the NBT Extractor. @@ -400,13 +402,13 @@ protected void renderBg(PoseStack matrixStack, float partialTicks, int mouseX, i Slot srcNBTSlot = this.nbtExtractorContainer.getSrcNBTSlot(); if (!srcNBTSlot.hasItem()) { errorCode = null; - this.renderWelcome(matrixStack); + this.renderWelcome(guiGraphics); } else if (errorCode == null) { - this.renderLoading(matrixStack); + this.renderLoading(guiGraphics); } else if (!errorCode.equals(ErrorCode.NO_ERROR)) { - this.renderError(matrixStack); + this.renderError(guiGraphics); } else { - this.treeViewer.render(matrixStack, nbt, mouseX, mouseY); + this.treeViewer.render(guiGraphics, nbt, mouseX, mouseY); } glDisable(GL_SCISSOR_TEST); } @@ -429,18 +431,18 @@ public boolean isPauseScreen() { return false; } - private void renderGuiParts(PoseStack matrixStack) { + private void renderGuiParts(GuiGraphics guiGraphics) { int padding = this.padding; int screenWidth = this.screenWidth; int screenHeight = this.screenHeight; GUI_TEXTURE.bind(); - PART0.renderTo(this, matrixStack, padding, padding); - PART1.renderToScaled(this, matrixStack, padding + SIDE_BORDER_SIZE, padding, screenWidth, -1); - PART2.renderTo(this, matrixStack, this.width - padding - SIDE_BORDER_SIZE, padding); - PART3.renderToScaled(this, matrixStack, padding, padding + TOP_BORDER_SIZE, -1, screenHeight); + PART0.renderTo(guiGraphics, padding, padding); + PART1.renderToScaled(this, guiGraphics.pose(), padding + SIDE_BORDER_SIZE, padding, screenWidth, -1); + PART2.renderTo(guiGraphics, this.width - padding - SIDE_BORDER_SIZE, padding); + PART3.renderToScaled(this, guiGraphics.pose(), padding, padding + TOP_BORDER_SIZE, -1, screenHeight); PART4.renderToScaled( this, - matrixStack, + guiGraphics.pose(), padding + SIDE_BORDER_SIZE, padding + TOP_BORDER_SIZE, screenWidth, @@ -448,66 +450,64 @@ private void renderGuiParts(PoseStack matrixStack) { ); PART5.renderToScaled( this, - matrixStack, + guiGraphics.pose(), this.width - padding - SIDE_BORDER_SIZE, padding + TOP_BORDER_SIZE, -1, screenHeight ); int topOfPart6789 = this.height - padding - INVENTORY_HEIGHT; - PART6.renderTo(this, matrixStack, padding, topOfPart6789); + PART6.renderTo(guiGraphics, padding, topOfPart6789); int part7Width2x = this.width - 2 * padding - 2 * SIDE_BORDER_SIZE - INVENTORY_WIDTH; int part7WidthFloor = (int) Math.floor(part7Width2x / 2.0); int part7WidthCeil = (int) Math.ceil(part7Width2x / 2.0); PART7.renderToScaled( this, - matrixStack, + guiGraphics.pose(), padding + SIDE_BORDER_SIZE, topOfPart6789, part7WidthFloor, -1 ); PART8.renderTo( - this, - matrixStack, + guiGraphics, padding + SIDE_BORDER_SIZE + part7WidthFloor, topOfPart6789 ); PART7.renderToScaled( - this, - matrixStack, + this, + guiGraphics.pose(), padding + SIDE_BORDER_SIZE + part7WidthFloor + INVENTORY_WIDTH, topOfPart6789, part7WidthCeil, -1 ); PART9.renderTo( - this, - matrixStack, + guiGraphics, this.width - padding - SIDE_BORDER_SIZE, topOfPart6789 ); } - private void renderWelcome(PoseStack matrixStack) { + private void renderWelcome(GuiGraphics guiGraphics) { this.renderCenteredTextGroup( - matrixStack, + guiGraphics, I18n.get("integratednbt:nbt_extractor.welcome"), 0x00FFFF, I18n.get("integratednbt:nbt_extractor.welcome.description") ); } - private void renderLoading(PoseStack matrixStack) { + private void renderLoading(GuiGraphics guiGraphics) { this.renderCenteredTextGroup( - matrixStack, + guiGraphics, I18n.get("integratednbt:nbt_extractor.loading"), 0xFFFF00, I18n.get("integratednbt:nbt_extractor.loading.description") ); } - private void renderError(PoseStack matrixStack) { + private void renderError(GuiGraphics guiGraphics) { String message = ""; if (errorMessage != null) { message = errorMessage.getString(); @@ -525,38 +525,41 @@ private void renderError(PoseStack matrixStack) { } } this.renderCenteredTextGroup( - matrixStack, + guiGraphics, I18n.get("integratednbt:nbt_extractor.error"), 0xFF5555, message ); } - private void renderCenteredTextGroup(PoseStack matrixStack, String title, int titleColor, String description) { - matrixStack.pushPose(); + private void renderCenteredTextGroup(GuiGraphics guiGraphics, String title, int titleColor, String description) { + PoseStack poseStack = guiGraphics.pose(); + poseStack.pushPose(); try { int x = this.screenCenterX(); int y = this.screenCenterY(); int titleWidth = this.fontRenderer.width(title); - matrixStack.pushPose(); + poseStack.pushPose(); try { - this.scaleAt(matrixStack, x, y, 2); - this.fontRenderer.draw( - matrixStack, + this.scaleAt(poseStack, x, y, 2); + guiGraphics.drawString( + this.fontRenderer, title, -titleWidth / 2f, -this.fontRenderer.lineHeight - 1, - titleColor + titleColor, + false ); } finally { - matrixStack.popPose(); + poseStack.popPose(); } - this.scaleAt(matrixStack, x, y, 1); + this.scaleAt(poseStack, x, y, 1); int wrappingWidth = (int) (this.screenWidth * CENTERED_TEXT_MAX_RATIO); int descriptionWidth = this.fontRenderer.width(description); if (descriptionWidth > wrappingWidth) { // this.fontRenderer.drawSplitString( - this.fontRenderer.drawWordWrap( + guiGraphics.drawWordWrap( + this.fontRenderer, Component.literal(description), -wrappingWidth / 2, 4, @@ -564,16 +567,17 @@ private void renderCenteredTextGroup(PoseStack matrixStack, String title, int ti 0xFFFFFF ); } else { - this.fontRenderer.draw( - matrixStack, + guiGraphics.drawString( + this.fontRenderer, description, -descriptionWidth / 2f, 4, - 0xFFFFFF + 0xFFFFFF, + false ); } } finally { - matrixStack.popPose(); + poseStack.popPose(); } } diff --git a/src/main/java/me/tepis/integratednbt/NBTTreeViewer.java b/src/main/java/me/tepis/integratednbt/NBTTreeViewer.java index 283716c..fb4361b 100644 --- a/src/main/java/me/tepis/integratednbt/NBTTreeViewer.java +++ b/src/main/java/me/tepis/integratednbt/NBTTreeViewer.java @@ -1,9 +1,9 @@ package me.tepis.integratednbt; -import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.resources.language.I18n; import net.minecraft.nbt.ByteTag; import net.minecraft.nbt.CompoundTag; @@ -140,7 +140,7 @@ private void startScrollTransition() { } private boolean renderKVPair( - PoseStack matrixStack, + GuiGraphics guiGraphics, String label, String value, int valueColor @@ -168,7 +168,7 @@ private boolean renderKVPair( } PURE_COLOR.renderToScaled( this.gui, - matrixStack, + guiGraphics.pose(), this.currentX - 1, this.currentY - 1, rightBoundary - this.currentX + 1, @@ -178,21 +178,22 @@ private boolean renderKVPair( } } if (value.isEmpty()) { - this.fontRenderer.draw(matrixStack, label, this.currentX, this.currentY, LABEL_COLOR); + guiGraphics.drawString(this.fontRenderer, label, this.currentX, this.currentY, LABEL_COLOR, false); } else { - int valueX = this.fontRenderer.draw( - matrixStack, + int valueX = guiGraphics.drawString( + this.fontRenderer, label + ": ", this.currentX, this.currentY, - LABEL_COLOR + LABEL_COLOR, + false ); - this.fontRenderer.draw(matrixStack, value, valueX, this.currentY, valueColor); + guiGraphics.drawString(this.fontRenderer, value, valueX, this.currentY, valueColor); } return isHovering; } - private void renderExpandableButton(PoseStack matrixStack, boolean expanded) { + private void renderExpandableButton(GuiGraphics guiGraphics, boolean expanded) { boolean hovering = ( this.mouseX >= this.currentX && this.mouseX < (this.currentX + EXPAND_BUTTON_SIZE) && @@ -205,11 +206,11 @@ private void renderExpandableButton(PoseStack matrixStack, boolean expanded) { if (hovering) { this.hoveringExpandableButton = this.currentPath.copy(); } - part.renderTo(this.gui, matrixStack, this.currentX, this.currentY, EXPAND_COLOR); + part.renderTo(guiGraphics, this.currentX, this.currentY, EXPAND_COLOR); this.currentX += EXPAND_BUTTON_SIZE + EXPAND_BUTTON_RIGHT_MARGIN; } - public void render(PoseStack matrixStack, Tag nbt, int absMouseX, int absMouseY) { + public void render(GuiGraphics guiGraphics, Tag nbt, int absMouseX, int absMouseY) { this.hoveringPath = null; this.hoveringNBTNode = null; this.hoveringExpandableButton = null; @@ -218,22 +219,24 @@ public void render(PoseStack matrixStack, Tag nbt, int absMouseX, int absMouseY) this.updateScroll(); this.mouseX = absMouseX - this.left; this.mouseY = (int) (absMouseY - this.top + this.renderScroll); - matrixStack.pushPose(); + PoseStack poseStack = guiGraphics.pose(); + poseStack.pushPose(); try { - matrixStack.translate(this.left, this.top - this.renderScroll, 0); + poseStack.translate(this.left, this.top - this.renderScroll, 0); if (nbt == null) { - this.fontRenderer.draw( - matrixStack, + guiGraphics.drawString( + this.fontRenderer, I18n.get("integratednbt:nbt_extractor.empty"), SCREEN_EDGE, this.currentY, - EMPTY_COLOR + EMPTY_COLOR, + false ); } else { - this.renderNode(matrixStack, I18n.get("integratednbt:nbt_extractor.root"), nbt); + this.renderNode(guiGraphics, I18n.get("integratednbt:nbt_extractor.root"), nbt); } int totalHeight = this.currentY + SCREEN_EDGE; - matrixStack.translate(0, this.renderScroll, 0); + poseStack.translate(0, this.renderScroll, 0); this.maxScroll = Math.max(totalHeight - this.height, 0); if (this.scrollTop.get() > this.maxScroll) { this.scrollTop.set(this.maxScroll); @@ -242,7 +245,7 @@ public void render(PoseStack matrixStack, Tag nbt, int absMouseX, int absMouseY) if (this.maxScroll != 0) { PURE_COLOR.renderToScaled( this.gui, - matrixStack, + guiGraphics.pose(), this.width - SCROLL_BAR_PADDING * 2 - SCROLL_BAR_WIDTH, -1, SCROLL_BAR_PADDING * 2 + SCROLL_BAR_WIDTH + 2, @@ -251,7 +254,7 @@ public void render(PoseStack matrixStack, Tag nbt, int absMouseX, int absMouseY) ); PURE_COLOR.renderToScaled( this.gui, - matrixStack, + guiGraphics.pose(), this.width - SCROLL_BAR_PADDING - SCROLL_BAR_WIDTH, SCROLL_BAR_PADDING + (int) ( this.renderScroll / totalHeight * ( @@ -299,15 +302,15 @@ public void render(PoseStack matrixStack, Tag nbt, int absMouseX, int absMouseY) "integratednbt:nbt_extractor.tooltip.right_click_expand")); } } - this.gui.renderTooltip( - matrixStack, + guiGraphics.renderTooltip( + this.fontRenderer, FontHelper.wrap(list.stream().map(s -> Component.literal(s)).collect(Collectors.toList()), 250), this.mouseX, (int) (this.mouseY - this.renderScroll) ); } } finally { - matrixStack.popPose(); + poseStack.popPose(); } } @@ -354,20 +357,21 @@ private static boolean isNodeExpandable(Tag nbt) { return nbtId == 9 || nbtId == 10; } - private void renderEmpty(PoseStack matrixStack) { + private void renderEmpty(GuiGraphics guiGraphics) { this.currentX = (this.currentPath.getDepth() + 1) * INDENTATION + SCREEN_EDGE + EXPAND_BUTTON_RIGHT_MARGIN + EXPAND_BUTTON_SIZE; - this.fontRenderer.draw( - matrixStack, + guiGraphics.drawString( + this.fontRenderer, I18n.get("integratednbt:nbt_extractor.empty"), this.currentX, this.currentY, - EMPTY_COLOR + EMPTY_COLOR, + false ); this.currentY += this.fontRenderer.lineHeight + LINE_SPACE; } - private void renderNode(PoseStack matrixStack, String label, Tag node) { + private void renderNode(GuiGraphics guiGraphics, String label, Tag node) { this.currentX = this.currentPath.getDepth() * INDENTATION + SCREEN_EDGE; boolean isExpandedIfExpandable = false; if (isNodeExpandable(node)) { @@ -378,11 +382,12 @@ private void renderNode(PoseStack matrixStack, String label, Tag node) { boolean isHoveringText; + PoseStack poseStack = guiGraphics.pose(); // Render Value switch (node.getId()) { case 1: // Byte isHoveringText = this.renderKVPair( - matrixStack, + guiGraphics, label, String.valueOf(((ByteTag) node).getAsByte()), NUMBER_COLOR @@ -390,7 +395,7 @@ private void renderNode(PoseStack matrixStack, String label, Tag node) { break; case 2: // Short isHoveringText = this.renderKVPair( - matrixStack, + guiGraphics, label, String.valueOf(((ShortTag) node).getAsShort()), NUMBER_COLOR @@ -398,7 +403,7 @@ private void renderNode(PoseStack matrixStack, String label, Tag node) { break; case 3: // Int isHoveringText = this.renderKVPair( - matrixStack, + guiGraphics, label, String.valueOf(((IntTag) node).getAsInt()), NUMBER_COLOR @@ -406,7 +411,7 @@ private void renderNode(PoseStack matrixStack, String label, Tag node) { break; case 4: // Long isHoveringText = this.renderKVPair( - matrixStack, + guiGraphics, label, String.valueOf(((LongTag) node).getAsLong()), NUMBER_COLOR @@ -414,7 +419,7 @@ private void renderNode(PoseStack matrixStack, String label, Tag node) { break; case 5: // Float isHoveringText = this.renderKVPair( - matrixStack, + guiGraphics, label, String.valueOf(((FloatTag) node).getAsFloat()), NUMBER_COLOR @@ -422,7 +427,7 @@ private void renderNode(PoseStack matrixStack, String label, Tag node) { break; case 6: // Double isHoveringText = this.renderKVPair( - matrixStack, + guiGraphics, label, String.valueOf(((DoubleTag) node).getAsDouble()), NUMBER_COLOR @@ -432,7 +437,7 @@ private void renderNode(PoseStack matrixStack, String label, Tag node) { case 11: // Int Array case 12: // Long Array isHoveringText = this.renderKVPair( - matrixStack, + guiGraphics, label, "[]", NUMBER_COLOR @@ -440,7 +445,7 @@ private void renderNode(PoseStack matrixStack, String label, Tag node) { break; case 8: // String isHoveringText = this.renderKVPair( - matrixStack, + guiGraphics, label, // Yes, I understand technically we should escape double quotes in the string. // However, I think that will just make it confusing. @@ -450,9 +455,9 @@ private void renderNode(PoseStack matrixStack, String label, Tag node) { break; case 9: // List case 10: { // Compound - this.renderExpandableButton(matrixStack, isExpandedIfExpandable); + this.renderExpandableButton(guiGraphics, isExpandedIfExpandable); isHoveringText = this.renderKVPair( - matrixStack, + guiGraphics, label, (isExpandedIfExpandable ? "" : node.toString()), COMPLEX_COLOR @@ -472,13 +477,13 @@ private void renderNode(PoseStack matrixStack, String label, Tag node) { switch (node.getId()) { case 9: { // List if (((ListTag) node).size() == 0) { - this.renderEmpty(matrixStack); + this.renderEmpty(guiGraphics); break; } int i = 0; for (Tag item : (ListTag) node) { this.currentPath.pushIndex(i); - this.renderNode(matrixStack, "#" + i, item); + this.renderNode(guiGraphics, "#" + i, item); this.currentPath.pop(); i++; } @@ -486,13 +491,13 @@ private void renderNode(PoseStack matrixStack, String label, Tag node) { } case 10: { // Compound if (((CompoundTag) node).size() == 0) { - this.renderEmpty(matrixStack); + this.renderEmpty(guiGraphics); break; } CompoundTag compound = (CompoundTag) node; for (String key : compound.getAllKeys()) { this.currentPath.pushKey(key); - this.renderNode(matrixStack, key, compound.get(key)); + this.renderNode(guiGraphics, key, compound.get(key)); this.currentPath.pop(); } break; diff --git a/src/main/java/me/tepis/integratednbt/Texture.java b/src/main/java/me/tepis/integratednbt/Texture.java index cb32138..19b1bd5 100644 --- a/src/main/java/me/tepis/integratednbt/Texture.java +++ b/src/main/java/me/tepis/integratednbt/Texture.java @@ -18,6 +18,10 @@ public void bind() { RenderSystem.setShaderTexture(0, this.resourceLocation); } + public ResourceLocation getResourceLocation() { + return resourceLocation; + } + public TexturePart createPart(int x, int y, int width, int height) { return new TexturePart(this, x, y, width, height); } diff --git a/src/main/java/me/tepis/integratednbt/TexturePart.java b/src/main/java/me/tepis/integratednbt/TexturePart.java index cb986c7..2ad5a39 100644 --- a/src/main/java/me/tepis/integratednbt/TexturePart.java +++ b/src/main/java/me/tepis/integratednbt/TexturePart.java @@ -2,9 +2,9 @@ import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.math.Matrix4f; -import net.minecraft.client.gui.GuiComponent; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.renderer.GameRenderer; +import org.joml.Matrix4f; /** * Represents a part in a texture; Offers help method for quick rendering @@ -24,9 +24,8 @@ public TexturePart(Texture texture, int x, int y, int width, int height) { this.height = height; } - public void renderTo(GuiComponent gui, PoseStack matrixStack, int x, int y) { - this.texture.bind(); - gui.blit(matrixStack, x, y, this.x, this.y, this.width, this.height); + public void renderTo(GuiGraphics graphics, int x, int y) { + graphics.blit(this.texture.getResourceLocation(), x, y, this.x, this.y, this.width, this.height); } private void setColorInt(int color) { @@ -38,16 +37,16 @@ private void setColorInt(int color) { ); } - public void renderTo(GuiComponent gui, PoseStack matrixStack, int x, int y, int color) { + public void renderTo(GuiGraphics gui, int x, int y, int color) { this.setColorInt(color); RenderSystem.setShader(GameRenderer::getPositionTexShader); RenderSystem.enableBlend(); - this.renderTo(gui, matrixStack, x, y); + this.renderTo(gui, x, y); } - public void renderToScaled(ExtendedContainerScreen gui, PoseStack matrixStack, int x, int y, int width, int height) { + public void renderToScaled(ExtendedContainerScreen gui, PoseStack poseStack, int x, int y, int width, int height) { this.texture.bind(); - Matrix4f matrix = matrixStack.last().pose(); + Matrix4f matrix = poseStack.last().pose(); gui.drawTexturedModalRectScalable( matrix, x, @@ -61,11 +60,11 @@ public void renderToScaled(ExtendedContainerScreen gui, PoseStack matrixStack ); } - public void renderToScaled(ExtendedContainerScreen gui, PoseStack matrixStack, int x, int y, int width, int height, int color) { + public void renderToScaled(ExtendedContainerScreen gui, PoseStack poseStack, int x, int y, int width, int height, int color) { this.setColorInt(color); RenderSystem.setShader(GameRenderer::getPositionTexShader); RenderSystem.enableBlend(); - this.renderToScaled(gui, matrixStack, x, y, width, height); + this.renderToScaled(gui, poseStack, x, y, width, height); } public int getWidth() { diff --git a/src/main/java/me/tepis/integratednbt/network/MessageHandler.java b/src/main/java/me/tepis/integratednbt/network/MessageHandler.java index 75d201e..58532ef 100644 --- a/src/main/java/me/tepis/integratednbt/network/MessageHandler.java +++ b/src/main/java/me/tepis/integratednbt/network/MessageHandler.java @@ -4,8 +4,6 @@ import net.minecraftforge.network.NetworkEvent.Context; import net.minecraftforge.network.simple.SimpleChannel; -import java.util.function.Supplier; - public abstract class MessageHandler { public void register(SimpleChannel channel, int id) { channel.registerMessage( diff --git a/src/main/java/me/tepis/integratednbt/network/clientbound/NBTExtractorUpdateClientMessage.java b/src/main/java/me/tepis/integratednbt/network/clientbound/NBTExtractorUpdateClientMessage.java index 73581b0..672212d 100644 --- a/src/main/java/me/tepis/integratednbt/network/clientbound/NBTExtractorUpdateClientMessage.java +++ b/src/main/java/me/tepis/integratednbt/network/clientbound/NBTExtractorUpdateClientMessage.java @@ -12,8 +12,6 @@ import net.minecraft.network.chat.Component; import net.minecraftforge.network.NetworkEvent.Context; -import java.util.function.Supplier; - /** * From server to client; * Updates NBT tree, error code, and/or extraction path for the client diff --git a/src/main/java/me/tepis/integratednbt/network/serverbound/NBTExtractorRemoteRequestMessage.java b/src/main/java/me/tepis/integratednbt/network/serverbound/NBTExtractorRemoteRequestMessage.java index 9f696e9..c2990df 100644 --- a/src/main/java/me/tepis/integratednbt/network/serverbound/NBTExtractorRemoteRequestMessage.java +++ b/src/main/java/me/tepis/integratednbt/network/serverbound/NBTExtractorRemoteRequestMessage.java @@ -9,8 +9,6 @@ import net.minecraft.world.InteractionHand; import net.minecraftforge.network.NetworkEvent.Context; -import java.util.function.Supplier; - /** * From client to server; * Requests to open the GUI for a NBT Extractor at location diff --git a/src/main/java/me/tepis/integratednbt/network/serverbound/NBTExtractorUpdateServerMessageBase.java b/src/main/java/me/tepis/integratednbt/network/serverbound/NBTExtractorUpdateServerMessageBase.java index d7318b5..b5099cd 100644 --- a/src/main/java/me/tepis/integratednbt/network/serverbound/NBTExtractorUpdateServerMessageBase.java +++ b/src/main/java/me/tepis/integratednbt/network/serverbound/NBTExtractorUpdateServerMessageBase.java @@ -25,7 +25,7 @@ public final void onMessage(T message, Context ctx) { ctx.enqueueWork(() -> { ServerPlayer player = ctx.getSender(); assert player != null; - Level world = player.level; + Level world = player.level(); if (!world.hasChunkAt(message.blockPos)) { return; } diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index 5f370a2..469e151 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -13,18 +13,18 @@ Integrated NBT is an addon for Integrated Dynamics. It offers a simpler way of e [[dependencies.integratednbt]] modId="integrateddynamics" mandatory=true - versionRange="[1.11.9,)" + versionRange="[1.19.0,)" ordering="AFTER" side="BOTH" [[dependencies.integratednbt]] modId="forge" mandatory=true - versionRange="[43.1,)" + versionRange="[47.1,)" ordering="NONE" side="BOTH" [[dependencies.integratednbt]] modId="minecraft" mandatory=true - versionRange="[1.19.2]" + versionRange="[1.20.1]" ordering="NONE" side="BOTH" diff --git a/src/main/resources/assets/integratednbt/models/item/nbt_extractor_remote.json b/src/main/resources/assets/integratednbt/models/item/nbt_extractor_remote.json index 1d1834e..d24fa2b 100644 --- a/src/main/resources/assets/integratednbt/models/item/nbt_extractor_remote.json +++ b/src/main/resources/assets/integratednbt/models/item/nbt_extractor_remote.json @@ -1,6 +1,6 @@ { "parent": "item/generated", "textures": { - "layer0": "integratednbt:items/nbt_extractor_remote" + "layer0": "integratednbt:item/nbt_extractor_remote" } } \ No newline at end of file diff --git a/src/main/resources/assets/integratednbt/textures/items/nbt_extractor_remote.png b/src/main/resources/assets/integratednbt/textures/item/nbt_extractor_remote.png similarity index 100% rename from src/main/resources/assets/integratednbt/textures/items/nbt_extractor_remote.png rename to src/main/resources/assets/integratednbt/textures/item/nbt_extractor_remote.png diff --git a/src/main/resources/pack.mcmeta b/src/main/resources/pack.mcmeta index 4018267..afb3bf2 100644 --- a/src/main/resources/pack.mcmeta +++ b/src/main/resources/pack.mcmeta @@ -1,7 +1,6 @@ { "pack": { - "description": "examplemod resources", - "pack_format": 3, - "_comment": "A pack_format of 3 should be used starting with Minecraft 1.11. All resources, including language files, should be lowercase (eg: en_us.lang). A pack_format of 2 will load your mod resources with LegacyV2Adapter, which requires language files to have uppercase letters (eg: en_US.lang)." + "description": "Integrated NBT resources", + "pack_format": 15 } }