From 203d4a2e698c61f566453702a1fa545243b000e7 Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Sun, 8 Sep 2024 14:49:05 -0400 Subject: [PATCH] Render forge recipe duration --- .../itemlist/recipes/SkyblockForgeRecipe.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/itemlist/recipes/SkyblockForgeRecipe.java b/src/main/java/de/hysky/skyblocker/skyblock/itemlist/recipes/SkyblockForgeRecipe.java index 728eca62ff..cc87308f87 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/itemlist/recipes/SkyblockForgeRecipe.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/itemlist/recipes/SkyblockForgeRecipe.java @@ -3,6 +3,8 @@ import de.hysky.skyblocker.SkyblockerMod; import de.hysky.skyblocker.utils.ItemUtils; import io.github.moulberry.repo.data.NEUForgeRecipe; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.ScreenPos; import net.minecraft.item.ItemStack; import net.minecraft.text.Text; @@ -20,10 +22,12 @@ public class SkyblockForgeRecipe implements SkyblockRecipe { private final List inputs; private final ItemStack output; + private final int duration; public SkyblockForgeRecipe(NEUForgeRecipe forgeRecipe) { inputs = forgeRecipe.getInputs().stream().map(SkyblockRecipe::getItemStack).toList(); output = SkyblockRecipe.getItemStack(forgeRecipe.getOutputStack()); + duration = forgeRecipe.getDuration(); } @@ -92,4 +96,12 @@ public Identifier getRecipeIdentifier() { public @Nullable ScreenPos getArrowLocation(int width, int height) { return new ScreenPos(width / 2, height / 2 - 9); } + + @Override + public void render(DrawContext context, int width, int height, double mouseX, double mouseY) { + // Render the duration of the recipe in hours by dividing by 3600 + ScreenPos arrowLocation = getArrowLocation(width, height); + if (arrowLocation != null) + context.drawCenteredTextWithShadow(MinecraftClient.getInstance().textRenderer, String.format("%d h", duration / 3600), arrowLocation.x() + 12, arrowLocation.y() - 10, 0xFFFFFF); + } }