From a591fef66e6f8719f7332afce2ccf695e03f9600 Mon Sep 17 00:00:00 2001 From: somehussar <148253652+somehussar@users.noreply.github.com> Date: Thu, 9 Jul 2026 00:45:19 +0200 Subject: [PATCH] Change tab setup process --- .../java/noppes/npcs/client/ClientProxy.java | 37 ++++++++++++++----- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/src/main/java/noppes/npcs/client/ClientProxy.java b/src/main/java/noppes/npcs/client/ClientProxy.java index 5fe12f95f..881c5fd7e 100644 --- a/src/main/java/noppes/npcs/client/ClientProxy.java +++ b/src/main/java/noppes/npcs/client/ClientProxy.java @@ -254,15 +254,13 @@ import noppes.npcs.items.ItemNpcTool; import noppes.npcs.items.ItemScripted; import noppes.npcs.scripted.item.ScriptCustomItem; import org.lwjgl.input.Keyboard; -import somehussar.gui.guides.GuideController; -import tconstruct.client.tabs.InventoryTabCustomNpc; -import tconstruct.client.tabs.InventoryTabVanilla; -import tconstruct.client.tabs.TabRegistry; +import tconstruct.client.tabs.*; import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; +import java.util.List; import java.util.Random; public class ClientProxy extends CommonProxy { @@ -387,15 +385,34 @@ public class ClientProxy extends CommonProxy { MinecraftForge.EVENT_BUS.register(new LightningHandler()); if (ConfigClient.InventoryGuiEnabled) { - MinecraftForge.EVENT_BUS.register(new TabRegistry()); - if (TabRegistry.getTabList().isEmpty()) { - TabRegistry.registerTab(new InventoryTabVanilla()); - } - GuideController.forceGuideButtonToBeFirst(); - TabRegistry.registerTab(new InventoryTabCustomNpc()); + setupTabs(); } } + private void setupTabs() { + MinecraftForge.EVENT_BUS.register(new TabRegistry()); + + ensureInventoryTabIsFirst(); + + TabRegistry.getTabList().add(1, new InventoryTabGuides()); + TabRegistry.registerTab(new InventoryTabCustomNpc()); + } + + private void ensureInventoryTabIsFirst() { + List tabList = TabRegistry.getTabList(); + + // Find the first inventory tab or create one. + InventoryTabVanilla vanillaTab = tabList.stream() + .filter(InventoryTabVanilla.class::isInstance) + .map(InventoryTabVanilla.class::cast) + .findFirst() + .orElseGet(InventoryTabVanilla::new); + + // Move the inventory tab to be the FIRST in the list no matter what. + tabList.remove(vanillaTab); + tabList.add(0, vanillaTab); + } + public FakePlayer getCommandPlayer(IWorld world) { return (FakePlayer) (new EntityCustomNpc(world.getMCWorld())).getFakePlayer(); }