diff --git a/src/main/java/mezz/jei/gui/ingredients/GuiFluidStackGroup.java b/src/main/java/mezz/jei/gui/ingredients/GuiFluidStackGroup.java index e60b92b31..f556833ae 100644 --- a/src/main/java/mezz/jei/gui/ingredients/GuiFluidStackGroup.java +++ b/src/main/java/mezz/jei/gui/ingredients/GuiFluidStackGroup.java @@ -9,8 +9,8 @@ import net.minecraftforge.fluids.FluidStack; public class GuiFluidStackGroup extends GuiIngredientGroup implements IGuiFluidStackGroup { - public GuiFluidStackGroup(IFocus focus) { - super(FluidStack.class, focus); + public GuiFluidStackGroup(IFocus focus, int cycleOffset) { + super(FluidStack.class, focus, cycleOffset); } @Override diff --git a/src/main/java/mezz/jei/gui/ingredients/GuiIngredient.java b/src/main/java/mezz/jei/gui/ingredients/GuiIngredient.java index 9b806962f..c2965ceb9 100644 --- a/src/main/java/mezz/jei/gui/ingredients/GuiIngredient.java +++ b/src/main/java/mezz/jei/gui/ingredients/GuiIngredient.java @@ -57,7 +57,7 @@ public GuiIngredient( int xPosition, int yPosition, int width, int height, int xPadding, int yPadding, - int itemCycleOffset + int cycleOffset ) { this.ingredientRenderer = ingredientRenderer; this.ingredientHelper = ingredientHelper; @@ -72,7 +72,7 @@ public GuiIngredient( this.xPadding = xPadding; this.yPadding = yPadding; - this.cycleTimer = new CycleTimer(itemCycleOffset); + this.cycleTimer = new CycleTimer(cycleOffset); } public boolean isMouseOver(int xOffset, int yOffset, int mouseX, int mouseY) { diff --git a/src/main/java/mezz/jei/gui/ingredients/GuiIngredientGroup.java b/src/main/java/mezz/jei/gui/ingredients/GuiIngredientGroup.java index 8de6b09f5..4e97e6b66 100644 --- a/src/main/java/mezz/jei/gui/ingredients/GuiIngredientGroup.java +++ b/src/main/java/mezz/jei/gui/ingredients/GuiIngredientGroup.java @@ -22,11 +22,11 @@ import net.minecraft.client.Minecraft; public class GuiIngredientGroup implements IGuiIngredientGroup { - private final int itemCycleOffset = (int) (Math.random() * 1000); private final Map> guiIngredients = new HashMap>(); private final Set inputSlots = new HashSet(); private final IIngredientHelper ingredientHelper; private final Class ingredientClass; + private final int cycleOffset; /** * If focus is set and any of the guiIngredients contains focus * they will only display focus instead of rotating through all their values. @@ -36,7 +36,7 @@ public class GuiIngredientGroup implements IGuiIngredientGroup { @Nullable private ITooltipCallback tooltipCallback; - public GuiIngredientGroup(Class ingredientClass, IFocus focus) { + public GuiIngredientGroup(Class ingredientClass, IFocus focus, int cycleOffset) { this.ingredientClass = ingredientClass; if (focus.getMode() == IFocus.Mode.INPUT) { this.inputFocus = focus; @@ -49,11 +49,12 @@ public GuiIngredientGroup(Class ingredientClass, IFocus focus) { this.outputFocus = new Focus(null); } this.ingredientHelper = Internal.getIngredientRegistry().getIngredientHelper(ingredientClass); + this.cycleOffset = cycleOffset; } @Override public void init(int slotIndex, boolean input, IIngredientRenderer ingredientRenderer, int xPosition, int yPosition, int width, int height, int xPadding, int yPadding) { - GuiIngredient guiIngredient = new GuiIngredient(slotIndex, input, ingredientRenderer, ingredientHelper, xPosition, yPosition, width, height, xPadding, yPadding, itemCycleOffset); + GuiIngredient guiIngredient = new GuiIngredient(slotIndex, input, ingredientRenderer, ingredientHelper, xPosition, yPosition, width, height, xPadding, yPadding, cycleOffset); guiIngredients.put(slotIndex, guiIngredient); if (input) { inputSlots.add(slotIndex); diff --git a/src/main/java/mezz/jei/gui/ingredients/GuiItemStackGroup.java b/src/main/java/mezz/jei/gui/ingredients/GuiItemStackGroup.java index ac19a7197..8ee8bbeb3 100644 --- a/src/main/java/mezz/jei/gui/ingredients/GuiItemStackGroup.java +++ b/src/main/java/mezz/jei/gui/ingredients/GuiItemStackGroup.java @@ -13,8 +13,8 @@ public class GuiItemStackGroup extends GuiIngredientGroup implements private static final int baseHeight = 16; private static final ItemStackRenderer renderer = new ItemStackRenderer(); - public GuiItemStackGroup(IFocus focus) { - super(ItemStack.class, focus); + public GuiItemStackGroup(IFocus focus, int cycleOffset) { + super(ItemStack.class, focus, cycleOffset); } public static int getWidth(int padding) { diff --git a/src/main/java/mezz/jei/gui/recipes/RecipeCategoryCraftingItems.java b/src/main/java/mezz/jei/gui/recipes/RecipeCategoryCraftingItems.java index ed3f185a2..5599f4de4 100644 --- a/src/main/java/mezz/jei/gui/recipes/RecipeCategoryCraftingItems.java +++ b/src/main/java/mezz/jei/gui/recipes/RecipeCategoryCraftingItems.java @@ -38,7 +38,7 @@ public class RecipeCategoryCraftingItems implements IShowsRecipeFocuses { public RecipeCategoryCraftingItems(IRecipeRegistry recipeRegistry) { this.recipeRegistry = recipeRegistry; IFocus focus = recipeRegistry.createFocus(IFocus.Mode.NONE, null); - craftingItems = new GuiItemStackGroup(focus); + craftingItems = new GuiItemStackGroup(focus, 0); ResourceLocation recipeBackgroundResource = new ResourceLocation(Constants.RESOURCE_DOMAIN, Constants.TEXTURE_RECIPE_BACKGROUND_PATH); @@ -50,7 +50,7 @@ public RecipeCategoryCraftingItems(IRecipeRegistry recipeRegistry) { public void updateLayout(List itemStacks, GuiProperties guiProperties) { IFocus focus = recipeRegistry.createFocus(IFocus.Mode.NONE, null); - craftingItems = new GuiItemStackGroup(focus); + craftingItems = new GuiItemStackGroup(focus, 0); if (!itemStacks.isEmpty()) { int totalHeight = topDrawable.getHeight() + middleDrawable.getHeight() + bottomDrawable.getHeight(); diff --git a/src/main/java/mezz/jei/gui/recipes/RecipeLayout.java b/src/main/java/mezz/jei/gui/recipes/RecipeLayout.java index 8de52fcd1..21329aad4 100644 --- a/src/main/java/mezz/jei/gui/recipes/RecipeLayout.java +++ b/src/main/java/mezz/jei/gui/recipes/RecipeLayout.java @@ -31,6 +31,7 @@ public class RecipeLayout implements IRecipeLayoutDrawable { private static final int RECIPE_BUTTON_SIZE = 12; public static final int recipeTransferButtonIndex = 100; + private final int ingredientCycleOffset = (int) (Math.random() * 10000); private final IRecipeCategory recipeCategory; private final GuiItemStackGroup guiItemStackGroup; private final GuiFluidStackGroup guiFluidStackGroup; @@ -55,8 +56,8 @@ public RecipeLayout(int index, IRecipeCategory rec } else if (focusValue instanceof FluidStack) { fluidStackFocus = (FluidStack) focusValue; } - this.guiItemStackGroup = new GuiItemStackGroup(new Focus(focus.getMode(), itemStackFocus)); - this.guiFluidStackGroup = new GuiFluidStackGroup(new Focus(focus.getMode(), fluidStackFocus)); + this.guiItemStackGroup = new GuiItemStackGroup(new Focus(focus.getMode(), itemStackFocus), ingredientCycleOffset); + this.guiFluidStackGroup = new GuiFluidStackGroup(new Focus(focus.getMode(), fluidStackFocus), ingredientCycleOffset); this.guiIngredientGroups = new HashMap(); this.guiIngredientGroups.put(ItemStack.class, this.guiItemStackGroup); @@ -204,7 +205,7 @@ public IGuiIngredientGroup getIngredientsGroup(Class ingredientClass) value = (T) focusValue; } IFocus focus = new Focus(this.focus.getMode(), value); - guiIngredientGroup = new GuiIngredientGroup(ingredientClass, focus); + guiIngredientGroup = new GuiIngredientGroup(ingredientClass, focus, ingredientCycleOffset); guiIngredientGroups.put(ingredientClass, guiIngredientGroup); } return guiIngredientGroup; diff --git a/src/main/java/mezz/jei/transfer/PlayerRecipeTransferHandler.java b/src/main/java/mezz/jei/transfer/PlayerRecipeTransferHandler.java index 2bede07c5..d1e2bf1c4 100644 --- a/src/main/java/mezz/jei/transfer/PlayerRecipeTransferHandler.java +++ b/src/main/java/mezz/jei/transfer/PlayerRecipeTransferHandler.java @@ -98,7 +98,7 @@ public IRecipeTransferError transferRecipe(ContainerPlayer container, IRecipeLay guiIngredients.add(guiIngredient); } } - IGuiItemStackGroup playerInvItemStackGroup = new GuiItemStackGroup(new Focus(null)); + IGuiItemStackGroup playerInvItemStackGroup = new GuiItemStackGroup(new Focus(null), 0); int[] playerGridIndexes = {0, 1, 3, 4}; for (int i = 0; i < 4; i++) { int index = playerGridIndexes[i];