Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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:

f9d9489d0a1a75d1dffc61751e041381.png

 

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 by Lambda
The issue has not actually been solved

Relatively new to modding.

Currently developing:

https://github.com/LambdaXV/DynamicGenerators

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.

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.

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.

  • 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 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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.