aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build.gradle28
-rw-r--r--gradle.properties4
-rw-r--r--gradle/wrapper/gradle-wrapper.jarbin54708 -> 59536 bytes
-rw-r--r--gradle/wrapper/gradle-wrapper.properties2
-rw-r--r--gradlew282
-rw-r--r--src/main/java/com/anthonyhilyard/iceberg/IcebergServer.java6
-rw-r--r--src/main/java/com/anthonyhilyard/iceberg/Loader.java6
-rw-r--r--src/main/java/com/anthonyhilyard/iceberg/events/CriterionEvent.java4
-rw-r--r--src/main/java/com/anthonyhilyard/iceberg/events/EntityFluidEvent.java4
-rw-r--r--src/main/java/com/anthonyhilyard/iceberg/events/NewItemPickupEvent.java6
-rw-r--r--src/main/java/com/anthonyhilyard/iceberg/events/RenderTooltipExtEvent.java32
-rw-r--r--src/main/java/com/anthonyhilyard/iceberg/mixin/EntityMixin.java10
-rw-r--r--src/main/java/com/anthonyhilyard/iceberg/mixin/ForgeEventFactoryMixin.java16
-rw-r--r--src/main/java/com/anthonyhilyard/iceberg/mixin/PlayerAdvancementsMixin.java6
-rw-r--r--src/main/java/com/anthonyhilyard/iceberg/network/IcebergNetworkProtocol.java6
-rw-r--r--src/main/java/com/anthonyhilyard/iceberg/network/NewItemPickupEventPacket.java10
-rw-r--r--src/main/java/com/anthonyhilyard/iceberg/registry/AutoRegistry.java33
-rw-r--r--src/main/java/com/anthonyhilyard/iceberg/registry/RendererRegistrar.java27
-rw-r--r--src/main/java/com/anthonyhilyard/iceberg/renderer/CustomItemRenderer.java136
-rw-r--r--src/main/java/com/anthonyhilyard/iceberg/util/Easing.java8
-rw-r--r--src/main/java/com/anthonyhilyard/iceberg/util/GuiHelper.java19
-rw-r--r--src/main/java/com/anthonyhilyard/iceberg/util/ItemColor.java16
-rw-r--r--src/main/java/com/anthonyhilyard/iceberg/util/Tooltips.java83
-rw-r--r--src/main/resources/META-INF/mods.toml6
-rw-r--r--src/main/resources/iceberg.mixins.json2
25 files changed, 397 insertions, 355 deletions
diff --git a/build.gradle b/build.gradle
index 0d0e82f..a3ff7bb 100644
--- a/build.gradle
+++ b/build.gradle
@@ -6,7 +6,7 @@ buildscript {
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'
}
}
@@ -16,7 +16,7 @@ apply plugin: 'eclipse'
archivesBaseName = name + '-' + mcVersion
-sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8'
+java.toolchain.languageVersion = JavaLanguageVersion.of(16)
mixin {
add sourceSets.main, "${project.name.toLowerCase()}.refmap.json"
@@ -40,26 +40,6 @@ minecraft {
}
}
-// Process resources on build
-processResources {
- // This will ensure that this task is redone when the versions change.
- inputs.property 'version', project.version
-
- // Replace stuff in mods.toml, nothing else
- from(sourceSets.main.resources.srcDirs) {
- include 'META-INF/mods.toml'
-
- // Replace version
- expand 'version':project.version
- }
-
- // Copy everything else except the mods.toml
- from(sourceSets.main.resources.srcDirs) {
- exclude 'META-INF/mods.toml'
- }
-}
-
-
sourceSets {
main {
resources {
@@ -69,8 +49,8 @@ sourceSets {
}
dependencies {
- minecraft 'net.minecraftforge:forge:' + project.properties.mcVersion + '-' + forgeVersion
- annotationProcessor 'org.spongepowered:mixin:0.8:processor'
+ minecraft "net.minecraftforge:forge:${project.mcVersion}-${project.forgeVersion}"
+ annotationProcessor 'org.spongepowered:mixin:0.8.4:processor'
}
jar {
diff --git a/gradle.properties b/gradle.properties
index 2534db5..cf5e124 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -7,5 +7,5 @@ name=Iceberg
group=com.anthonyhilyard.iceberg
author=anthonyhilyard
version=1.0.12
-mcVersion=1.16.5
-forgeVersion=36.2.2 \ No newline at end of file
+mcVersion=1.17.1
+forgeVersion=37.0.90
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
index 7a3265e..7454180 100644
--- a/gradle/wrapper/gradle-wrapper.jar
+++ b/gradle/wrapper/gradle-wrapper.jar
Binary files differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 1d5b29f..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.10.3-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/src/main/java/com/anthonyhilyard/iceberg/IcebergServer.java b/src/main/java/com/anthonyhilyard/iceberg/IcebergServer.java
index c5baa64..4ad4e48 100644
--- a/src/main/java/com/anthonyhilyard/iceberg/IcebergServer.java
+++ b/src/main/java/com/anthonyhilyard/iceberg/IcebergServer.java
@@ -3,7 +3,6 @@ package com.anthonyhilyard.iceberg;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus;
-import net.minecraftforge.fml.event.server.FMLServerStartingEvent;
@Mod.EventBusSubscriber(modid = Loader.MODID, bus = Bus.MOD, value = Dist.DEDICATED_SERVER)
public class IcebergServer
@@ -11,9 +10,4 @@ public class IcebergServer
public IcebergServer()
{
}
-
- public void onServerStarting(FMLServerStartingEvent event)
- {
-
- }
}
diff --git a/src/main/java/com/anthonyhilyard/iceberg/Loader.java b/src/main/java/com/anthonyhilyard/iceberg/Loader.java
index 38aa9c1..49e9d9c 100644
--- a/src/main/java/com/anthonyhilyard/iceberg/Loader.java
+++ b/src/main/java/com/anthonyhilyard/iceberg/Loader.java
@@ -2,19 +2,17 @@ package com.anthonyhilyard.iceberg;
import com.anthonyhilyard.iceberg.network.IcebergNetworkProtocol;
-import org.apache.commons.lang3.tuple.Pair;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.eventbus.api.SubscribeEvent;
-import net.minecraftforge.fml.ExtensionPoint;
+import net.minecraftforge.fml.IExtensionPoint;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.fml.loading.FMLEnvironment;
-import net.minecraftforge.fml.network.FMLNetworkConstants;
@Mod(Loader.MODID)
public class Loader
@@ -37,7 +35,7 @@ public class Loader
// Register the network protocol.
IcebergNetworkProtocol.register();
- ModLoadingContext.get().registerExtensionPoint(ExtensionPoint.DISPLAYTEST, () -> Pair.of(() -> FMLNetworkConstants.IGNORESERVERONLY, (a, b) -> true));
+ ModLoadingContext.get().registerExtensionPoint(IExtensionPoint.DisplayTest.class, () -> new IExtensionPoint.DisplayTest(() -> "ANY", (remote, isServer) -> true));
}
@SubscribeEvent
diff --git a/src/main/java/com/anthonyhilyard/iceberg/events/CriterionEvent.java b/src/main/java/com/anthonyhilyard/iceberg/events/CriterionEvent.java
index fe20cec..fed7ec2 100644
--- a/src/main/java/com/anthonyhilyard/iceberg/events/CriterionEvent.java
+++ b/src/main/java/com/anthonyhilyard/iceberg/events/CriterionEvent.java
@@ -2,7 +2,7 @@ package com.anthonyhilyard.iceberg.events;
import net.minecraftforge.event.entity.player.PlayerEvent;
import net.minecraft.advancements.Advancement;
-import net.minecraft.entity.player.PlayerEntity;
+import net.minecraft.world.entity.player.Player;
import net.minecraftforge.common.MinecraftForge;
/**
@@ -19,7 +19,7 @@ public class CriterionEvent extends PlayerEvent
private final Advancement advancement;
private final String criterionKey;
- public CriterionEvent(PlayerEntity player, Advancement advancement, String criterionKey)
+ public CriterionEvent(Player player, Advancement advancement, String criterionKey)
{
super(player);
this.advancement = advancement;
diff --git a/src/main/java/com/anthonyhilyard/iceberg/events/EntityFluidEvent.java b/src/main/java/com/anthonyhilyard/iceberg/events/EntityFluidEvent.java
index aa91fa5..d2abcb2 100644
--- a/src/main/java/com/anthonyhilyard/iceberg/events/EntityFluidEvent.java
+++ b/src/main/java/com/anthonyhilyard/iceberg/events/EntityFluidEvent.java
@@ -1,7 +1,7 @@
package com.anthonyhilyard.iceberg.events;
-import net.minecraft.entity.Entity;
-import net.minecraft.fluid.Fluid;
+import net.minecraft.world.entity.Entity;
+import net.minecraft.world.level.material.Fluid;
import net.minecraftforge.event.entity.EntityEvent;
public class EntityFluidEvent extends EntityEvent
diff --git a/src/main/java/com/anthonyhilyard/iceberg/events/NewItemPickupEvent.java b/src/main/java/com/anthonyhilyard/iceberg/events/NewItemPickupEvent.java
index a758769..48f2faf 100644
--- a/src/main/java/com/anthonyhilyard/iceberg/events/NewItemPickupEvent.java
+++ b/src/main/java/com/anthonyhilyard/iceberg/events/NewItemPickupEvent.java
@@ -5,8 +5,8 @@ import net.minecraftforge.event.entity.player.PlayerEvent;
import java.util.UUID;
import net.minecraft.client.Minecraft;
-import net.minecraft.entity.player.PlayerEntity;
-import net.minecraft.item.ItemStack;
+import net.minecraft.world.entity.player.Player;
+import net.minecraft.world.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
/**
@@ -22,7 +22,7 @@ public class NewItemPickupEvent extends PlayerEvent
{
private final ItemStack itemStack;
- public NewItemPickupEvent(PlayerEntity player, ItemStack itemStack)
+ public NewItemPickupEvent(Player player, ItemStack itemStack)
{
super(player);
this.itemStack = itemStack;
diff --git a/src/main/java/com/anthonyhilyard/iceberg/events/RenderTooltipExtEvent.java b/src/main/java/com/anthonyhilyard/iceberg/events/RenderTooltipExtEvent.java
index dfb1364..3ca2d37 100644
--- a/src/main/java/com/anthonyhilyard/iceberg/events/RenderTooltipExtEvent.java
+++ b/src/main/java/com/anthonyhilyard/iceberg/events/RenderTooltipExtEvent.java
@@ -2,11 +2,11 @@ package com.anthonyhilyard.iceberg.events;
import java.util.List;
-import com.mojang.blaze3d.matrix.MatrixStack;
+import com.mojang.blaze3d.vertex.PoseStack;
-import net.minecraft.client.gui.FontRenderer;
-import net.minecraft.item.ItemStack;
-import net.minecraft.util.text.ITextProperties;
+import net.minecraft.client.gui.Font;
+import net.minecraft.world.item.ItemStack;
+import net.minecraft.network.chat.FormattedText;
import net.minecraftforge.client.event.RenderTooltipEvent;
public class RenderTooltipExtEvent
@@ -14,31 +14,37 @@ public class RenderTooltipExtEvent
public static class Pre extends RenderTooltipEvent.Pre
{
private boolean comparisonTooltip = false;
- public Pre(ItemStack stack, List<? extends ITextProperties> lines, MatrixStack matrixStack, int x, int y, int screenWidth, int screenHeight, int maxWidth, FontRenderer font, boolean comparison)
+
+ @SuppressWarnings("removal")
+ public Pre(ItemStack stack, List<? extends FormattedText> lines, PoseStack PoseStack, int x, int y, int screenWidth, int screenHeight, int maxWidth, Font font, boolean comparison)
{
- super(stack, lines, matrixStack, x, y, screenWidth, screenHeight, maxWidth, font);
+ super(stack, lines, PoseStack, x, y, screenWidth, screenHeight, maxWidth, font);
comparisonTooltip = comparison;
}
public boolean isComparison() { return comparisonTooltip; }
}
+ @SuppressWarnings("removal")
public static class PostBackground extends RenderTooltipEvent.PostBackground
{
private boolean comparisonTooltip = false;
- public PostBackground(ItemStack stack, List<? extends ITextProperties> textLines, MatrixStack matrixStack, int x, int y, FontRenderer font, int width, int height, boolean comparison)
+
+ public PostBackground(ItemStack stack, List<? extends FormattedText> textLines, PoseStack PoseStack, int x, int y, Font font, int width, int height, boolean comparison)
{
- super(stack, textLines, matrixStack, x, y, font, width, height);
+ super(stack, textLines, PoseStack, x, y, font, width, height);
comparisonTooltip = comparison;
}
public boolean isComparison() { return comparisonTooltip; }
}
+ @SuppressWarnings("removal")
public static class PostText extends RenderTooltipEvent.PostText
{
private boolean comparisonTooltip = false;
- public PostText(ItemStack stack, List<? extends ITextProperties> textLines, MatrixStack matrixStack, int x, int y, FontRenderer font, int width, int height, boolean comparison)
+
+ public PostText(ItemStack stack, List<? extends FormattedText> textLines, PoseStack PoseStack, int x, int y, Font font, int width, int height, boolean comparison)
{
- super(stack, textLines, matrixStack, x, y, font, width, height);
+ super(stack, textLines, PoseStack, x, y, font, width, height);
comparisonTooltip = comparison;
}
public boolean isComparison() { return comparisonTooltip; }
@@ -47,9 +53,11 @@ public class RenderTooltipExtEvent
public static class Color extends RenderTooltipEvent.Color
{
private boolean comparisonTooltip = false;
- public Color(ItemStack stack, List<? extends ITextProperties> textLines, MatrixStack matrixStack, int x, int y, FontRenderer font, int background, int borderStart, int borderEnd, boolean comparison)
+
+ @SuppressWarnings("removal")
+ public Color(ItemStack stack, List<? extends FormattedText> textLines, PoseStack PoseStack, int x, int y, Font font, int background, int borderStart, int borderEnd, boolean comparison)
{
- super(stack, textLines, matrixStack, x, y, font, background, borderStart, borderEnd);
+ super(stack, textLines, PoseStack, x, y, font, background, borderStart, borderEnd);
comparisonTooltip = comparison;
}
public boolean isComparison() { return comparisonTooltip; }
diff --git a/src/main/java/com/anthonyhilyard/iceberg/mixin/EntityMixin.java b/src/main/java/com/anthonyhilyard/iceberg/mixin/EntityMixin.java
index f4ca091..ba3a69e 100644
--- a/src/main/java/com/anthonyhilyard/iceberg/mixin/EntityMixin.java
+++ b/src/main/java/com/anthonyhilyard/iceberg/mixin/EntityMixin.java
@@ -11,9 +11,9 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.At.Shift;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
-import net.minecraft.entity.Entity;
-import net.minecraft.fluid.Fluid;
-import net.minecraft.tags.ITag;
+import net.minecraft.world.entity.Entity;
+import net.minecraft.world.level.material.Fluid;
+import net.minecraft.tags.Tag;
import net.minecraftforge.common.MinecraftForge;
@Mixin(Entity.class)
@@ -22,7 +22,7 @@ public class EntityMixin extends net.minecraftforge.common.capabilities.Capabili
private Fluid previousFluidOnEyes = null;
@Shadow
- protected ITag<Fluid> fluidOnEyes;
+ protected Tag<Fluid> fluidOnEyes;
protected EntityMixin(Class<Entity> baseClass) { super(baseClass); }
@@ -45,7 +45,7 @@ public class EntityMixin extends net.minecraftforge.common.capabilities.Capabili
}
@Inject(method = "updateFluidOnEyes",
- at = @At(value = "FIELD", target = "Lnet/minecraft/entity/Entity;fluidOnEyes:Lnet/minecraft/tags/ITag;", ordinal = 1, shift = Shift.AFTER))
+ at = @At(value = "FIELD", target = "Lnet/minecraft/world/entity/Entity;fluidOnEyes:Lnet/minecraft/tags/Tag;", ordinal = 1, shift = Shift.AFTER))
public void onUpdateFluidOnEyeAssign(CallbackInfo callbackInfo)
{
Fluid currentFluid = null;
diff --git a/src/main/java/com/anthonyhilyard/iceberg/mixin/ForgeEventFactoryMixin.java b/src/main/java/com/anthonyhilyard/iceberg/mixin/ForgeEventFactoryMixin.java
index a530465..2dbc247 100644
--- a/src/main/java/com/anthonyhilyard/iceberg/mixin/ForgeEventFactoryMixin.java
+++ b/src/main/java/com/anthonyhilyard/iceberg/mixin/ForgeEventFactoryMixin.java
@@ -3,12 +3,12 @@ package com.anthonyhilyard.iceberg.mixin;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
-import net.minecraft.entity.item.ItemEntity;
-import net.minecraft.entity.player.PlayerEntity;
-import net.minecraft.entity.player.ServerPlayerEntity;
+import net.minecraft.world.entity.item.ItemEntity;
+import net.minecraft.world.entity.player.Player;
+import net.minecraft.server.level.ServerPlayer;
import net.minecraftforge.event.ForgeEventFactory;
import net.minecraftforge.fml.loading.FMLEnvironment;
-import net.minecraftforge.fml.network.PacketDistributor;
+import net.minecraftforge.fmllegacy.network.PacketDistributor;
import com.anthonyhilyard.iceberg.network.IcebergNetworkProtocol;
import com.anthonyhilyard.iceberg.network.NewItemPickupEventPacket;
@@ -19,13 +19,13 @@ import org.spongepowered.asm.mixin.injection.At;
@Mixin(ForgeEventFactory.class)
public class ForgeEventFactoryMixin
{
- @Inject(method = { "onItemPickup(Lnet/minecraft/entity/item/ItemEntity;Lnet/minecraft/entity/player/PlayerEntity;)I" },
+ @Inject(method = { "onItemPickup(Lnet/minecraft/world/entity/item/ItemEntity;Lnet/minecraft/world/entity/player/Player;)I" },
at = { @At("HEAD") }, remap = false)
- private static void onItemPickup(ItemEntity entityItem, PlayerEntity player, CallbackInfoReturnable<Integer> info)
+ private static void onItemPickup(ItemEntity entityItem, Player player, CallbackInfoReturnable<Integer> info)
{
- if (player instanceof ServerPlayerEntity && FMLEnvironment.dist.isDedicatedServer())
+ if (player instanceof ServerPlayer && FMLEnvironment.dist.isDedicatedServer())
{
- IcebergNetworkProtocol.CHANNEL.send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity)player), new NewItemPickupEventPacket(player.getUUID(), entityItem.getItem()));
+ IcebergNetworkProtocol.CHANNEL.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer)player), new NewItemPickupEventPacket(player.getUUID(), entityItem.getItem()));
}
}
}
diff --git a/src/main/java/com/anthonyhilyard/iceberg/mixin/PlayerAdvancementsMixin.java b/src/main/java/com/anthonyhilyard/iceberg/mixin/PlayerAdvancementsMixin.java
index b27b219..ad52b94 100644
--- a/src/main/java/com/anthonyhilyard/iceberg/mixin/PlayerAdvancementsMixin.java
+++ b/src/main/java/com/anthonyhilyard/iceberg/mixin/PlayerAdvancementsMixin.java
@@ -10,15 +10,15 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
import net.minecraft.advancements.Advancement;
-import net.minecraft.advancements.PlayerAdvancements;
-import net.minecraft.entity.player.ServerPlayerEntity;
+import net.minecraft.server.PlayerAdvancements;
+import net.minecraft.server.level.ServerPlayer;
import net.minecraftforge.common.MinecraftForge;
@Mixin(PlayerAdvancements.class)
public class PlayerAdvancementsMixin
{
@Shadow
- private ServerPlayerEntity player;
+ private ServerPlayer player;
@Inject(method = "award", at = @At(value = "TAIL"), locals = LocalCapture.CAPTURE_FAILEXCEPTION)
public void onAward(Advancement advancement, String criterionKey, CallbackInfoReturnable<Boolean> callbackInfo, boolean success)
diff --git a/src/main/java/com/anthonyhilyard/iceberg/network/IcebergNetworkProtocol.java b/src/main/java/com/anthonyhilyard/iceberg/network/IcebergNetworkProtocol.java
index d0dd1c8..4b5db06 100644
--- a/src/main/java/com/anthonyhilyard/iceberg/network/IcebergNetworkProtocol.java
+++ b/src/main/java/com/anthonyhilyard/iceberg/network/IcebergNetworkProtocol.java
@@ -2,9 +2,9 @@ package com.anthonyhilyard.iceberg.network;
import com.anthonyhilyard.iceberg.Loader;
-import net.minecraft.util.ResourceLocation;
-import net.minecraftforge.fml.network.NetworkRegistry;
-import net.minecraftforge.fml.network.simple.SimpleChannel;
+import net.minecraft.resources.ResourceLocation;
+import net.minecraftforge.fmllegacy.network.NetworkRegistry;
+import net.minecraftforge.fmllegacy.network.simple.SimpleChannel;
public class IcebergNetworkProtocol
{
diff --git a/src/main/java/com/anthonyhilyard/iceberg/network/NewItemPickupEventPacket.java b/src/main/java/com/anthonyhilyard/iceberg/network/NewItemPickupEventPacket.java
index 23df08b..b99a36d 100644
--- a/src/main/java/com/anthonyhilyard/iceberg/network/NewItemPickupEventPacket.java
+++ b/src/main/java/com/anthonyhilyard/iceberg/network/NewItemPickupEventPacket.java
@@ -1,9 +1,9 @@
package com.anthonyhilyard.iceberg.network;
-import net.minecraft.item.ItemStack;
-import net.minecraft.network.PacketBuffer;
+import net.minecraft.world.item.ItemStack;
+import net.minecraft.network.FriendlyByteBuf;
import net.minecraftforge.common.MinecraftForge;
-import net.minecraftforge.fml.network.NetworkEvent;
+import net.minecraftforge.fmllegacy.network.NetworkEvent;
import java.util.UUID;
import java.util.function.Supplier;
@@ -22,13 +22,13 @@ public final class NewItemPickupEventPacket
this.item = item;
}
- public static void encode(final NewItemPickupEventPacket msg, final PacketBuffer packetBuffer)
+ public static void encode(final NewItemPickupEventPacket msg, final FriendlyByteBuf packetBuffer)
{
packetBuffer.writeUUID(msg.playerUUID);
packetBuffer.writeItem(msg.item);
}
- public static NewItemPickupEventPacket decode(final PacketBuffer packetBuffer)
+ public static NewItemPickupEventPacket decode(final FriendlyByteBuf packetBuffer)
{
return new NewItemPickupEventPacket(packetBuffer.readUUID(), packetBuffer.readItem());
}
diff --git a/src/main/java/com/anthonyhilyard/iceberg/registry/AutoRegistry.java b/src/main/java/com/anthonyhilyard/iceberg/registry/AutoRegistry.java
index a9b983e..59803ae 100644
--- a/src/main/java/com/anthonyhilyard/iceberg/registry/AutoRegistry.java
+++ b/src/main/java/com/anthonyhilyard/iceberg/registry/AutoRegistry.java
@@ -6,14 +6,13 @@ import java.util.Map;
import java.util.function.Consumer;
import java.util.function.Supplier;
-import net.minecraft.entity.Entity;
-import net.minecraft.entity.EntityType;
-import net.minecraft.entity.LivingEntity;
-import net.minecraft.entity.ai.attributes.AttributeModifierMap;
-import net.minecraft.util.ResourceLocation;
-import net.minecraft.util.SoundEvent;
+import net.minecraft.world.entity.Entity;
+import net.minecraft.world.entity.EntityType;
+import net.minecraft.world.entity.LivingEntity;
+import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
+import net.minecraft.resources.ResourceLocation;
+import net.minecraft.sounds.SoundEvent;
import net.minecraftforge.event.RegistryEvent;
-import net.minecraftforge.fml.client.registry.IRenderFactory;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.IForgeRegistry;
@@ -21,7 +20,7 @@ import net.minecraftforge.registries.IForgeRegistryEntry;
import net.minecraftforge.event.entity.EntityAttributeCreationEvent;
/**
- * Extend this class to have all registerable fields be automatically registered in Forge. Easy.
+ * Extend this class to have all registerable fields be automatically registered in Forge. Easy. (Just no renderers.)
*/
public abstract class AutoRegistry
{
@@ -29,7 +28,7 @@ public abstract class AutoRegistry
private static boolean entityCreationRegistered = false;
- private static Map<EntityType<?>, Supplier<AttributeModifierMap.MutableAttribute>> entityAttributes = new HashMap<>();
+ private static Map<EntityType<?>, Supplier<AttributeSupplier.Builder>> entityAttributes = new HashMap<>();
private static Map<String, EntityType<? extends Entity>> registeredEntityTypes = new HashMap<>();
@@ -108,23 +107,11 @@ public abstract class AutoRegistry
protected static <T extends Entity> EntityType<T> registerEntity(String name, EntityType.Builder<T> builder)
{
- return registerEntity(name, builder, (Supplier<AttributeModifierMap.MutableAttribute>)null);
+ return registerEntity(name, builder, (Supplier<AttributeSupplier.Builder>)null);
}
- protected static <T extends Entity> EntityType<T> registerEntity(String name, EntityType.Builder<T> builder, Supplier<AttributeModifierMap.MutableAttribute> attributes)
- {
- return registerEntity(name, builder, null, attributes);
- }
-
- @Deprecated
- protected static <T extends Entity> EntityType<T> registerEntity(String name, EntityType.Builder<T> builder, IRenderFactory<? super T> renderFactory)
- {
- return registerEntity(name, builder, renderFactory, null);
- }
-
- @Deprecated
@SuppressWarnings("unchecked")
- protected static <T extends Entity> EntityType<T> registerEntity(String name, EntityType.Builder<T> builder, IRenderFactory<? super T> renderFactory, Supplier<AttributeModifierMap.MutableAttribute> attributes)
+ protected static <T extends Entity> EntityType<T> registerEntity(String name, EntityType.Builder<T> builder, Supplier<AttributeSupplier.Builder> attributes)
{
if (MODID == null)
{
diff --git a/src/main/java/com/anthonyhilyard/iceberg/registry/RendererRegistrar.java b/src/main/java/com/anthonyhilyard/iceberg/registry/RendererRegistrar.java
index e77fd1f..1b0a053 100644
--- a/src/main/java/com/anthonyhilyard/iceberg/registry/RendererRegistrar.java
+++ b/src/main/java/com/anthonyhilyard/iceberg/registry/RendererRegistrar.java
@@ -1,21 +1,36 @@
package com.anthonyhilyard.iceberg.registry;
-import net.minecraft.entity.Entity;
-import net.minecraftforge.fml.client.registry.IRenderFactory;
-import net.minecraftforge.fml.client.registry.RenderingRegistry;
+import java.util.HashMap;
+import java.util.Map;
+
+import net.minecraft.world.entity.Entity;
+import net.minecraft.world.entity.EntityType;
+import net.minecraft.client.renderer.entity.EntityRendererProvider;
+import net.minecraftforge.client.event.EntityRenderersEvent;
public abstract class RendererRegistrar
{
- protected static <T extends Entity> void registerRenderer(String name, IRenderFactory<? super T> renderFactory)
+ private static Map<EntityType<? extends Entity>, EntityRendererProvider<?>> entityRenderers = new HashMap<>();
+
+ protected static <T extends Entity> void registerRenderer(String name, EntityRendererProvider<T> rendererProvider)
{
if (AutoRegistry.isEntityTypeRegistered(name))
{
- // Register the rendering handler.
- RenderingRegistry.registerEntityRenderingHandler(AutoRegistry.<T>getEntityType(name), renderFactory);
+ // Store this renderer provider.
+ entityRenderers.put(AutoRegistry.getEntityType(name), rendererProvider);
}
else
{
throw new RuntimeException("Tried to register a renderer for an unregistered entity type! Make sure you register renderers after entities.");
}
}
+
+ @SuppressWarnings({"unchecked", "unused"})
+ private <T extends Entity> void onEntityCreation(EntityRenderersEvent.RegisterRenderers event)
+ {
+ for (EntityType<? extends Entity> entityType : entityRenderers.keySet())
+ {
+ event.registerEntityRenderer((EntityType<T>)entityType, (EntityRendererProvider<T>)entityRenderers.get(entityType));
+ }
+ }
}
diff --git a/src/main/java/com/anthonyhilyard/iceberg/renderer/CustomItemRenderer.java b/src/main/java/com/anthonyhilyard/iceberg/renderer/CustomItemRenderer.java
index 29ce7d0..e86d824 100644
--- a/src/main/java/com/anthonyhilyard/iceberg/renderer/CustomItemRenderer.java
+++ b/src/main/java/com/anthonyhilyard/iceberg/renderer/CustomItemRenderer.java
@@ -1,31 +1,36 @@
package com.anthonyhilyard.iceberg.renderer;
-import com.mojang.blaze3d.matrix.MatrixStack;
-import com.mojang.blaze3d.platform.GlStateManager.DestFactor;
-import com.mojang.blaze3d.platform.GlStateManager.SourceFactor;
+import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.systems.RenderSystem;
+import com.mojang.blaze3d.pipeline.MainTarget;
+import com.mojang.blaze3d.pipeline.RenderTarget;
+import com.mojang.blaze3d.platform.Lighting;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.lwjgl.opengl.GL11;
import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.AbstractGui;
-import net.minecraft.client.renderer.IRenderTypeBuffer;
-import net.minecraft.client.renderer.ItemRenderer;
-import net.minecraft.client.renderer.RenderHelper;
-import net.minecraft.client.renderer.color.ItemColors;
-import net.minecraft.client.renderer.model.IBakedModel;
-import net.minecraft.client.renderer.model.ItemCameraTransforms;
-import net.minecraft.client.renderer.model.ModelManager;
-import net.minecraft.client.renderer.texture.AtlasTexture;
+import net.minecraft.client.renderer.entity.ItemRenderer;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.client.renderer.texture.TextureManager;
-import net.minecraft.client.shader.Framebuffer;
-import net.minecraft.item.ItemStack;
+
+import com.mojang.blaze3d.platform.GlStateManager.SourceFactor;
+import com.mojang.blaze3d.platform.GlStateManager.DestFactor;
+import com.mojang.math.Matrix4f;
+
+import net.minecraft.client.color.item.ItemColors;
+import net.minecraft.client.gui.GuiComponent;
+import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer;
+import net.minecraft.client.renderer.MultiBufferSource;
+import net.minecraft.client.renderer.block.model.ItemTransforms;
+import net.minecraft.client.resources.model.BakedModel;
+import net.minecraft.client.resources.model.ModelManager;
+import net.minecraft.world.inventory.InventoryMenu;
+import net.minecraft.world.item.ItemStack;
/**
- * An extended ItemRenderer that allows items to be rendered to framebuffer before drawing to screen.
+ * An extended ItemRenderer that allows items to be rendered to RenderTarget before drawing to screen.
* This allows alpha values to be supported properly by all item types, even semi-transparent items.
*/
public class CustomItemRenderer extends ItemRenderer
@@ -33,76 +38,64 @@ public class CustomItemRenderer extends ItemRenderer
@SuppressWarnings("unused")
private static final Logger LOGGER = LogManager.getLogger();
- private static Framebuffer iconFrameBuffer = null;
+ private static RenderTarget iconFrameBuffer = null;
private Minecraft mc;
- public CustomItemRenderer(TextureManager textureManagerIn, ModelManager modelManagerIn, ItemColors itemColorsIn, Minecraft mcIn)
+ public CustomItemRenderer(TextureManager textureManagerIn, ModelManager modelManagerIn, ItemColors itemColorsIn, BlockEntityWithoutLevelRenderer blockEntityRendererIn, Minecraft mcIn)
{
- super(textureManagerIn, modelManagerIn, itemColorsIn);
+ super(textureManagerIn, modelManagerIn, itemColorsIn, blockEntityRendererIn);
mc = mcIn;
// Initialize the icon framebuffer if needed.
if (iconFrameBuffer == null)
{
// Use 96 x 96 pixels for the icon frame buffer so at 1.5 scale we get 4x resolution (for smooth icons on larger gui scales).
- iconFrameBuffer = new Framebuffer(96, 96, true, Minecraft.ON_OSX);
- iconFrameBuffer.setClearColor(0.0F, 0.0F, 0.0F, 0.0F);
+ iconFrameBuffer = new MainTarget(96, 96);
+ iconFrameBuffer.setClearColor(0.0f, 0.0f, 0.0f, 0.0f);
+ iconFrameBuffer.clear(Minecraft.ON_OSX);
}
}
- @SuppressWarnings("deprecation")
- public void renderItemModelIntoGUIWithAlpha(ItemStack stack, int x, int y, float alpha)
+ protected void renderItemModelIntoGUIWithAlpha(ItemStack stack, int x, int y, float alpha)
{
- IBakedModel bakedModel = mc.getItemRenderer().getModel(stack, null, null);
- Framebuffer lastFrameBuffer = mc.getMainRenderTarget();
+ BakedModel bakedModel = mc.getItemRenderer().getModel(stack, null, null, 0);
+ RenderTarget lastFrameBuffer = mc.getMainRenderTarget();
// Bind the icon framebuffer so we can render to texture.
iconFrameBuffer.clear(Minecraft.ON_OSX);
iconFrameBuffer.bindWrite(true);
-
+
RenderSystem.clear(GL11.GL_DEPTH_BUFFER_BIT, Minecraft.ON_OSX);
- RenderSystem.matrixMode(GL11.GL_PROJECTION);
- RenderSystem.pushMatrix();
- RenderSystem.loadIdentity();
- RenderSystem.ortho(0.0D, iconFrameBuffer.width, iconFrameBuffer.height, 0.0D, 1000.0D, 3000.0D);
- RenderSystem.matrixMode(GL11.GL_MODELVIEW);
- RenderSystem.pushMatrix();
- RenderSystem.loadIdentity();
- RenderSystem.translatef(0.0F, 0.0F, -2000.0F);
- RenderHelper.setupFor3DItems();
-
- mc.getTextureManager().bind(AtlasTexture.LOCATION_BLOCKS);
- mc.getTextureManager().getTexture(AtlasTexture.LOCATION_BLOCKS).setFilter(false, false);
- RenderSystem.enableRescaleNormal();
- RenderSystem.enableAlphaTest();
- RenderSystem.defaultAlphaFunc();
+ RenderSystem.backupProjectionMatrix();
+ RenderSystem.setProjectionMatrix(Matrix4f.orthographic(0.0f, iconFrameBuffer.width, iconFrameBuffer.height, 0.0f, 1000.0f, 3000.0f));
+
+ Lighting.setupFor3DItems();
+
+ mc.getTextureManager().getTexture(InventoryMenu.BLOCK_ATLAS).setFilter(false, false);
+ RenderSystem.setShaderTexture(0, InventoryMenu.BLOCK_ATLAS);
RenderSystem.enableBlend();
RenderSystem.blendFuncSeparate(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA, SourceFactor.ONE, DestFactor.ONE_MINUS_SRC_ALPHA);
- RenderSystem.color4f(1.0f, 1.0f, 1.0f, 1.0f);
- RenderSystem.translatef(48.0f, 48.0f, 150.0f + this.blitOffset);
- RenderSystem.scalef(1.0f, -1.0f, 1.0f);
- RenderSystem.scalef(96.0f, 96.0f, 96.0f);
- MatrixStack matrixStack = new MatrixStack();
- IRenderTypeBuffer.Impl renderBuffer = Minecraft.getInstance().renderBuffers().bufferSource();
- boolean isSideLit = !bakedModel.usesBlockLight();
- if (isSideLit)
- {
- RenderHelper.setupForFlatItems();
- }
+ RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
+
+ PoseStack modelViewStack = RenderSystem.getModelViewStack();
+ modelViewStack.pushPose();
+ modelViewStack.setIdentity();
+ modelViewStack.translate(48.0f, 48.0f, -2000.0f);
+ modelViewStack.scale(96.0F, 96.0F, 96.0F);
+ RenderSystem.applyModelViewMatrix();
+ PoseStack poseStack = new PoseStack();
+ MultiBufferSource.BufferSource multibuffersource$buffersource = Minecraft.getInstance().renderBuffers().bufferSource();
+ boolean flag = !bakedModel.usesBlockLight();
+ if (flag) { Lighting.setupForFlatItems(); }
- render(stack, ItemCameraTransforms.TransformType.GUI, false, matrixStack, renderBuffer, 0xF000F0, OverlayTexture.NO_OVERLAY, bakedModel);
- renderBuffer.endBatch();
+ render(stack, ItemTransforms.TransformType.GUI, false, poseStack, multibuffersource$buffersource, 0xF000F0, OverlayTexture.NO_OVERLAY, bakedModel);
+ multibuffersource$buffersource.endBatch();
RenderSystem.enableDepthTest();
- if (isSideLit)
- {
- RenderHelper.setupFor3DItems();
- }
+ if (flag) { Lighting.setupFor3DItems(); }
- RenderSystem.disableRescaleNormal();
- RenderSystem.popMatrix();
- RenderSystem.matrixMode(GL11.GL_PROJECTION);
- RenderSystem.popMatrix();
- RenderSystem.matrixMode(GL11.GL_MODELVIEW);
+ modelViewStack.popPose();
+ RenderSystem.applyModelViewMatrix();
+ RenderSystem.restoreProjectionMatrix();
// Rebind the previous framebuffer, if there was one.
if (lastFrameBuffer != null)
@@ -110,20 +103,25 @@ public class CustomItemRenderer extends ItemRenderer
lastFrameBuffer.bindWrite(true);
// Blit from the texture we just rendered to, respecting the alpha value given.
- iconFrameBuffer.bindRead();
- RenderSystem.enableAlphaTest();
RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc();
- RenderSystem.defaultAlphaFunc();
RenderSystem.disableCull();
- RenderSystem.color4f(1.0f, 1.0f, 1.0f, alpha);
- RenderSystem.scalef(1.0f, -1.0f, 1.0f);
+ RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, alpha);
+ modelViewStack.pushPose();
+ modelViewStack.scale(1.0f, -1.0f, 1.0f);
+ modelViewStack.translate(0.0f, 0.0f, 50.0f + this.blitOffset);
+ RenderSystem.applyModelViewMatrix();
- AbstractGui.blit(new MatrixStack(), x, y - 18, 16, 16, 0, 0, iconFrameBuffer.width, iconFrameBuffer.height, iconFrameBuffer.width, iconFrameBuffer.height);
+ RenderSystem.setShaderTexture(0, iconFrameBuffer.getColorTextureId());
+
+ GuiComponent.blit(new PoseStack(), x, y - 18, 16, 16, 0, 0, iconFrameBuffer.width, iconFrameBuffer.height, iconFrameBuffer.width, iconFrameBuffer.height);
+ modelViewStack.popPose();
+ RenderSystem.applyModelViewMatrix();
+ iconFrameBuffer.unbindRead();
}
else
{
iconFrameBuffer.unbindWrite();
}
- }
+ }
}
diff --git a/src/main/java/com/anthonyhilyard/iceberg/util/Easing.java b/src/main/java/com/anthonyhilyard/iceberg/util/Easing.java
index 4146900..bc4e39b 100644
--- a/src/main/java/com/anthonyhilyard/iceberg/util/Easing.java
+++ b/src/main/java/com/anthonyhilyard/iceberg/util/Easing.java
@@ -1,6 +1,6 @@
package com.anthonyhilyard.iceberg.util;
-import net.minecraft.util.text.Color;
+import net.minecraft.network.chat.TextColor;
/**
* Helper functions for smooth easing/interpolation. If you need linear, use net.minecraft.util.math.MathHelper.lerp instead.
@@ -32,14 +32,14 @@ public final class Easing
return Ease(a, b, t, type, EasingDirection.InOut);
}
- public static Color Ease(Color a, Color b, float t, EasingType type)
+ public static TextColor Ease(TextColor a, TextColor b, float t, EasingType type)
{
- // Helper function to ease between colors.
+ // Helper function to ease between TextColors.
// Ease each component individually.
int aV = a.getValue(), bV = b.getValue();
int aA = (aV >> 24) & 0xFF, aR = (aV >> 16) & 0xFF, aG = (aV >> 8) & 0xFF, aB = (aV >> 0) & 0xFF,
bA = (bV >> 24) & 0xFF, bR = (bV >> 16) & 0xFF, bG = (bV >> 8) & 0xFF, bB = (bV >> 0) & 0xFF;
- return Color.fromRgb((int)Ease(aA, bA, t, type) << 24 |
+ return TextColor.fromRgb((int)Ease(aA, bA, t, type) << 24 |
(int)Ease(aR, bR, t, type) << 16 |
(int)Ease(aG, bG, t, type) << 8 |
(int)Ease(aB, bB, t, type) << 0);
diff --git a/src/main/java/com/anthonyhilyard/iceberg/util/GuiHelper.java b/src/main/java/com/anthonyhilyard/iceberg/util/GuiHelper.java
index 4325ebe..b87c057 100644
--- a/src/main/java/com/anthonyhilyard/iceberg/util/GuiHelper.java
+++ b/src/main/java/com/anthonyhilyard/iceberg/util/GuiHelper.java
@@ -1,15 +1,15 @@
package com.anthonyhilyard.iceberg.util;
-import org.lwjgl.opengl.GL11;
import com.mojang.blaze3d.systems.RenderSystem;
-import net.minecraft.client.renderer.BufferBuilder;
-import net.minecraft.client.renderer.Tessellator;
-import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
-import net.minecraft.util.math.vector.Matrix4f;
+import net.minecraft.client.renderer.GameRenderer;
+import com.mojang.blaze3d.vertex.Tesselator;
+import com.mojang.blaze3d.vertex.BufferBuilder;
+import com.mojang.blaze3d.vertex.DefaultVertexFormat;
+import com.mojang.blaze3d.vertex.VertexFormat;
+import com.mojang.math.Matrix4f;
public class GuiHelper
{
- @SuppressWarnings("deprecation")
public static void drawGradientRectHorizontal(Matrix4f mat, int zLevel, int left, int top, int right, int bottom, int startColor, int endColor)
{
float startAlpha = (float)(startColor >> 24 & 255) / 255.0F;
@@ -25,18 +25,17 @@ public class GuiHelper
RenderSystem.disableTexture();
RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc();
- RenderSystem.shadeModel(GL11.GL_SMOOTH);
+ RenderSystem.setShader(GameRenderer::getPositionColorShader);
- Tessellator tessellator = Tessellator.getInstance();
+ Tesselator tessellator = Tesselator.getInstance();
BufferBuilder buffer = tessellator.getBuilder();
- buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
+ buffer.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR);
buffer.vertex(mat, right, top, zLevel).color( endRed, endGreen, endBlue, endAlpha).endVertex();
buffer.vertex(mat, left, top, zLevel).color(startRed, startGreen, startBlue, startAlpha).endVertex();
buffer.vertex(mat, left, bottom, zLevel).color(startRed, startGreen, startBlue, startAlpha).endVertex();
buffer.vertex(mat, right, bottom, zLevel).color( endRed, endGreen, endBlue, endAlpha).endVertex();
tessellator.end();
- RenderSystem.shadeModel(GL11.GL_FLAT);
RenderSystem.disableBlend();
RenderSystem.enableTexture();
}
diff --git a/src/main/java/com/anthonyhilyard/iceberg/util/ItemColor.java b/src/main/java/com/anthonyhilyard/iceberg/util/ItemColor.java
index a4625aa..26cdc14 100644
--- a/src/main/java/com/anthonyhilyard/iceberg/util/ItemColor.java
+++ b/src/main/java/com/anthonyhilyard/iceberg/util/ItemColor.java
@@ -1,18 +1,18 @@
package com.anthonyhilyard.iceberg.util;
-import net.minecraft.item.ItemStack;
-import net.minecraft.util.text.Color;
+import net.minecraft.world.item.ItemStack;
+import net.minecraft.network.chat.TextColor;
public class ItemColor
{
- public static Color getColorForItem(ItemStack item, Color defaultColor)
+ public static TextColor getColorForItem(ItemStack item, TextColor defaultColor)
{
- Color result = null;
+ TextColor result = null;
- // Color based on rarity value.
+ // TextColor based on rarity value.
result = item.getDisplayName().getStyle().getColor();
- // Some mods override the getName() method of the Item class, so grab that color if it's there.
+ // Some mods override the getName() method of the Item class, so grab that TextColor if it's there.
if (item.getItem() != null &&
item.getItem().getName(item) != null &&
item.getItem().getName(item).getStyle() != null &&
@@ -21,13 +21,13 @@ public class ItemColor
result = item.getItem().getName(item).getStyle().getColor();
}
- // Finally, if the item has a special hover name color (Stored in NBT), use that.
+ // Finally, if the item has a special hover name TextColor (Stored in NBT), use that.
if (!item.getHoverName().getStyle().isEmpty() && item.getHoverName().getStyle().getColor() != null)
{
result = item.getHoverName().getStyle().getColor();
}
- // Fallback to the default color if we somehow haven't found a single valid color.
+ // Fallback to the default TextColor if we somehow haven't found a single valid TextColor.
if (result == null)
{
result = defaultColor;
diff --git a/src/main/java/com/anthonyhilyard/iceberg/util/Tooltips.java b/src/main/java/com/anthonyhilyard/iceberg/util/Tooltips.java
index d111ae5..fe24e44 100644
--- a/src/main/java/com/anthonyhilyard/iceberg/util/Tooltips.java
+++ b/src/main/java/com/anthonyhilyard/iceberg/util/Tooltips.java
@@ -6,21 +6,23 @@ import java.util.List;
import javax.annotation.Nonnull;
import com.anthonyhilyard.iceberg.events.RenderTooltipExtEvent;
-import com.mojang.blaze3d.matrix.MatrixStack;
+import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.systems.RenderSystem;
-import net.minecraft.client.gui.FontRenderer;
-import net.minecraft.client.renderer.IRenderTypeBuffer;
-import net.minecraft.client.renderer.Rectangle2d;
-import net.minecraft.client.renderer.Tessellator;
-import net.minecraft.item.ItemStack;
-import net.minecraft.util.math.vector.Matrix4f;
-import net.minecraft.util.text.ITextProperties;
-import net.minecraft.util.text.LanguageMap;
-import net.minecraft.util.text.Style;
+import net.minecraft.client.gui.Font;
+import net.minecraft.client.renderer.MultiBufferSource;
+import net.minecraft.client.renderer.Rect2i;
+import net.minecraft.client.renderer.MultiBufferSource.BufferSource;
+
+import com.mojang.blaze3d.vertex.Tesselator;
+import net.minecraft.world.item.ItemStack;
+import com.mojang.math.Matrix4f;
+import net.minecraft.network.chat.FormattedText;
+import net.minecraft.locale.Language;
+import net.minecraft.network.chat.Style;
import net.minecraftforge.client.event.RenderTooltipEvent;
import net.minecraftforge.common.MinecraftForge;
-import net.minecraftforge.fml.client.gui.GuiUtils;
+import net.minecraftforge.fmlclient.gui.GuiUtils;
public class Tooltips
{
@@ -28,10 +30,10 @@ public class Tooltips
{
private int tooltipWidth = 0;
private int titleLines = 1;
- private FontRenderer font;
- private List<? extends ITextProperties> lines = new ArrayList<>();
+ private Font font;
+ private List<? extends FormattedText> lines = new ArrayList<>();
- public TooltipInfo(List<? extends ITextProperties> lines, FontRenderer font)
+ public TooltipInfo(List<? extends FormattedText> lines, Font font)
{
this.lines = lines;
this.font = font;
@@ -39,15 +41,15 @@ public class Tooltips
public int getTooltipWidth() { return tooltipWidth; }
public int getTitleLines() { return titleLines; }
- public FontRenderer getFont() { return font; }
- public List<? extends ITextProperties> getLines() { return lines; }
+ public Font getFont() { return font; }
+ public List<? extends FormattedText> getLines() { return lines; }
- public void setFont(FontRenderer font) { this.font = font; }
+ public void setFont(Font font) { this.font = font; }
public int getMaxLineWidth()
{
int textWidth = 0;
- for (ITextProperties textLine : lines)
+ for (FormattedText textLine : lines)
{
int textLineWidth = font.width(textLine);
if (textLineWidth > textWidth)
@@ -61,17 +63,17 @@ public class Tooltips
public void wrap(int maxWidth)
{
tooltipWidth = 0;
- List<ITextProperties> wrappedLines = new ArrayList<>();
+ List<FormattedText> wrappedLines = new ArrayList<>();
for (int i = 0; i < lines.size(); i++)
{
- ITextProperties textLine = lines.get(i);
- List<ITextProperties> wrappedLine = font.getSplitter().splitLines(textLine, maxWidth, Style.EMPTY);
+ FormattedText textLine = lines.get(i);
+ List<FormattedText> wrappedLine = font.getSplitter().splitLines(textLine, maxWidth, Style.EMPTY);
if (i == 0)
{
titleLines = wrappedLine.size();
}
- for (ITextProperties line : wrappedLine)
+ for (FormattedText line : wrappedLine)
{
int lineWidth = font.width(line);
if (lineWidth > tooltipWidth)
@@ -86,16 +88,16 @@ public class Tooltips
}
}
- public static void renderItemTooltip(@Nonnull final ItemStack stack, MatrixStack mStack, TooltipInfo info,
- Rectangle2d rect, int screenWidth, int screenHeight,
+ public static void renderItemTooltip(@Nonnull final ItemStack stack, PoseStack mStack, TooltipInfo info,
+ Rect2i rect, int screenWidth, int screenHeight,
int backgroundColor, int borderColorStart, int borderColorEnd)
{
renderItemTooltip(stack, mStack, info, rect, screenWidth, screenHeight, backgroundColor, borderColorStart, borderColorEnd, false);
}
- @SuppressWarnings("deprecation")
- public static void renderItemTooltip(@Nonnull final ItemStack stack, MatrixStack mStack, TooltipInfo info,
- Rectangle2d rect, int screenWidth, int screenHeight,
+ @SuppressWarnings("removal")
+ public static void renderItemTooltip(@Nonnull final ItemStack stack, PoseStack mStack, TooltipInfo info,
+ Rect2i rect, int screenWidth, int screenHeight,
int backgroundColor, int borderColorStart, int borderColorEnd, boolean comparison)
{
if (info.getLines().isEmpty())
@@ -120,7 +122,6 @@ public class Tooltips
maxTextWidth = event.getMaxWidth();
info.setFont(event.getFontRenderer());
- RenderSystem.disableRescaleNormal();
RenderSystem.disableDepthTest();
int tooltipTextWidth = info.getMaxLineWidth();
@@ -200,17 +201,17 @@ public class Tooltips
MinecraftForge.EVENT_BUS.post(new RenderTooltipEvent.PostBackground(stack, info.getLines(), mStack, tooltipX, tooltipY, info.getFont(), tooltipTextWidth, tooltipHeight));
- IRenderTypeBuffer.Impl renderType = IRenderTypeBuffer.immediate(Tessellator.getInstance().getBuilder());
+ BufferSource renderType = MultiBufferSource.immediate(Tesselator.getInstance().getBuilder());
mStack.translate(0.0D, 0.0D, zLevel);
int tooltipTop = tooltipY;
for (int lineNumber = 0; lineNumber < info.getLines().size(); ++lineNumber)
{
- ITextProperties line = info.getLines().get(lineNumber);
+ FormattedText line = info.getLines().get(lineNumber);
if (line != null)
{
- info.getFont().drawInBatch(LanguageMap.getInstance().getVisualOrder(line), (float)tooltipX, (float)tooltipY, -1, true, mat, renderType, false, 0, 15728880);
+ info.getFont().drawInBatch(Language.getInstance().getVisualOrder(line), (float)tooltipX, (float)tooltipY, -1, true, mat, renderType, false, 0, 15728880);
}
if (lineNumber + 1 == info.getTitleLines())
@@ -227,13 +228,13 @@ public class Tooltips
MinecraftForge.EVENT_BUS.post(new RenderTooltipExtEvent.PostText(stack, info.getLines(), mStack, tooltipX, tooltipTop, info.getFont(), tooltipTextWidth, tooltipHeight, comparison));
RenderSystem.enableDepthTest();
- RenderSystem.enableRescaleNormal();
}
- public static Rectangle2d calculateRect(final ItemStack stack, MatrixStack mStack, List<? extends ITextProperties> textLines, int mouseX, int mouseY,
- int screenWidth, int screenHeight, int maxTextWidth, FontRenderer font)
+ @SuppressWarnings("removal")
+ public static Rect2i calculateRect(final ItemStack stack, PoseStack mStack, List<? extends FormattedText> textLines, int mouseX, int mouseY,
+ int screenWidth, int screenHeight, int maxTextWidth, Font font)
{
- Rectangle2d rect = new Rectangle2d(0, 0, 0, 0);
+ Rect2i rect = new Rect2i(0, 0, 0, 0);
if (textLines == null || textLines.isEmpty() || stack == null)
{
return rect;
@@ -255,7 +256,7 @@ public class Tooltips
int tooltipTextWidth = 0;
- for (ITextProperties textLine : textLines)
+ for (FormattedText textLine : textLines)
{
int textLineWidth = font.width(textLine);
if (textLineWidth > tooltipTextWidth)
@@ -294,17 +295,17 @@ public class Tooltips
if (needsWrap)
{
int wrappedTooltipWidth = 0;
- List<ITextProperties> wrappedTextLines = new ArrayList<>();
+ List<FormattedText> wrappedTextLines = new ArrayList<>();
for (int i = 0; i < textLines.size(); i++)
{
- ITextProperties textLine = textLines.get(i);
- List<ITextProperties> wrappedLine = font.getSplitter().splitLines(textLine, tooltipTextWidth, Style.EMPTY);
+ FormattedText textLine = textLines.get(i);
+ List<FormattedText> wrappedLine = font.getSplitter().splitLines(textLine, tooltipTextWidth, Style.EMPTY);
if (i == 0)
{
titleLinesCount = wrappedLine.size();
}
- for (ITextProperties line : wrappedLine)
+ for (FormattedText line : wrappedLine)
{
int lineWidth = font.width(line);
if (lineWidth > wrappedTooltipWidth)
@@ -348,7 +349,7 @@ public class Tooltips
tooltipY = screenHeight - tooltipHeight - 4;
}
- rect = new Rectangle2d(tooltipX - 4, tooltipY - 4, tooltipTextWidth + 8, tooltipHeight + 8);
+ rect = new Rect2i(tooltipX - 4, tooltipY - 4, tooltipTextWidth + 8, tooltipHeight + 8);
return rect;
}
}
diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml
index 77fa6e8..63fbef3 100644
--- a/src/main/resources/META-INF/mods.toml
+++ b/src/main/resources/META-INF/mods.toml
@@ -1,5 +1,5 @@
modLoader="javafml"
-loaderVersion="[36,)"
+loaderVersion="[37,)"
license="CC BY-NC-ND 4.0"
[[mods]]
@@ -15,13 +15,13 @@ description="A library containing events, helpers, and utilities to make modding
[[dependencies.iceberg]]
modId="forge"
mandatory=true
- versionRange="[36,)"
+ versionRange="[37,)"
ordering="NONE"
side="BOTH"
[[dependencies.iceberg]]
modId="minecraft"
mandatory=true
- versionRange="[1.16.5]"
+ versionRange="[1.17.1]"
ordering="NONE"
side="BOTH" \ No newline at end of file
diff --git a/src/main/resources/iceberg.mixins.json b/src/main/resources/iceberg.mixins.json
index 9dfa917..8bb4253 100644
--- a/src/main/resources/iceberg.mixins.json
+++ b/src/main/resources/iceberg.mixins.json
@@ -13,6 +13,6 @@
"injectors": {
"defaultRequire": 1
},
- "minVersion": "0.8",
+ "minVersion": "0.8.4",
"target": "@env(DEFAULT)"
}