package net.geforcemods.securitycraft.screen.components;

import com.mojang.blaze3d.vertex.PoseStack;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.components.Widget;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Ingredient;

public class IngredientDisplay implements Widget {
	private static final int DISPLAY_LENGTH = 20;
	private final int x;
	private final int y;
	private ItemStack[] stacks;
	private int currentRenderingStack = 0;
	private float ticksToChange = DISPLAY_LENGTH;

	public IngredientDisplay(int x, int y) {
		this.x = x;
		this.y = y;
	}

	@Override
	public void render(PoseStack pose, int mouseX, int mouseY, float partialTick) {
		if (stacks == null || stacks.length == 0)
			return;

		Minecraft.getInstance().getItemRenderer().renderAndDecorateItem(stacks[currentRenderingStack], x, y);
		ticksToChange -= partialTick;

		if (ticksToChange <= 0) {
			if (++currentRenderingStack >= stacks.length)
				currentRenderingStack = 0;

			ticksToChange = DISPLAY_LENGTH;
		}
	}

	public void setIngredient(Ingredient ingredient) {
		stacks = ingredient.getItems();
		currentRenderingStack = 0;
		ticksToChange = DISPLAY_LENGTH;
	}

	public ItemStack getCurrentStack() {
		return currentRenderingStack >= 0 && currentRenderingStack < stacks.length && stacks.length != 0 ? stacks[currentRenderingStack] : ItemStack.EMPTY;
	}
}

@@ -188,24 +188,73 @@
 ts.Widget;%0D%0A
+import net.minecraft.client.gui.screens.Screen;%0D%0A
 import net.m
@@ -945,16 +945,52 @@
 x, y);%0D%0A
+%0D%0A%09%09if (!Screen.hasShiftDown()) %7B%0D%0A%09
 %09%09ticksT
@@ -1014,24 +1014,25 @@
 lTick;%0D%0A%0D%0A%09%09
+%09
 if (ticksToC
@@ -1046,16 +1046,17 @@
 = 0) %7B%0D%0A
+%09
 %09%09%09if (+
@@ -1101,16 +1101,17 @@
 h)%0D%0A%09%09%09%09
+%09
 currentR
@@ -1132,16 +1132,17 @@
 = 0;%0D%0A%0D%0A
+%09
 %09%09%09ticks
@@ -1169,16 +1169,22 @@
 ENGTH;%0D%0A
+%09%09%09%7D%0D%0A
 %09%09%7D%0D%0A%09%7D%0D

stop switching items in sc manual when shift key is held