Jump to content

Drawing string to screen [SOLVED]


cookie545445

Recommended Posts

I'm probably missing something really obvious here, but I can't get a string to render on the screen. My aim is to get an update-every-tick meter of an NBT integer that only shows when you are wearing a certain helmet, but even just rendering the word "works" doesn't do anything.

 

FML (Tick) Event Handler

public class FMLEventHandler {

private Minecraft mc = Minecraft.getMinecraft();
private ScaledResolution sclRes;

public FMLEventHandler() {
	sclRes = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
}

@SubscribeEvent
public void render(RenderGameOverlayEvent event)
{
	mc.fontRenderer.drawString("works", sclRes.getScaledWidth()/2, sclRes.getScaledHeight()/2, 0xffffffff, false);
}
}

 

I've registered the handler like so:

FMLCommonHandler.instance().bus().register(new FMLEventHandler());

 

Any (working :D) help would be greatly appreciated!

Link to comment
Share on other sites

screen that is not modal

 

That's what "modal" means - the screen is on top and must be dismissed before play continues - and although I haven't done it myself and there are others here who would know more specifically... what about the HUD? It is a screen GUI I believe and game operates normally with it up.

 

 

edit: if nothing else, this is where I would look to find your answer. Do what the HUD does.

I'll need help, and I'll give help. Just ask, you know I will!

Link to comment
Share on other sites

I'm almost 100% sure RenderGameOverlayEvent is a forge event, so register it in MinecraftForge.EVENT_BUS. Don't forget to register it on the client side ONLY!

 

THANK YOU SO MUCH!!! I think I got it confused with the RenderTickEvent (on the FML bus) and it's not on the Forge Bus Event List so I put it on the FML bus. Also would this count as registering client side only?

@SideOnly(Side.CLIENT)
@SubscribeEvent
public void render(RenderGameOverlayEvent event)
{
	if (event.type == ElementType.TEXT) {
		mc.fontRenderer.drawString("works", 2, 2, 0xFFFFFFFF, false);
	}
}

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.