From 306e1436804f221ef24f7c4542c6d6fc63b79bd3 Mon Sep 17 00:00:00 2001 From: Ethryan <3237986+Ethryan@users.noreply.github.com> Date: Sat, 7 Jun 2025 10:07:53 +0200 Subject: [PATCH] Gui Stuff --- dependencies.gradle | 31 +-------- .../baubles/client/gui/GuiBaublesButton.java | 64 ++++++++++++------ .../java/baubles/client/gui/GuiEvents.java | 22 +++--- .../baubles/client/gui/GuiPlayerExpanded.java | 38 +++++++++-- .../textures/gui/bauble_background.png | Bin 0 -> 1320 bytes 5 files changed, 86 insertions(+), 69 deletions(-) create mode 100644 src/main/resources/assets/baubles/textures/gui/bauble_background.png diff --git a/dependencies.gradle b/dependencies.gradle index 53ccadc..f394b2f 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -1,32 +1,3 @@ -/* - * Add your dependencies here. Supported configurations: - * - api("group:name:version:classifier"): if you use the types from this dependency in the public API of this mod - * Available at runtime and compiletime for mods depending on this mod - * - implementation("g:n:v:c"): if you need this for internal implementation details of the mod, but none of it is visible via the public API - * Available at runtime but not compiletime for mods depending on this mod - * - compileOnly("g:n:v:c"): if the mod you're building doesn't need this dependency during runtime at all, e.g. for optional mods - * Not available at all for mods depending on this mod, only visible at compiletime for this mod - * - compileOnlyApi("g:n:v:c"): like compileOnly, but also visible at compiletime for mods depending on this mod - * Available at compiletime but not runtime for mods depending on this mod - * - runtimeOnlyNonPublishable("g:n:v:c"): if you want to include a mod in this mod's runClient/runServer runs, but not publish it as a dependency - * Not available at all for mods depending on this mod, only visible at runtime for this mod - * - runtimeOnly("g:n:v:c"): if you don't need this at compile time, but want it to be present at runtime - * Available at runtime for mods depending on this mod - * - annotationProcessor("g:n:v:c"): mostly for java compiler plugins, if you know you need this, use it, otherwise don't worry - * - testCONFIG("g:n:v:c") - replace CONFIG by one of the above (except api), same as above but for the test sources instead of main - * - * - shadowImplementation("g:n:v:c"): effectively the same as API, but the dependency is included in your jar under a renamed package name - * Requires you to enable usesShadowedDependencies in gradle.properties - * - * - compile("g:n:v:c"): deprecated, replace with "api" (works like the old "compile") or "implementation" (can be more efficient) - * - * You can exclude transitive dependencies (dependencies of the chosen dependency) by appending { transitive = false } if needed, - * but use this sparingly as it can break using your mod as another mod's dependency if you're not careful. - * - * Gradle names for some of the configuration can be misleading, compileOnlyApi and runtimeOnly both get published as dependencies in Maven, but compileOnly does not. - * The buildscript adds runtimeOnlyNonPublishable to also have a runtime dependency that's not published. - * - * For more details, see https://docs.gradle.org/8.0.1/userguide/java_library_plugin.html#sec:java_library_configurations_graph - */ dependencies { + runtimeOnlyNonPublishable("com.github.GTNewHorizons:NotEnoughItems:2.7.4-GTNH:dev") } diff --git a/src/main/java/baubles/client/gui/GuiBaublesButton.java b/src/main/java/baubles/client/gui/GuiBaublesButton.java index aba3e78..d27aa51 100644 --- a/src/main/java/baubles/client/gui/GuiBaublesButton.java +++ b/src/main/java/baubles/client/gui/GuiBaublesButton.java @@ -9,36 +9,58 @@ import net.minecraft.client.renderer.OpenGlHelper; public class GuiBaublesButton extends GuiButton { - public GuiBaublesButton(int p_i1021_1_, int p_i1021_2_, int p_i1021_3_, - int p_i1021_4_, int p_i1021_5_, String p_i1021_6_) { - super(p_i1021_1_, p_i1021_2_, p_i1021_3_, p_i1021_4_, p_i1021_5_, p_i1021_6_); - } - - public void drawButton(Minecraft mc, int xx, int yy) - { - if (this.visible) - { + public GuiBaublesButton(int buttonId, int xIn, int yIn, int widthIn, int heightIn, String resource) { + super(buttonId, xIn, yIn, widthIn, heightIn, resource); + } + + public void drawButton(Minecraft mc, int xx, int yy) { + + if (this.visible) { FontRenderer fontrenderer = mc.fontRenderer; - mc.getTextureManager().bindTexture(GuiPlayerExpanded.background); + mc.getTextureManager().bindTexture(GuiPlayerExpanded.gui_background); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); this.field_146123_n = xx >= this.xPosition && yy >= this.yPosition && xx < this.xPosition + this.width && yy < this.yPosition + this.height; - int k = this.getHoverState(this.field_146123_n); + int hover = this.getHoverState(this.field_146123_n); GL11.glEnable(GL11.GL_BLEND); OpenGlHelper.glBlendFunc(770, 771, 1, 0); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - - - if (k==1) { - this.drawTexturedModalRect(this.xPosition, this.yPosition, 200, 48, 10, 10); + + + if (hover == 1) { + this.drawTexturedModalRect(this.xPosition, this.yPosition, 50, 0, 14, 14); } else { - this.drawTexturedModalRect(this.xPosition, this.yPosition, 210, 48, 10, 10); - this.drawCenteredString(fontrenderer, this.displayString, - this.xPosition + 5, this.yPosition + this.height, 0xffffff); + this.drawTexturedModalRect(this.xPosition, this.yPosition, 50, 14, 14, 14); + + int k = 0; + int w = fontrenderer.getStringWidth(this.displayString); + + if (w > k) { + k = w; + } + + int j2 = this.xPosition + 20; + int k2 = this.yPosition - this.height; + int i1 = 8; + + int j1 = -267386864; + this.drawGradientRect(j2 - 3, k2 - 4, j2 + k + 3, k2 - 3, j1, j1); + this.drawGradientRect(j2 - 3, k2 + i1 + 3, j2 + k + 3, k2 + i1 + 4, j1, j1); + this.drawGradientRect(j2 - 3, k2 - 3, j2 + k + 3, k2 + i1 + 3, j1, j1); + this.drawGradientRect(j2 - 4, k2 - 3, j2 - 3, k2 + i1 + 3, j1, j1); + this.drawGradientRect(j2 + k + 3, k2 - 3, j2 + k + 4, k2 + i1 + 3, j1, j1); + int k1 = 1347420415; + int l1 = (k1 & 16711422) >> 1 | k1 & -16777216; + this.drawGradientRect(j2 - 3, k2 - 3 + 1, j2 - 3 + 1, k2 + i1 + 3 - 1, k1, l1); + this.drawGradientRect(j2 + k + 2, k2 - 3 + 1, j2 + k + 3, k2 + i1 + 3 - 1, k1, l1); + this.drawGradientRect(j2 - 3, k2 - 3, j2 + k + 3, k2 - 3 + 1, k1, k1); + this.drawGradientRect(j2 - 3, k2 + i1 + 2, j2 + k + 3, k2 + i1 + 3, l1, l1); + + this.drawString(fontrenderer, this.displayString, this.xPosition + 20, + this.yPosition - this.height, 0xffffff); } - + this.mouseDragged(mc, xx, yy); - - + } } diff --git a/src/main/java/baubles/client/gui/GuiEvents.java b/src/main/java/baubles/client/gui/GuiEvents.java index 87ebafa..422e98d 100644 --- a/src/main/java/baubles/client/gui/GuiEvents.java +++ b/src/main/java/baubles/client/gui/GuiEvents.java @@ -12,28 +12,28 @@ import net.minecraft.client.gui.inventory.GuiInventory; import net.minecraft.client.resources.I18n; import net.minecraftforge.client.event.GuiScreenEvent; -public class GuiEvents { - +public class GuiEvents { + @SideOnly(value = Side.CLIENT) @SubscribeEvent public void guiPostInit(GuiScreenEvent.InitGuiEvent.Post event) { if (event.gui instanceof GuiInventory || event.gui instanceof GuiPlayerExpanded) { - + int xSize = 176; int ySize = 166; - + int guiLeft = (event.gui.width - xSize) / 2; int guiTop = (event.gui.height - ySize) / 2; - + if (!event.gui.mc.thePlayer.getActivePotionEffects().isEmpty() && isNeiHidden()) { guiLeft = 160 + (event.gui.width - xSize - 200) / 2; } - - event.buttonList.add(new GuiBaublesButton(55, guiLeft + 66, guiTop + 9, 10, 10, + + event.buttonList.add(new GuiBaublesButton(55, guiLeft + 26, guiTop + 9, 10, 10, I18n.format((event.gui instanceof GuiInventory)?"button.baubles":"button.normal", new Object[0]))); } - + } @SideOnly(value = Side.CLIENT) @@ -45,7 +45,7 @@ public class GuiEvents { PacketHandler.INSTANCE.sendToServer(new PacketOpenBaublesInventory(event.gui.mc.thePlayer)); } } - + if (event.gui instanceof GuiPlayerExpanded) { if (event.button.id == 55) { event.gui.mc.displayGuiScreen(new GuiInventory(event.gui.mc.thePlayer)); @@ -53,7 +53,7 @@ public class GuiEvents { } } } - + static Method isNEIHidden; boolean isNeiHidden() { boolean hidden=true; @@ -63,7 +63,7 @@ public class GuiEvents { isNEIHidden = fake.getMethod("isHidden"); } hidden = (Boolean) isNEIHidden.invoke(null); - } catch(Exception ex) { } + } catch(Exception ex) { } return hidden; } } diff --git a/src/main/java/baubles/client/gui/GuiPlayerExpanded.java b/src/main/java/baubles/client/gui/GuiPlayerExpanded.java index 3547df7..56f7808 100644 --- a/src/main/java/baubles/client/gui/GuiPlayerExpanded.java +++ b/src/main/java/baubles/client/gui/GuiPlayerExpanded.java @@ -1,5 +1,8 @@ package baubles.client.gui; +import net.minecraft.client.gui.inventory.GuiInventory; +import net.minecraft.client.resources.I18n; +import net.minecraft.item.ItemStack; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; @@ -21,7 +24,9 @@ import net.minecraft.util.ResourceLocation; public class GuiPlayerExpanded extends InventoryEffectRenderer { - public static final ResourceLocation background = new ResourceLocation("baubles","textures/gui/bauble_inventory.png"); + public static final ResourceLocation gui_background = new ResourceLocation("baubles","textures/gui/bauble_background.png"); + + private static final ResourceLocation creative_inventory_tabs = new ResourceLocation("textures/gui/container/creative_inventory/tabs.png"); /** * x size of the inventory window in pixels. Defined as float, passed as int. @@ -40,7 +45,7 @@ public class GuiPlayerExpanded extends InventoryEffectRenderer { /** * Called from the main game loop to update the screen. */ - @Override + @Override public void updateScreen() { try { ((ContainerPlayerExpanded)inventorySlots).baubles.blockEvents = false; @@ -66,22 +71,41 @@ public class GuiPlayerExpanded extends InventoryEffectRenderer { ySizeFloat = (float)par2; } + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + this.fontRendererObj.drawString(I18n.format("container.crafting"), 86, 16, 4210752); + } + @Override protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.getTextureManager().bindTexture(background); + mc.getTextureManager().bindTexture(GuiInventory.field_147001_a); drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); + + + int upperHeight = 7 + BaubleExpandedSlots.slotsCurrentlyUsed() * 18; + this.mc.getTextureManager().bindTexture(gui_background); + this.drawTexturedModalRect(this.guiLeft - 26, this.guiTop + 4, 0, 0, 27, upperHeight); + final int slotOffset = 18; - final int slotStartX = guiLeft + 79; - final int slotStartY = guiTop + 7; + final int slotStartX = guiLeft - 26; + final int slotStartY = guiTop + 4; + + if (BaubleExpandedSlots.slotsCurrentlyUsed() <= 8 || !BaublesConfig.showUnusedSlots) { + this.drawTexturedModalRect(this.guiLeft - 26, this.guiTop + 4 + upperHeight, 0, 151, 27, 7); + } else { + this.drawTexturedModalRect(this.guiLeft - 42, this.guiTop + 4, 27, 0, 23, 158); + this.mc.getTextureManager().bindTexture(creative_inventory_tabs); + //this.drawTexturedModalRect(this.guiLeft - 34, this.guiTop + 12 + (int) (127f * this.currentScroll), 232, 0, 12, 15); + } //bauble slot backgrounds for (int slotIndex = 0; slotIndex < BaubleExpandedSlots.slotLimit; slotIndex++) { String slotType = BaubleExpandedSlots.getSlotType(slotIndex); - if(BaublesConfig.showUnusedSlots || !slotType.equals(BaubleExpandedSlots.unknownType)) { + if (BaublesConfig.showUnusedSlots || !slotType.equals(BaubleExpandedSlots.unknownType)) { //Slot slot = (Slot)inventorySlots.inventorySlots.get(slotIndex + 4); - drawTexturedModalRect(slotStartX + (slotOffset * (slotIndex / 4)), slotStartY + (slotOffset * (slotIndex % 4)), 200, 0, 18, 18); + drawTexturedModalRect(slotStartX + (slotOffset * slotIndex), slotStartY + (slotOffset * slotIndex), 200, 0, 18, 18); } } drawPlayerModel(guiLeft + 51, guiTop + 75, 30, (float)(guiLeft + 51) - xSizeFloat, (float)(guiTop + 25) - ySizeFloat, mc.thePlayer); diff --git a/src/main/resources/assets/baubles/textures/gui/bauble_background.png b/src/main/resources/assets/baubles/textures/gui/bauble_background.png new file mode 100644 index 0000000000000000000000000000000000000000..1bca05aa2c760cbc3ce3d1e3e6bf7a0ef255f6b3 GIT binary patch literal 1320 zcmeAS@N?(olHy`uVBq!ia0y~yU<5K5893O0R7}x|G$6&6|H(?D8gCb z5n0T@z%2~Ij105pNB{-dOFVsD*&j1Wu*(^(+A!UXfq`YKr;B4q#jUq@_UA=~%N+Q4 zf9)c^m%$G66eJV9r}5l7BfIW~R^^$7BM`EIVQ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