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 fc6763b commit aeffd7a
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
import java.util.stream.Collectors;

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 @@ -68,7 +68,7 @@ public IRecipeSlotBuilder addSlot(RecipeIngredientRole role) {
addOutputSlotTooltipCallback(slot);
}

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

Expand All @@ -83,7 +83,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 @@ -175,6 +175,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 @@ -187,7 +190,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 aeffd7a

Please sign in to comment.