Skip to content

Commit

Permalink
Prevent displaying invisible focus-linked slots
Browse files Browse the repository at this point in the history
  • Loading branch information
mezz committed Oct 8, 2024
1 parent 3efb0e2 commit e5bf20b
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import java.util.Set;

public class RecipeLayoutBuilder<T> implements IRecipeLayoutBuilder {
private final List<RecipeSlotBuilder> slots = new ArrayList<>();
private final List<RecipeSlotBuilder> visibleSlots = new ArrayList<>();
private final List<List<RecipeSlotBuilder>> focusLinkedSlots = new ArrayList<>();

private final IIngredientManager ingredientManager;
Expand Down Expand Up @@ -66,7 +66,7 @@ public IRecipeSlotBuilder addSlot(RecipeIngredientRole role) {
addOutputSlotTooltipCallback(slot);
}

this.slots.add(slot);
this.visibleSlots.add(slot);
return slot;
}

Expand All @@ -81,7 +81,7 @@ public IRecipeSlotBuilder addSlotToWidget(RecipeIngredientRole role, mezz.jei.ap
addOutputSlotTooltipCallback(slot);
}

this.slots.add(slot);
this.visibleSlots.add(slot);
return slot;
}

Expand Down Expand Up @@ -173,6 +173,9 @@ public RecipeLayout<T> buildRecipeLayout(
focusMatches.addAll(slot.getMatches(focuses));
}
for (RecipeSlotBuilder slotBuilder : linkedSlots) {
if (!visibleSlots.contains(slotBuilder)) {
continue;
}
mezz.jei.api.gui.widgets.ISlottedWidgetFactory<?> assignedWidget = slotBuilder.getAssignedWidget();
Pair<Integer, IRecipeSlotDrawable> slotDrawable = slotBuilder.build(focusMatches, cycleTicker);
if (assignedWidget == null) {
Expand All @@ -185,7 +188,7 @@ public RecipeLayout<T> buildRecipeLayout(
focusLinkedSlots.addAll(linkedSlots);
}

for (RecipeSlotBuilder slotBuilder : slots) {
for (RecipeSlotBuilder slotBuilder : visibleSlots) {
if (!focusLinkedSlots.contains(slotBuilder)) {
mezz.jei.api.gui.widgets.ISlottedWidgetFactory<?> assignedWidget = slotBuilder.getAssignedWidget();
Pair<Integer, IRecipeSlotDrawable> slotDrawable = slotBuilder.build(focuses, cycleTicker);
Expand Down

0 comments on commit e5bf20b

Please sign in to comment.