Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.7.10]Display liquid and mB when hovered over in gui?


Recommended Posts

In mods such as Tinker's Construct and Thermal Expansion when you hover over a liquid in a gui it tells you the name of the liquid and the amount in mB. How is this accomplished?

Legend of Zelda Mod[updated September 20th to 3.1.1]

Extra Achievements(Minecraft 1.8!)[updated April 3rd to 2.3.0]

Fancy Cheeses[updated May 8th to 0.5.0]

Link to post
Share on other sites

To accomplish this, you'll need to check where the mouse is on the screen then, draw the tooltip. Considering this took me hours of research to figure out a few months back; here's some code to help you out. :P

 

public void drawToolTips(int mouseX, int mouseY) {
    int boxX = (this.width - this.xSize) / 2; //These are just like the center of the screen. 
    int boxY = (this.height - this.ySize) / 2;//You make these in order to get a starting point on where to check (With these, it would be the top left of your GUI)

	int defaultX = 16; //These are like the boxes of the area to check.
	int defaultY = 16; //So, if you're rendering an Item to hover over, it would be 16x16. 

	//This checks if the mouse is in the correct position on screen. You can add and subtract from boxX and Y to determine where to be.
	if(mouseX > boxX && mouseX < boxX + defaultX && mouseY > boxY && mouseY < boxY + defaultY) { 
                           List list = new ArrayList(); //Just the list of text to be added. It is just like the addInformation method now. 
                           list.add("SOMETHING") //Each time you add something, it's gonna be a new line in the tooltip.
                           this.drawHoveringText(list, mouseX, mouseY, fontRenderer);
	}
}

 

Then you just add that method in your drawScreen AFTER calling super.drawScreen(). If you add it before, you will get some pretty weird rendering errors. The first two params of drawScreen are the mouseX and mouseY so use those. :P Hope it helped!

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Link to post
Share on other sites

where do i get fontRenderer from?

Edit: Found it, It's ment to be fontRendererObj

Legend of Zelda Mod[updated September 20th to 3.1.1]

Extra Achievements(Minecraft 1.8!)[updated April 3rd to 2.3.0]

Fancy Cheeses[updated May 8th to 0.5.0]

Link to post
Share on other sites

Minecraft.getMinecraft().getFontRenderer() or getFontRendererObj()

 

Or you know, if you are using some kind of GUI - 1st check if there is no ready-to-use fontRenderer or Minecraft instance reference.

1.7.10 is no longer supported by forge, you are on your own.

Link to post
Share on other sites

If you extend GuiScreen you get a ready-to-use instance of Minecraft. Just thought I'd point it out. :P

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • For some reason my Minecraft server is not letting me take any type of damage, and not only that, but I've configured the server to make normally crashing entities to dissapear instead, to try and look at what the error might be. For some reason, Entities will become corrupted when trying to hurt me. Here I give you the crash report: java.lang.NoSuchMethodError: net.minecraft.entity.player.InventoryPlayer.func_70440_f(I)Lnet/minecraft/item/ItemStack;     at com.lying.variousoddities.utility.bus.VOBusServer.onPlayerBreakArmorEventPre(VOBusServer.java:878)     at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_728_VOBusServer_onPlayerBreakArmorEventPre_LivingHurtEvent.invoke(.dynamic)     at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90)     at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182)     at net.minecraftforge.common.ForgeHooks.onLivingHurt(ForgeHooks.java:604)     at net.minecraft.entity.player.EntityPlayer.func_70665_d(EntityPlayer.java:1120)     at net.minecraft.entity.EntityLivingBase.func_70097_a(EntityLivingBase.java:926)     at net.minecraft.entity.player.EntityPlayer.func_70097_a(EntityPlayer.java:1038)     at net.minecraft.entity.player.EntityPlayerMP.func_70097_a(EntityPlayerMP.java:645)     at micdoodle8.mods.galacticraft.core.entities.player.GCEntityPlayerMP.func_70097_a(GCEntityPlayerMP.java:68)     at drzhark.mocreatures.entity.MoCEntityAnimal.func_70652_k(MoCEntityAnimal.java:1123)     at drzhark.mocreatures.entity.passive.MoCEntitySnake.func_70652_k(MoCEntitySnake.java:460)     at net.minecraft.entity.ai.EntityAIAttackMelee.func_190102_a(EntityAIAttackMelee.java:178)     at net.minecraft.entity.ai.EntityAIAttackMelee.func_75246_d(EntityAIAttackMelee.java:167)     at net.minecraft.entity.ai.EntityAITasks.func_75774_a(SourceFile:129)     at net.minecraft.entity.EntityLiving.func_70626_be(EntityLiving.java:763)     at net.minecraft.entity.EntityLivingBase.func_70636_d(EntityLivingBase.java:2359)     at net.minecraft.entity.EntityLiving.func_70636_d(EntityLiving.java:577)     at net.minecraft.entity.EntityAgeable.func_70636_d(EntityAgeable.java:178)     at net.minecraft.entity.passive.EntityAnimal.func_70636_d(SourceFile:43)     at drzhark.mocreatures.entity.MoCEntityAnimal.func_70636_d(MoCEntityAnimal.java:359)     at drzhark.mocreatures.entity.MoCEntityTameableAnimal.func_70636_d(MoCEntityTameableAnimal.java:435)     at drzhark.mocreatures.entity.passive.MoCEntitySnake.func_70636_d(MoCEntitySnake.java:415)     at net.minecraft.entity.EntityLivingBase.func_70071_h_(EntityLivingBase.java:2179)     at net.minecraft.entity.EntityLiving.func_70071_h_(EntityLiving.java:295)     at drzhark.mocreatures.entity.passive.MoCEntitySnake.func_70071_h_(MoCEntitySnake.java:265)     at net.minecraft.world.World.func_72866_a(World.java:1996)     at net.minecraft.world.WorldServer.func_72866_a(WorldServer.java:832)     at net.minecraft.world.World.func_72870_g(World.java:1958)     at net.minecraft.world.World.func_72939_s(World.java:1762)     at net.minecraft.world.WorldServer.func_72939_s(WorldServer.java:613)     at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:767)     at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:397)     at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:668)     at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:526)     at java.lang.Thread.run(Unknown Source) I can also link the whole log if this doesn't help. Thank you.
    • Hello! I want to make a 'sky block'. I just want to render the sky in it. How can I do that ? Here is a screenshot Thanks in advance !
    • Now the problem has been solved. Thank you. I mistook (!world.isClientSide) in the vanilla MinecartItem class for (world.isClientSide).
    • You cannot reliably do this. What you can do is try to find out by looking through ModList#getModFiles and check where the class came from. But this is unreliable, which is why for example @EventBusSubscriber requires you to specify the ModID.
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.