Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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!

  • 2 months later...

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

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 :D

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.