From 160f3ae628525b80bbca85967a45f27eecceb1e3 Mon Sep 17 00:00:00 2001 From: somehussar <148253652+somehussar@users.noreply.github.com> Date: Wed, 8 Jul 2026 22:42:49 +0200 Subject: [PATCH] Create Guide button. --- .../java/noppes/npcs/client/ClientProxy.java | 2 + .../gui/guides/GuideController.java | 23 ++++++++++ .../client/tabs/InventoryTabGuides.java | 46 +++++++++++++++++++ 3 files changed, 71 insertions(+) create mode 100644 src/main/java/somehussar/gui/guides/GuideController.java create mode 100644 src/main/java/tconstruct/client/tabs/InventoryTabGuides.java diff --git a/src/main/java/noppes/npcs/client/ClientProxy.java b/src/main/java/noppes/npcs/client/ClientProxy.java index ce49e6eee..5fe12f95f 100644 --- a/src/main/java/noppes/npcs/client/ClientProxy.java +++ b/src/main/java/noppes/npcs/client/ClientProxy.java @@ -254,6 +254,7 @@ 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; @@ -390,6 +391,7 @@ public class ClientProxy extends CommonProxy { if (TabRegistry.getTabList().isEmpty()) { TabRegistry.registerTab(new InventoryTabVanilla()); } + GuideController.forceGuideButtonToBeFirst(); TabRegistry.registerTab(new InventoryTabCustomNpc()); } } diff --git a/src/main/java/somehussar/gui/guides/GuideController.java b/src/main/java/somehussar/gui/guides/GuideController.java new file mode 100644 index 000000000..c476e1411 --- /dev/null +++ b/src/main/java/somehussar/gui/guides/GuideController.java @@ -0,0 +1,23 @@ +package somehussar.gui.guides; + + +import tconstruct.client.tabs.InventoryTabGuides; +import tconstruct.client.tabs.TabRegistry; + +// TODO: THIS IS JUST THE CLIENT SIDE CONTROLLER +// NEED SERVER SIDE +public class GuideController { + private static boolean isGuideLoaded = true; + + public static boolean isGuideLoaded() { + return isGuideLoaded; + } + + public static void setGuideLoaded(boolean isGuideLoaded) { + GuideController.isGuideLoaded = isGuideLoaded; + } + + public static void forceGuideButtonToBeFirst() { + TabRegistry.getTabList().add(0, new InventoryTabGuides()); + } +} diff --git a/src/main/java/tconstruct/client/tabs/InventoryTabGuides.java b/src/main/java/tconstruct/client/tabs/InventoryTabGuides.java new file mode 100644 index 000000000..9669b9853 --- /dev/null +++ b/src/main/java/tconstruct/client/tabs/InventoryTabGuides.java @@ -0,0 +1,46 @@ +package tconstruct.client.tabs; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Gui; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; +import somehussar.gui.guides.GuideController; + +public class InventoryTabGuides extends AbstractTab { + private static final ResourceLocation HELP_TEXTURE = new ResourceLocation("customnpcs", "textures/marks/question.png"); + public InventoryTabGuides() { + super(0, 0, 0, null); + } + + @Override + public void onTabClicked() { + + } + + @Override + public boolean shouldAddToList() { + return GuideController.isGuideLoaded(); + } + + @Override + public void drawButton(Minecraft mc, int mouseX, int mouseY) { + if (this.visible) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int yTexPos = this.enabled ? 3 : 32; + int ySize = this.enabled ? 25 : 32; + int xOffset = this.id == 2 ? 0 : 1; + int yPos = this.yPosition + (this.enabled ? 3 : 0); + mc.renderEngine.bindTexture(super.texture); + this.drawTexturedModalRect(this.xPosition, yPos, xOffset * 28, + yTexPos, 28, ySize); + + this.zLevel = 100.0F; + + mc.renderEngine.bindTexture(HELP_TEXTURE); + func_146110_a(xPosition + 6, yPosition + 8, 0, 0, 16, 16, 16, 16); + + this.zLevel = 0.0F; + + } + } +}