From 1469e4ca5f314e817e307d27cb159098b4b3ce00 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Sun, 19 Dec 2021 18:24:54 +0100 Subject: [PATCH] added back overlay rendering --- .../java/de/ellpeck/naturesaura/Helper.java | 44 ++-- .../compat/patchouli/PatchouliCompat.java | 3 +- .../naturesaura/events/ClientEvents.java | 237 +++++++++--------- 3 files changed, 140 insertions(+), 144 deletions(-) diff --git a/src/main/java/de/ellpeck/naturesaura/Helper.java b/src/main/java/de/ellpeck/naturesaura/Helper.java index e35ffbe7..3ac4dbab 100644 --- a/src/main/java/de/ellpeck/naturesaura/Helper.java +++ b/src/main/java/de/ellpeck/naturesaura/Helper.java @@ -1,5 +1,6 @@ package de.ellpeck.naturesaura; +import com.mojang.blaze3d.systems.RenderSystem; import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.aura.container.IAuraContainer; import de.ellpeck.naturesaura.api.aura.item.IAuraRecharge; @@ -8,6 +9,7 @@ import de.ellpeck.naturesaura.blocks.tiles.BlockEntityImpl; import de.ellpeck.naturesaura.chunk.AuraChunk; import de.ellpeck.naturesaura.compat.Compat; import de.ellpeck.naturesaura.misc.LevelData; +import net.minecraft.client.Minecraft; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.resources.ResourceLocation; @@ -41,7 +43,6 @@ import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.IForgeRegistry; import net.minecraftforge.registries.IForgeRegistryEntry; import org.apache.commons.lang3.tuple.ImmutableTriple; -import org.lwjgl.opengl.GL11; import top.theillusivec4.curios.api.CuriosApi; import javax.annotation.Nonnull; @@ -116,6 +117,19 @@ public final class Helper { return !nbt || ItemStack.tagMatches(first, second); } + @OnlyIn(Dist.CLIENT) + public static void renderItemInGui(ItemStack stack, int x, int y, float scale) { + var poseStack = RenderSystem.getModelViewStack(); + poseStack.pushPose(); + poseStack.translate(x, y, 0); + poseStack.scale(scale, scale, scale); + RenderSystem.applyModelViewMatrix(); + Minecraft.getInstance().getItemRenderer().renderGuiItem(stack, 0, 0); + Minecraft.getInstance().getItemRenderer().renderGuiItemDecorations(Minecraft.getInstance().font, stack, 0, 0, null); + poseStack.popPose(); + RenderSystem.applyModelViewMatrix(); + } + public static InteractionResult putStackOnTile(Player player, InteractionHand hand, BlockPos pos, int slot, boolean sound) { var tile = player.level.getBlockEntity(pos); if (tile instanceof BlockEntityImpl) { @@ -226,34 +240,6 @@ public final class Helper { return highestAmount; } - @OnlyIn(Dist.CLIENT) - public static void renderWeirdBox(double x, double y, double z, double width, double height, double depth) { - GL11.glVertex3d(x, y + height, z); - GL11.glVertex3d(x + width, y + height, z); - GL11.glVertex3d(x + width, y, z); - GL11.glVertex3d(x, y, z); - GL11.glVertex3d(x + width, y, z + depth); - GL11.glVertex3d(x + width, y, z); - GL11.glVertex3d(x + width, y + height, z); - GL11.glVertex3d(x + width, y + height, z + depth); - GL11.glVertex3d(x + width, y + height, z + depth); - GL11.glVertex3d(x, y + height, z + depth); - GL11.glVertex3d(x, y, z + depth); - GL11.glVertex3d(x + width, y, z + depth); - GL11.glVertex3d(x, y + height, z + depth); - GL11.glVertex3d(x, y + height, z); - GL11.glVertex3d(x, y, z); - GL11.glVertex3d(x, y, z + depth); - GL11.glVertex3d(x, y + height, z); - GL11.glVertex3d(x, y + height, z + depth); - GL11.glVertex3d(x + width, y + height, z + depth); - GL11.glVertex3d(x + width, y + height, z); - GL11.glVertex3d(x + width, y, z); - GL11.glVertex3d(x + width, y, z + depth); - GL11.glVertex3d(x, y, z + depth); - GL11.glVertex3d(x, y, z); - } - public static boolean isHoldingItem(Player player, Item item) { for (var hand : InteractionHand.values()) { var stack = player.getItemInHand(hand); diff --git a/src/main/java/de/ellpeck/naturesaura/compat/patchouli/PatchouliCompat.java b/src/main/java/de/ellpeck/naturesaura/compat/patchouli/PatchouliCompat.java index aaef2301..5dcecc5d 100644 --- a/src/main/java/de/ellpeck/naturesaura/compat/patchouli/PatchouliCompat.java +++ b/src/main/java/de/ellpeck/naturesaura/compat/patchouli/PatchouliCompat.java @@ -138,8 +138,7 @@ public class PatchouliCompat implements ICompat { var r = ((info.color() >> 16) & 255) / 255F; var g = ((info.color() >> 8) & 255) / 255F; var b = (info.color() & 255) / 255F; - // TODO apply leaf color, we probably have to blit manually using the texture + color shader - //RenderSystem.color3f(r, g, b); + RenderSystem.setShaderColor(r, g, b, 1); Screen.blit(event.getPoseStack(), x, y, 496 - 32, 44, 16, 18, 512, 256); } diff --git a/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java b/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java index e6022493..20d32c46 100644 --- a/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java +++ b/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java @@ -1,32 +1,44 @@ package de.ellpeck.naturesaura.events; +import com.mojang.blaze3d.platform.Window; +import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.PoseStack; import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.ModConfig; import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; +import de.ellpeck.naturesaura.api.aura.container.IAuraContainer; import de.ellpeck.naturesaura.api.aura.type.IAuraType; +import de.ellpeck.naturesaura.blocks.tiles.*; import de.ellpeck.naturesaura.items.ItemAuraCache; import de.ellpeck.naturesaura.items.ItemRangeVisualizer; import de.ellpeck.naturesaura.items.ModItems; import de.ellpeck.naturesaura.packet.PacketAuraChunk; import net.minecraft.ChatFormatting; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.screens.ChatScreen; +import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.renderer.BiomeColors; +import net.minecraft.client.resources.language.I18n; import net.minecraft.core.BlockPos; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Mth; import net.minecraft.util.Tuple; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; -import net.minecraft.world.level.block.*; -import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.BonemealableBlock; +import net.minecraft.world.level.block.LeavesBlock; +import net.minecraft.world.level.block.MyceliumBlock; import net.minecraft.world.level.levelgen.Heightmap; +import net.minecraft.world.phys.BlockHitResult; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.client.event.RenderLevelLastEvent; import net.minecraftforge.common.IPlantable; +import net.minecraftforge.energy.EnergyStorage; import net.minecraftforge.event.TickEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import org.apache.commons.lang3.mutable.MutableInt; @@ -236,131 +248,132 @@ public class ClientEvents { @SubscribeEvent public void onOverlayRender(RenderGameOverlayEvent.Post event) { - // TODO raw rendering bleh, should be easy enough to convert to PoseStack stuff - /*Minecraft mc = Minecraft.getInstance(); - PoseStack stack = event.getMatrixStack(); - if (event.getType() == ElementType.ALL) { + var mc = Minecraft.getInstance(); + var stack = event.getMatrixStack(); + if (event.getType() == RenderGameOverlayEvent.ElementType.ALL) { var res = event.getWindow(); if (mc.player != null) { if (!heldCache.isEmpty()) { - IAuraContainer container = heldCache.getCapability(NaturesAuraAPI.capAuraContainer, null).orElse(null); - int width = Mth.ceil(container.getStoredAura() / (float) container.getMaxAura() * 80); + var container = heldCache.getCapability(NaturesAuraAPI.capAuraContainer, null).orElse(null); + var width = Mth.ceil(container.getStoredAura() / (float) container.getMaxAura() * 80); int conf = ModConfig.instance.cacheBarLocation.get(); - int x = res.getGuiScaledWidth() / 2 + (conf == 0 ? -173 - (mc.player.getOffhandItem().isEmpty() ? 0 : 29) : 93); - int y = res.getScreenHeight() - 8; + var x = res.getGuiScaledWidth() / 2 + (conf == 0 ? -173 - (mc.player.getOffhandItem().isEmpty() ? 0 : 29) : 93); + var y = res.getGuiScaledHeight() - 8; - RenderSystem.pushMatrix(); + stack.pushPose(); - int color = container.getAuraColor(); - RenderSystem.color4f((color >> 16 & 255) / 255F, (color >> 8 & 255) / 255F, (color & 255) / 255F, 1); - mc.getTextureManager().bindTexture(OVERLAYS); + var color = container.getAuraColor(); + RenderSystem.setShaderColor((color >> 16 & 255) / 255F, (color >> 8 & 255) / 255F, (color & 255) / 255F, 1); + RenderSystem.setShaderTexture(0, OVERLAYS); if (width < 80) - AbstractGui.blit(stack, x + width, y, width, 0, 80 - width, 6, 256, 256); + Screen.blit(stack, x + width, y, width, 0, 80 - width, 6, 256, 256); if (width > 0) - AbstractGui.blit(stack, x, y, 0, 6, width, 6, 256, 256); + Screen.blit(stack, x, y, 0, 6, width, 6, 256, 256); - float scale = 0.75F; - RenderSystem.scalef(scale, scale, scale); - String s = heldCache.getDisplayName().getString(); - mc.fontRenderer.drawStringWithShadow(stack, s, conf == 1 ? x / scale : (x + 80) / scale - mc.fontRenderer.getStringWidth(s), (y - 7) / scale, color); + var scale = 0.75F; + stack.pushPose(); + stack.scale(scale, scale, scale); + var s = heldCache.getDisplayName().getString(); + mc.font.drawShadow(stack, s, conf == 1 ? x / scale : (x + 80) / scale - mc.font.width(s), (y - 7) / scale, color); + stack.popPose(); - RenderSystem.color4f(1F, 1F, 1F, 1); - RenderSystem.popMatrix(); + RenderSystem.setShaderColor(1F, 1F, 1F, 1); + stack.pushPose(); } if (!heldEye.isEmpty() || !heldOcular.isEmpty()) { - RenderSystem.pushMatrix(); - mc.getTextureManager().bindTexture(OVERLAYS); + stack.pushPose(); + RenderSystem.setShaderTexture(0, OVERLAYS); int conf = ModConfig.instance.auraBarLocation.get(); - if (!mc.gameSettings.showDebugInfo && (conf != 2 || !(mc.currentScreen instanceof ChatScreen))) { - int color = IAuraType.forLevel(mc.level).getColor(); - RenderSystem.color4f((color >> 16 & 0xFF) / 255F, (color >> 8 & 0xFF) / 255F, (color & 0xFF) / 255F, 1); + if (!mc.options.renderDebug && (conf != 2 || !(mc.screen instanceof ChatScreen))) { + var color = IAuraType.forLevel(mc.level).getColor(); + RenderSystem.setShaderColor((color >> 16 & 0xFF) / 255F, (color >> 8 & 0xFF) / 255F, (color & 0xFF) / 255F, 1); - int totalAmount = IAuraChunk.triangulateAuraInArea(mc.level, mc.player.getPosition(), 35); - float totalPercentage = totalAmount / (IAuraChunk.DEFAULT_AURA * 2F); - String text = I18n.format("info." + NaturesAura.MOD_ID + ".aura_in_area"); - float textScale = 0.75F; + var totalAmount = IAuraChunk.triangulateAuraInArea(mc.level, mc.player.blockPosition(), 35); + var totalPercentage = totalAmount / (IAuraChunk.DEFAULT_AURA * 2F); + var text = I18n.get("info." + NaturesAura.MOD_ID + ".aura_in_area"); + var textScale = 0.75F; - int startX = conf % 2 == 0 ? 3 : res.getScaledWidth() - 3 - 6; - int startY = conf < 2 ? 10 : (!heldOcular.isEmpty() && (totalPercentage > 1F || totalPercentage < 0) ? -26 : 0) + res.getScaledHeight() - 60; + var startX = conf % 2 == 0 ? 3 : res.getGuiScaledWidth() - 3 - 6; + var startY = conf < 2 ? 10 : (!heldOcular.isEmpty() && (totalPercentage > 1F || totalPercentage < 0) ? -26 : 0) + res.getGuiScaledHeight() - 60; float plusOffX = conf % 2 == 0 ? 7 : -1 - 6; - float textX = conf % 2 == 0 ? 3 : res.getScaledWidth() - 3 - mc.fontRenderer.getStringWidth(text) * textScale; - float textY = conf < 2 ? 3 : res.getScaledHeight() - 3 - 6; + var textX = conf % 2 == 0 ? 3 : res.getGuiScaledWidth() - 3 - mc.font.width(text) * textScale; + float textY = conf < 2 ? 3 : res.getGuiScaledHeight() - 3 - 6; - int tHeight = Mth.ceil(Mth.clamp(totalPercentage, 0F, 1F) * 50); - int y = !heldOcular.isEmpty() && totalPercentage > 1F ? startY + 26 : startY; + var tHeight = Mth.ceil(Mth.clamp(totalPercentage, 0F, 1F) * 50); + var y = !heldOcular.isEmpty() && totalPercentage > 1F ? startY + 26 : startY; if (tHeight < 50) - AbstractGui.blit(stack, startX, y, 6, 12, 6, 50 - tHeight, 256, 256); + Screen.blit(stack, startX, y, 6, 12, 6, 50 - tHeight, 256, 256); if (tHeight > 0) - AbstractGui.blit(stack, startX, y + 50 - tHeight, 0, 12 + 50 - tHeight, 6, tHeight, 256, 256); + Screen.blit(stack, startX, y + 50 - tHeight, 0, 12 + 50 - tHeight, 6, tHeight, 256, 256); if (!heldOcular.isEmpty()) { - int topHeight = Mth.ceil(Mth.clamp((totalPercentage - 1F) * 2F, 0F, 1F) * 25); + var topHeight = Mth.ceil(Mth.clamp((totalPercentage - 1F) * 2F, 0F, 1F) * 25); if (topHeight > 0) { if (topHeight < 25) - AbstractGui.blit(stack, startX, startY, 18, 12, 6, 25 - topHeight, 256, 256); - AbstractGui.blit(stack, startX, startY + 25 - topHeight, 12, 12 + 25 - topHeight, 6, topHeight, 256, 256); + Screen.blit(stack, startX, startY, 18, 12, 6, 25 - topHeight, 256, 256); + Screen.blit(stack, startX, startY + 25 - topHeight, 12, 12 + 25 - topHeight, 6, topHeight, 256, 256); } - int bottomHeight = Mth.floor(Mth.clamp((totalPercentage + 1F) * 2F - 1F, 0F, 1F) * 25); + var bottomHeight = Mth.floor(Mth.clamp((totalPercentage + 1F) * 2F - 1F, 0F, 1F) * 25); if (bottomHeight < 25) { - AbstractGui.blit(stack, startX, startY + 51, 18, 12, 6, 25 - bottomHeight, 256, 256); + Screen.blit(stack, startX, startY + 51, 18, 12, 6, 25 - bottomHeight, 256, 256); if (bottomHeight > 0) - AbstractGui.blit(stack, startX, startY + 51 + 25 - bottomHeight, 12, 12 + 25 - bottomHeight, 6, bottomHeight, 256, 256); + Screen.blit(stack, startX, startY + 51 + 25 - bottomHeight, 12, 12 + 25 - bottomHeight, 6, bottomHeight, 256, 256); } } if (totalPercentage > (heldOcular.isEmpty() ? 1F : 1.5F)) - mc.fontRenderer.drawStringWithShadow(stack, "+", startX + plusOffX, startY - 0.5F, color); + mc.font.drawShadow(stack, "+", startX + plusOffX, startY - 0.5F, color); if (totalPercentage < (heldOcular.isEmpty() ? 0F : -0.5F)) - mc.fontRenderer.drawStringWithShadow(stack, "-", startX + plusOffX, startY - 0.5F + (heldOcular.isEmpty() ? 44 : 70), color); + mc.font.drawShadow(stack, "-", startX + plusOffX, startY - 0.5F + (heldOcular.isEmpty() ? 44 : 70), color); - RenderSystem.pushMatrix(); - RenderSystem.scalef(textScale, textScale, textScale); - mc.fontRenderer.drawStringWithShadow(stack, text, textX / textScale, textY / textScale, color); - RenderSystem.popMatrix(); + stack.pushPose(); + stack.scale(textScale, textScale, textScale); + mc.font.drawShadow(stack, text, textX / textScale, textY / textScale, color); + stack.popPose(); if (!heldOcular.isEmpty()) { - float scale = 0.75F; - RenderSystem.pushMatrix(); - RenderSystem.scalef(scale, scale, scale); - int stackX = conf % 2 == 0 ? 10 : res.getScaledWidth() - 22; - int stackY = conf < 2 ? 15 : res.getScaledHeight() - 55; - for (Tuple effect : SHOWING_EFFECTS.values()) { - int theX = (int) (stackX / scale); - int theY = (int) (stackY / scale); - ItemStack itemStack = effect.getA(); + var scale = 0.75F; + stack.pushPose(); + stack.scale(scale, scale, scale); + var stackX = conf % 2 == 0 ? 10 : res.getGuiScaledWidth() - 22; + var stackY = conf < 2 ? 15 : res.getGuiScaledHeight() - 55; + for (var effect : SHOWING_EFFECTS.values()) { + var theX = (int) (stackX / scale); + var theY = (int) (stackY / scale); + var itemStack = effect.getA(); Helper.renderItemInGui(itemStack, theX, theY, 1F); if (effect.getB()) { - GlStateManager.disableDepthTest(); - mc.getTextureManager().bindTexture(OVERLAYS); - AbstractGui.blit(stack, theX, theY, 240, 0, 16, 16, 256, 256); - GlStateManager.enableDepthTest(); + RenderSystem.disableDepthTest(); + RenderSystem.setShaderTexture(0, OVERLAYS); + Screen.blit(stack, theX, theY, 240, 0, 16, 16, 256, 256); + RenderSystem.enableDepthTest(); } stackY += 8; } - RenderSystem.popMatrix(); + stack.popPose(); } } - if (mc.objectMouseOver instanceof BlockRayTraceResult) { - BlockPos pos = ((BlockRayTraceResult) mc.objectMouseOver).getPos(); + if (mc.hitResult instanceof BlockHitResult blockHitResult) { + var pos = blockHitResult.getBlockPos(); if (pos != null) { - BlockEntity tile = mc.level.getBlockEntity(pos); + var tile = mc.level.getBlockEntity(pos); IAuraContainer container; - int x = res.getScaledWidth() / 2; - int y = res.getScaledHeight() / 2; + var x = res.getGuiScaledWidth() / 2; + var y = res.getGuiScaledHeight() / 2; if (tile != null && (container = tile.getCapability(NaturesAuraAPI.capAuraContainer, null).orElse(null)) != null) { - BlockState state = mc.level.getBlockState(pos); - ItemStack blockStack = state.getBlock().getPickBlock(state, mc.objectMouseOver, mc.level, pos, mc.player); + var state = mc.level.getBlockState(pos); + var blockStack = state.getBlock().getCloneItemStack(state, blockHitResult, mc.level, pos, mc.player); this.drawContainerInfo(stack, container.getStoredAura(), container.getMaxAura(), container.getAuraColor(), mc, res, 35, blockStack.getDisplayName().getString(), null); if (tile instanceof BlockEntityNatureAltar) { - ItemStack tileStack = ((BlockEntityNatureAltar) tile).getItemHandler().getStackInSlot(0); + var tileStack = ((BlockEntityNatureAltar) tile).getItemHandler().getStackInSlot(0); if (!tileStack.isEmpty()) { - IAuraContainer stackCont = tileStack.getCapability(NaturesAuraAPI.capAuraContainer, null).orElse(null); + var stackCont = tileStack.getCapability(NaturesAuraAPI.capAuraContainer, null).orElse(null); if (stackCont != null) { this.drawContainerInfo(stack, stackCont.getStoredAura(), stackCont.getMaxAura(), stackCont.getAuraColor(), mc, res, 55, tileStack.getDisplayName().getString(), null); @@ -370,50 +383,48 @@ public class ClientEvents { } else if (tile instanceof BlockEntityRFConverter) { EnergyStorage storage = ((BlockEntityRFConverter) tile).storage; this.drawContainerInfo(stack, storage.getEnergyStored(), storage.getMaxEnergyStored(), 0xcc4916, - mc, res, 35, I18n.format("block.naturesaura.rf_converter"), + mc, res, 35, I18n.get("block.naturesaura.rf_converter"), storage.getEnergyStored() + " / " + storage.getMaxEnergyStored() + " RF"); - } else if (tile instanceof BlockEntityGratedChute) { - BlockEntityGratedChute chute = (BlockEntityGratedChute) tile; - ItemStack itemStack = chute.getItemHandler().getStackInSlot(0); + } else if (tile instanceof BlockEntityGratedChute chute) { + var itemStack = chute.getItemHandler().getStackInSlot(0); - if (itemStack.isEmpty()) - mc.fontRenderer.drawStringWithShadow(stack, - TextFormatting.GRAY.toString() + TextFormatting.ITALIC + I18n.format("info.naturesaura.empty"), + if (itemStack.isEmpty()) { + mc.font.drawShadow(stack, + ChatFormatting.GRAY.toString() + ChatFormatting.ITALIC + I18n.get("info.naturesaura.empty"), x + 5, y - 11, 0xFFFFFF); - else + } else { Helper.renderItemInGui(itemStack, x + 2, y - 18, 1F); + } Helper.renderItemInGui(ITEM_FRAME, x - 24, y - 24, 1F); - mc.getTextureManager().bindTexture(OVERLAYS); - int u = chute.isBlacklist ? 240 : 224; - GlStateManager.disableDepthTest(); - AbstractGui.blit(stack, x - 18, y - 18, u, 0, 16, 16, 256, 256); - GlStateManager.enableDepthTest(); - } else if (tile instanceof BlockEntityItemDistributor) { - BlockEntityItemDistributor distributor = (BlockEntityItemDistributor) tile; + RenderSystem.setShaderTexture(0, OVERLAYS); + var u = chute.isBlacklist ? 240 : 224; + RenderSystem.disableDepthTest(); + Screen.blit(stack, x - 18, y - 18, u, 0, 16, 16, 256, 256); + RenderSystem.enableDepthTest(); + } else if (tile instanceof BlockEntityItemDistributor distributor) { Helper.renderItemInGui(DISPENSER, x - 24, y - 24, 1F); - mc.getTextureManager().bindTexture(OVERLAYS); - int u = !distributor.isRandomMode ? 240 : 224; - GlStateManager.disableDepthTest(); - AbstractGui.blit(stack, x - 18, y - 18, u, 0, 16, 16, 256, 256); - GlStateManager.enableDepthTest(); - } else if (tile instanceof BlockEntityAuraTimer) { - BlockEntityAuraTimer timer = (BlockEntityAuraTimer) tile; - ItemStack itemStack = timer.getItemHandler().getStackInSlot(0); + RenderSystem.setShaderTexture(0, OVERLAYS); + var u = !distributor.isRandomMode ? 240 : 224; + RenderSystem.disableDepthTest(); + Screen.blit(stack, x - 18, y - 18, u, 0, 16, 16, 256, 256); + RenderSystem.enableDepthTest(); + } else if (tile instanceof BlockEntityAuraTimer timer) { + var itemStack = timer.getItemHandler().getStackInSlot(0); if (!itemStack.isEmpty()) { Helper.renderItemInGui(itemStack, x - 20, y - 20, 1); - mc.fontRenderer.drawStringWithShadow(stack, TextFormatting.GRAY + this.createTimeString(timer.getTotalTime()), x + 5, y - 11, 0xFFFFFF); - mc.fontRenderer.drawStringWithShadow(stack, TextFormatting.GRAY + I18n.format("info.naturesaura.remaining", this.createTimeString(timer.getTimeLeft())), x + 5, y + 3, 0xFFFFFF); + mc.font.drawShadow(stack, ChatFormatting.GRAY + this.createTimeString(timer.getTotalTime()), x + 5, y - 11, 0xFFFFFF); + mc.font.drawShadow(stack, ChatFormatting.GRAY + I18n.get("info.naturesaura.remaining", this.createTimeString(timer.getTimeLeft())), x + 5, y + 3, 0xFFFFFF); } } } } - RenderSystem.color4f(1F, 1F, 1F, 1); - RenderSystem.popMatrix(); + RenderSystem.setShaderColor(1F, 1F, 1F, 1); + stack.popPose(); } } - }*/ + } } private String createTimeString(int totalTicks) { @@ -424,22 +435,22 @@ public class ClientEvents { return String.format("%02d:%02d:%02d.%02d", hours, minutes, seconds, ticks); } -/* private void drawContainerInfo(PoseStack stack, int stored, int max, int color, Minecraft mc, MainWindow res, int yOffset, String name, String textBelow) { - RenderSystem.color3f((color >> 16 & 255) / 255F, (color >> 8 & 255) / 255F, (color & 255) / 255F); + private void drawContainerInfo(PoseStack stack, int stored, int max, int color, Minecraft mc, Window res, int yOffset, String name, String textBelow) { + RenderSystem.setShaderColor((color >> 16 & 255) / 255F, (color >> 8 & 255) / 255F, (color & 255) / 255F, 1); - int x = res.getScaledWidth() / 2 - 40; - int y = res.getScaledHeight() / 2 + yOffset; - int width = Mth.ceil(stored / (float) max * 80); + var x = res.getGuiScaledWidth() / 2 - 40; + var y = res.getGuiScaledHeight() / 2 + yOffset; + var width = Mth.ceil(stored / (float) max * 80); - mc.getTextureManager().bindTexture(OVERLAYS); + RenderSystem.setShaderTexture(0, OVERLAYS); if (width < 80) - AbstractGui.blit(stack, x + width, y, width, 0, 80 - width, 6, 256, 256); + Screen.blit(stack, x + width, y, width, 0, 80 - width, 6, 256, 256); if (width > 0) - AbstractGui.blit(stack, x, y, 0, 6, width, 6, 256, 256); + Screen.blit(stack, x, y, 0, 6, width, 6, 256, 256); - mc.fontRenderer.drawStringWithShadow(stack, name, x + 40 - mc.fontRenderer.getStringWidth(name) / 2F, y - 9, color); + mc.font.drawShadow(stack, name, x + 40 - mc.font.width(name) / 2F, y - 9, color); if (textBelow != null) - mc.fontRenderer.drawStringWithShadow(stack, textBelow, x + 40 - mc.fontRenderer.getStringWidth(textBelow) / 2F, y + 7, color); - }*/ + mc.font.drawShadow(stack, textBelow, x + 40 - mc.font.width(textBelow) / 2F, y + 7, color); + } }