aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnthony Hilyard <anthony.hilyard@gmail.com>2021-10-13 22:51:23 -0700
committerAnthony Hilyard <anthony.hilyard@gmail.com>2021-10-13 22:51:23 -0700
commit407a3cfabed3869b38527153e8b3322a824f1263 (patch)
tree06909dc024d048e999354a0c7102a57bccf32ef8 /src
parent0eb0e8504684ad9e7bdae99a54de618809cee8d4 (diff)
downloadIceberg-407a3cfabed3869b38527153e8b3322a824f1263.tar.gz
Iceberg-407a3cfabed3869b38527153e8b3322a824f1263.tar.bz2
Iceberg-407a3cfabed3869b38527153e8b3322a824f1263.zip
Initial commit for 1.17.1 version.
Diffstat (limited to 'src')
-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
20 files changed, 218 insertions, 218 deletions
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)"
}