Gui Stuff

This commit is contained in:
Ethryan committed 2025-06-07 10:07:53 +02:00
1 parent ea2485b2ed
commit 306e143680
5 files changed
+86 -69

No files matched your search

@@ -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);
}
}
+11 -11
View File
@@ -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;
}
}
@@ -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);