From e7c9ab6617a2b7a5a9b86bca7db2732ebb411af0 Mon Sep 17 00:00:00 2001
From: Reece Mackie <20544390+rover656@users.noreply.github.com>
Date: Mon, 21 Oct 2024 09:38:25 +0100
Subject: [PATCH] fix: Add operator tab to common group list and filter for
 visible tabs in getPageCount. (#4172)

(cherry picked from commit 6823f7cd48313cd8dff25635b7031bfbffef08c3)
---
 .../impl/client/itemgroup/FabricCreativeGuiComponents.java    | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fabric-item-group-api-v1/src/client/java/net/fabricmc/fabric/impl/client/itemgroup/FabricCreativeGuiComponents.java b/fabric-item-group-api-v1/src/client/java/net/fabricmc/fabric/impl/client/itemgroup/FabricCreativeGuiComponents.java
index 9c63eb652..c3a37d3ec 100644
--- a/fabric-item-group-api-v1/src/client/java/net/fabricmc/fabric/impl/client/itemgroup/FabricCreativeGuiComponents.java
+++ b/fabric-item-group-api-v1/src/client/java/net/fabricmc/fabric/impl/client/itemgroup/FabricCreativeGuiComponents.java
@@ -37,12 +37,12 @@ import net.fabricmc.fabric.impl.itemgroup.FabricItemGroupImpl;
 public class FabricCreativeGuiComponents {
 	private static final Identifier BUTTON_TEX = Identifier.of("fabric", "textures/gui/creative_buttons.png");
 	private static final double TABS_PER_PAGE = FabricItemGroupImpl.TABS_PER_PAGE;
-	public static final Set<ItemGroup> COMMON_GROUPS = Set.of(ItemGroups.SEARCH, ItemGroups.INVENTORY, ItemGroups.HOTBAR).stream()
+	public static final Set<ItemGroup> COMMON_GROUPS = Set.of(ItemGroups.SEARCH, ItemGroups.INVENTORY, ItemGroups.HOTBAR, ItemGroups.OPERATOR).stream()
 			.map(Registries.ITEM_GROUP::getValueOrThrow)
 			.collect(Collectors.toSet());
 
 	public static int getPageCount() {
-		return (int) Math.ceil((ItemGroups.getGroupsToDisplay().size() - COMMON_GROUPS.size()) / TABS_PER_PAGE);
+		return (int) Math.ceil((ItemGroups.getGroupsToDisplay().size() - COMMON_GROUPS.stream().filter(ItemGroup::shouldDisplay).count()) / TABS_PER_PAGE);
 	}
 
 	public static class ItemGroupButtonWidget extends ButtonWidget {