Jump to content

Adding text to chest with a specific name


Coder

Recommended Posts

I need to add text to the chest window when the name of the chest is equal to something.

I guess I need an event that fires every tick or so when you are inside a chest, and then render the text somehow above it.

Are there any good examples of the events I need to use in order to achieve something like this?

Link to comment
Share on other sites

45 minutes ago, diesieben07 said:

GuiScreenEvent.DrawScreenEvent.

 

@EventHandler
    public void renderChest(DrawScreenEvent e) {
    	if (e.getGui() instanceof GuiChest) {
	    	System.out.println("ok");
    	}
    }

Doesn't work for some reason

Link to comment
Share on other sites

Just now, diesieben07 said:

You have shown zero of your code.

ScaledResolution sr = new ScaledResolution(mc);
	    	String displayGUIText = "This is a place-holder";
	    	e.getGui().drawString(mc.fontRenderer, displayGUIText, sr.getScaledWidth() / 2 - mc.fontRenderer.getStringWidth(displayGUIText) / 2, sr.getScaledHeight() / 2 - 85, 0xFFFFFF);
	    	

 

just some basic font render stuff, it's all inside the event listener I sent earlier. (DrawScreenEvent.Post)

Link to comment
Share on other sites

11 minutes ago, diesieben07 said:

You need to set the GL color to white.

I don't think I really know how to do this, do you have an example of this?

GL11.glColor4f(1, 1, 1, 1);

This is what I found but it does nothing.

 

Also, can I get the chest's custom name from this event?

Link to comment
Share on other sites

13 minutes ago, diesieben07 said:

Use GLStateManager.color. You might also need RenderHelper.disableStandardItemLighting (and RenderHelper.enableStandardItemLighting after you are done).

 

Sure.

Awesome it worked. I am fiddling around trying to figure out how to get the custom chest name. Should it be inside getGui()?

Link to comment
Share on other sites

9 minutes ago, diesieben07 said:

GuiChest already draws the name, look at it.

I checked GuiChest by itself and what e.getGui() gives, also e.getGui().getClass() , couldn't find it. I'm probably not even close

 

Link to comment
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.
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...

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

Announcements



×
×
  • Create New...

Important Information

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