Jump to content

Recommended Posts

Posted

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!

Posted

Why don't you just make a gui screen that is not modal, etc, and draw it there? Maybe there's something I don't know about guis but wouldn't that work?

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

Posted

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!

Posted

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);
	}
}

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.