Posted March 24, 20187 yr Hello! So my block needs water to run (ex. raining/water buckets, etc) and I have a popup next to the gui inventory that shows that it needs one: I want it to have the functionality for when you hover over it, it creates a text box saying "Needs water!" or something like that. I want the text box to be similar to the ones found when you hover over an item. Thank you! Edited March 25, 20187 yr by Lambda The issue has not actually been solved Relatively new to modding. Currently developing: https://github.com/LambdaXV/DynamicGenerators
March 24, 20187 yr drawHoveringText Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
March 24, 20187 yr Author Yes I found this function, however is there a method to detect where the mouse is and display the hover box when its only over that area? Relatively new to modding. Currently developing: https://github.com/LambdaXV/DynamicGenerators
March 24, 20187 yr Buttons do this already. Just make that area a button. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
March 24, 20187 yr Author Okay, and how do I set the button to not "highlight" itself and set the texture to what I have it as now? Relatively new to modding. Currently developing: https://github.com/LambdaXV/DynamicGenerators
March 24, 20187 yr https://github.com/Draco18s/ReasonableRealism/blob/1.12.1/src/main/java/com/draco18s/industry/client/gui/GuiContainerFilter.java#L165 Take a look at what I did Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
March 24, 20187 yr Author Ah perfect! Thanks for that! Relatively new to modding. Currently developing: https://github.com/LambdaXV/DynamicGenerators
March 25, 20187 yr Author Okay, so I got the button half working. Its there and it clicks, but no hovering text. Aswell, how would I make the button go away when x condition is met: Here is what I have so far: Spoiler @SideOnly(Side.CLIENT) public class GuiVoidInfuser extends GuiContainerMod { private static final ResourceLocation RES_LOC = ResourceUtil.getGuiLocation("gui_voidInfuser"); private final TileEntityVoidInfuser tileVoidInfuser; public static GuiVoidInfuser self; private float tickTime; private HintButton needsWater; public GuiVoidInfuser(InventoryPlayer inventoryPlayer, TileEntityBase tile){ this(inventoryPlayer, tile, false); } private GuiVoidInfuser(InventoryPlayer inventory, TileEntityBase tile, boolean isDouble){ super(new ContainerVoidInfuser(inventory, tile)); this.tileVoidInfuser = (TileEntityVoidInfuser)tile; this.xSize = 176; this.ySize = 179; self = this; } @Override public void initGui(){ super.initGui(); this.needsWater = new HintButton(0, this.guiLeft+148, this.guiTop+42); this.buttonList.add(this.needsWater); } @Override public void updateScreen(){ super.updateScreen(); } @Override public void drawScreen(int x, int y, float f){ super.drawScreen(x, y, f); } @Override public void drawGuiContainerForegroundLayer(int x, int y){ ResourceUtil.displayNameString(this.fontRenderer, this.xSize, -10, this.tileVoidInfuser); } @Override public void drawGuiContainerBackgroundLayer(float f, int x, int y){ GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(ResourceUtil.GUI_INVENTORY_LOCATION); this.drawTexturedModalRect(this.guiLeft, this.guiTop+93, 0, 0, 176, 86); this.mc.getTextureManager().bindTexture(RES_LOC); this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93); if(this.tileVoidInfuser.hasWater == false){ this.drawTexturedModalRect(this.guiLeft+148, this.guiTop+42, 180, 0, 19, 18); }else { this.tickTime = (55.00F / (float)this.tileVoidInfuser.runtime) * 100.00F; //55 ticks being MOST efficient this.fontRenderer.drawString((int)(this.tickTime) + "%", this.guiLeft+142, this.guiTop+75, StringUtil.COLOR_WHITE); } } public void drawText(List text, int x, int y) { this.drawHoveringText(text, x, y); } @SideOnly(Side.CLIENT) static class HintButton extends GuiButton { protected HintButton(int buttonID, int posx, int posy) { super(buttonID, posx, posy, 18, 19, ""); } @Override public void drawButton(Minecraft mc, int mouseX, int mouseY, float partialTicks) { if (this.visible) { mc.getTextureManager().bindTexture(RES_LOC); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); this.hovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height; this.drawTexturedModalRect(this.x, this.y, 0, 182, this.width, this.height); } } @Override public void drawButtonForegroundLayer(int x, int y) { List list = new ArrayList<String>(); list.add(I18n.format("ce:voidIF_water")); GuiVoidInfuser.self.drawText(list, x, y); } } } It follows your code's basic principal and it still doesn't work; as well, what I mean by condition x is this: if(this.tileVoidInfuser.hasWater == false){ this.drawTexturedModalRect(this.guiLeft+148, this.guiTop+42, 180, 0, 19, 18); }else { this.tickTime = (55.00F / (float)this.tileVoidInfuser.runtime) * 100.00F; //55 ticks being MOST efficient this.fontRenderer.drawString((int)(this.tickTime) + "%", this.guiLeft+142, this.guiTop+75, StringUtil.COLOR_WHITE); } If hasWater is false, it displays that little icon -- I want the button to also appear/disappear with that. Thanks -- Nevermind! I found my error, I didn't iterate through the ubttons to check if the mouse is over! Thanks for my help. and this is the fix: Spoiler Iterator<GuiButton> iterator = this.buttonList.iterator(); while (iterator.hasNext()) { GuiButton guibutton = iterator.next(); if (guibutton.isMouseOver()) { guibutton.drawButtonForegroundLayer(x- this.guiLeft, y - this.guiTop); break; } } Edited March 25, 20187 yr by Lambda fixed Relatively new to modding. Currently developing: https://github.com/LambdaXV/DynamicGenerators
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.