Posted February 13, 201411 yr I've searched far and wide to find a way to draw text to the screen and I have found the following so far, that is unfortunately not working correctly: I have a TickEventHandler.java, that is registered through FMLCommonHandler.instance().bus(). My event handler gets called (if I write to the console from there, the console gets flooded), but the text is nowhere to be seen. My question is: how can I draw text to the screen, preferably showing only when in a game (not in menu screens) like the data shown when F3 is pressed? Thanks!
April 22, 201411 yr I'm wondering this too, Minecraft.GetMinecraft().fontRenderer is always null for me, and I don't know how to get it Creator of Metroid Cubed! Power Suits, Beams, Hypermode and more! http://i.imgur.com/ghgWmA3.jpg[/img]
April 22, 201411 yr package something; import net.minecraft.client.gui.Gui; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType; import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.common.eventhandler.EventPriority; import cpw.mods.fml.common.eventhandler.SubscribeEvent; public class MyClass extends Gui { @SubscribeEvent(priority = EventPriority.NORMAL) public void hej(RenderGameOverlayEvent event) { if (event.isCancelable() || event.type != ElementType.EXPERIENCE) { return; } drawString(FMLClientHandler.instance().getClient().fontRenderer, "heeeejjjjj", 40, 40, 0xffffff); } } Mainmod: MinecraftForge.EVENT_BUS.register(new MyClass()); My mod for futher awesomeness: http://www.minecraftforum.net/topic/1714396-the-decopack-collection-v010-wip-made-a-signature-new-snapshot-1-screenshots-are-up-small-snapshot-1-is-out-for-147/#entry21250399
April 22, 201411 yr I have a cheaty way of doing this. Not most simple, but works. Registration: MinecraftForge.EVENT_BUS.register(new IngameText(Minecraft.getMinecraft())); IngameText class: //you can add package and imports public class IngameText extends Gui { private Minecraft mc; public IngameText(Minecraft mc) { super(); this.mc = mc; } @SubscribeEvent public void renderScreen(RenderGameOverlayEvent.Post event) { if (event.isCancelable() || event.type != ElementType.TEXT) { return; } render(mc); } public void render(Minecraft minecraft) { minecraft.fontRenderer.drawString(//add your fields); } } Like I said, this is like the worst way to do it, but it works
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.