Skip to content

Commit

Permalink
Render forge recipe duration
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinthegreat1 committed Sep 8, 2024
1 parent 3be895a commit 203d4a2
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -20,10 +22,12 @@ public class SkyblockForgeRecipe implements SkyblockRecipe {

private final List<ItemStack> 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();
}


Expand Down Expand Up @@ -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);
}
}

0 comments on commit 203d4a2

Please sign in to comment.