From 28b92396d05ab2f664929cde311bded6488227d1 Mon Sep 17 00:00:00 2001 From: Kam Date: Thu, 14 Mar 2024 01:32:50 -0400 Subject: [PATCH] Add Special Icons to Side Buttons for Inventory --- .../player/inventory/GuiCNPCInventory.java | 28 ++++++++++++++---- .../client/gui/util/GuiMenuSideButton.java | 17 +++++++++-- .../assets/customnpcs/textures/gui/icons.png | Bin 0 -> 1126 bytes 3 files changed, 37 insertions(+), 8 deletions(-) create mode 100644 src/main/resources/assets/customnpcs/textures/gui/icons.png diff --git a/src/main/java/noppes/npcs/client/gui/player/inventory/GuiCNPCInventory.java b/src/main/java/noppes/npcs/client/gui/player/inventory/GuiCNPCInventory.java index 9777cd999..b8870861a 100644 --- a/src/main/java/noppes/npcs/client/gui/player/inventory/GuiCNPCInventory.java +++ b/src/main/java/noppes/npcs/client/gui/player/inventory/GuiCNPCInventory.java @@ -1,6 +1,7 @@ package noppes.npcs.client.gui.player.inventory; import net.minecraft.client.Minecraft; +import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import noppes.npcs.CustomItems; @@ -12,6 +13,8 @@ import tconstruct.client.tabs.TabRegistry; public class GuiCNPCInventory extends GuiNPCInterface { private final ResourceLocation resource = new ResourceLocation("customnpcs","textures/gui/standardbg.png"); + public static final ResourceLocation specialIcons = new ResourceLocation("customnpcs","textures/gui/icons.png"); + public static int activeTab = 0; private Minecraft mc = Minecraft.getMinecraft(); @@ -26,25 +29,38 @@ public class GuiCNPCInventory extends GuiNPCInterface { super.initGui(); guiTop +=10; - GuiMenuSideButton questsButton = new GuiMenuSideButton(100, guiLeft + xSize + 37, this.guiTop + 3, 22, 22, ""); + int y = 3; + GuiMenuSideButton questsButton = new GuiMenuSideButton(100, guiLeft + xSize + 37, this.guiTop + y, 22, 22, ""); questsButton.rightSided = true; questsButton.active = activeTab == 0; - questsButton.renderStack = new ItemStack(CustomItems.letter); + questsButton.renderIconPosX = 32; + questsButton.renderResource = specialIcons; addButton(questsButton); - GuiMenuSideButton partyButton = new GuiMenuSideButton(101, guiLeft + xSize + 37, this.guiTop + 3 + 21, 22, 22, ""); + y += 21; + GuiMenuSideButton partyButton = new GuiMenuSideButton(101, guiLeft + xSize + 37, this.guiTop + y, 22, 22, ""); partyButton.rightSided = true; partyButton.active = activeTab == 1; - partyButton.renderStack = new ItemStack(CustomItems.bag); + partyButton.renderResource = specialIcons; addButton(partyButton); if(ConfigClient.enableFactionTab){ - GuiMenuSideButton factionButton = new GuiMenuSideButton(102, guiLeft + xSize + 37, this.guiTop + 3 + 21*2, 22, 22, ""); + y += 21; + GuiMenuSideButton factionButton = new GuiMenuSideButton(102, guiLeft + xSize + 37, this.guiTop + y, 22, 22, ""); factionButton.rightSided = true; factionButton.active = activeTab == 2; - factionButton.renderStack = new ItemStack(CustomItems.wallBanner); + factionButton.renderIconPosX = 48; + factionButton.renderResource = specialIcons; addButton(factionButton); } + + y += 21; + GuiMenuSideButton clientButton = new GuiMenuSideButton(101, guiLeft + xSize + 37, this.guiTop + y, 22, 22, ""); + clientButton.rightSided = true; + clientButton.active = activeTab == 3; + clientButton.renderIconPosX = 16; + clientButton.renderResource = specialIcons; + addButton(clientButton); } @Override diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiMenuSideButton.java b/src/main/java/noppes/npcs/client/gui/util/GuiMenuSideButton.java index 99fdb45c8..866d763d7 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiMenuSideButton.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiMenuSideButton.java @@ -6,6 +6,7 @@ import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.entity.RenderItem; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; +import noppes.npcs.client.gui.player.inventory.GuiCNPCInventory; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; @@ -16,6 +17,9 @@ public class GuiMenuSideButton extends GuiNpcButton{ public boolean active; public boolean rightSided; public ItemStack renderStack; + public ResourceLocation renderResource; + public int renderIconPosX = 0; + public int renderIconPosY = 0; public GuiMenuSideButton(int id, int x, int y, String s){ this(id, x, y, 200, 20, s); @@ -54,6 +58,15 @@ public class GuiMenuSideButton extends GuiNpcButton{ } mouseDragged(minecraft, i, j); + // Render Custom Icon + if (this.renderResource != null) { + this.zLevel = 100.0F; + minecraft.renderEngine.bindTexture(renderResource); + drawTexturedModalRect(xPosition + 2, yPosition + height/2 - 8, renderIconPosX, renderIconPosY, 16, 16); + this.zLevel = 0.0F; + } + + if (this.renderStack != null) { RenderHelper.enableGUIStandardItemLighting(); this.zLevel = 100.0F; @@ -71,7 +84,7 @@ public class GuiMenuSideButton extends GuiNpcButton{ this.zLevel = 0.0F; RenderHelper.disableStandardItemLighting(); } - + String text = ""; float maxWidth = width * 0.75f; if(fontrenderer.getStringWidth(displayString) > maxWidth){ @@ -102,7 +115,7 @@ public class GuiMenuSideButton extends GuiNpcButton{ @Override public void mouseReleased(int i, int j){ - + } @Override diff --git a/src/main/resources/assets/customnpcs/textures/gui/icons.png b/src/main/resources/assets/customnpcs/textures/gui/icons.png new file mode 100644 index 0000000000000000000000000000000000000000..80d28fa9b3c86191ba30fdef2ee8d5293c94475a GIT binary patch literal 1126 zcmeAS@N?(olHy`uVBq!ia0y~yU<5K58911MRQ8&P5D>38$lZxy-8q?;Kn_c~qpu?a z!^VE@KZ&eBer$kGh^wBiiBhsf1~0FSL-*7vGn11tj3x%@xBJM3=x?;PcCCKlSbW1G zWsjhGNNh|}P+*v=i|0yp_1R)#7UotK3!?x3|Nr6rdy|;8ygWP=qN19mPHqAMYO2~2 z5;8y=o<7f!08;WLL4LtNm3RQdS;;a1pi<5PkH}&M2EM}}%y>M1MG6B0bGoOCV@O5Z z+i3@rW;uwsGA=%%!ZlIKRPE3I^k;i#CSTUsbt34UEjM3l*+;*2$=Q)}{`chWnpCufMxUx{jfn#aOLf9^=8K(e_Si}V%vIe9s%wL zCENn6-<&V^Jg(5I&oQ@Wdh)0JbP|_K!&N<|Jt+-4PP_Y_k?&%NRCvChwW5B`dQ*pY zEI+5epQkpxzHeXm>EJrHjjV4@@3QE>EW%pE{^GY)J*U8D_lBi4?1Bp0_FsJ|Qtfc> z=;S{Pr&cFs89B_CPGGChXFT<1dJOw?)j8}nOkYKI)G{3wXr3?s?W^z)b%!}EXTMh2 zmQ0^xuO0I_{*LiRCcmHc^Orl^o0{%i_iv*>(LbF4P40v|yJtUd#U@EUdHU{oI=_O$ zP3BM1GnN(JIBpohmD2G2arBw__N_(-WL7Vj^!~l{w}v9FE4B%J&JSwlCGk$tRme#G z#uHG-RaY}Dy<3s#%3FQr577$G?93}yes*v4xnTF~4>ykh`-8lx#}jsb`ceJE%P0O= zd{RUFr=Oe8-2MET!TT`d1|7bJ)ItWGZsvqY8HUr37$U^j4{Wkvn09njY9K