Minecraft fontRenderer.drawString() disappears instantly Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of Minecraft fontRenderer.drawString() disappears instantly without wasting too much if your time.

The question is published on by Tutorial Guruji team.

I tried to make a ingame GUI in minecraft with this function. (I’m using forge with MC 1.5.2).


Here’s my code:

public void onServerChat(ServerChatEvent event)
    mcObject.fontRenderer.drawStringWithShadow("Hello WOrld", 4, 4, 0xffFFFFFF);
    mcObject.ingameGUI.drawRect(2 /*X*/, 2 /*Y*/, 100 /*X1*/, 12 /*Y1*/, 0x80000000 /*COLOUR*/);

But when I type a chat message (just using that event for testing) the text disappears instantly and you can barely see it and certainly not read it.

I’m quite new to forge modding.

How to make a text more permanent and how you remove it again (or overwrite)?


onServerChat is an instantaneous event: it fires when the chat receives a message and immediately stops.

You will need to draw your GUI in an event that updates every frame. I have been doing it OnRenderExperienceBar, an element of Minecraft’s default GUI. Here’s an example using your code.

@SubscribeEvent(priority = EventPriority.NORMAL)
public void onRenderExperienceBar(RenderGameOverlayEvent event) {

mcObject.fontRenderer.drawStringWithShadow("Hello World", 4, 4, 0xffFFFFFF);
mcObject.ingameGUI.drawRect(2 /*X*/, 2 /*Y*/, 100 /*X1*/, 12 /*Y1*/, 0x80000000 /*COLOUR*/);

We are here to answer your question about Minecraft fontRenderer.drawString() disappears instantly - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji