Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/9.x-1.19' into 12.x-1.20
Browse files Browse the repository at this point in the history
# Conflicts:
#	runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/components/ConfigGroupWidget.java
  • Loading branch information
shedaniel committed Apr 29, 2024
2 parents 9cb2883 + c037d7b commit ee6aa88
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import me.shedaniel.math.Point;
import me.shedaniel.math.Rectangle;
import me.shedaniel.rei.api.client.REIRuntime;
import me.shedaniel.rei.api.client.gui.widgets.Widget;
import me.shedaniel.rei.api.client.gui.widgets.WidgetWithBounds;
import me.shedaniel.rei.api.client.gui.widgets.Widgets;
Expand All @@ -37,6 +38,7 @@
import me.shedaniel.rei.impl.client.gui.config.options.preview.InterfacePreviewer;
import me.shedaniel.rei.impl.client.gui.config.options.preview.TooltipPreviewer;
import me.shedaniel.rei.impl.client.gui.text.TextTransformations;
import net.minecraft.client.Minecraft;
import org.apache.commons.lang3.tuple.Pair;
import org.jetbrains.annotations.Nullable;
import org.joml.Matrix4f;
Expand Down Expand Up @@ -65,6 +67,10 @@ public static WidgetWithBounds create(ConfigAccess access, OptionGroup entry, in
.withPadding(0, 0, 0, 6);
WidgetWithBounds contents;

if (applyPreview) {
applyPreview = REIRuntime.getInstance().getPreviousContainerScreen() != null && Minecraft.getInstance().getConnection() != null && Minecraft.getInstance().getConnection().getRecipeManager() != null;
}

if (applyPreview && SPECIAL_GROUPS.containsKey(entry.getId())) {
Pair<PreviewLocation, SpecialGroupConstructor> pair = SPECIAL_GROUPS.get(entry.getId());
PreviewLocation location = pair.getLeft();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ protected void renderEntries(boolean fastEntryRendering, GuiGraphics graphics, i
}

public int getTotalPages() {
return getTotalPages(entries);
}

public int getTotalPages(List<?> entries) {
return Mth.ceil(stacks.size() / (float) entries.size());
}

Expand All @@ -133,7 +137,7 @@ protected void updateEntries(int entrySize, boolean zoomed) {
}
}
}
page = Math.max(Math.min(page, getTotalPages() - 1), 0);
page = Mth.clamp(page, 0, getTotalPages(entries) - 1);
int skip = Math.max(0, page * entries.size());
List</*EntryStack<?> | List<EntryStack<?>>*/ Object> subList = stacks.subList(skip, Math.min(stacks.size(), skip + entries.size()));
Int2ObjectMap<CollapsedStack> indexedCollapsedStack = getCollapsedStackIndexed();
Expand Down

0 comments on commit ee6aa88

Please sign in to comment.