So, I've been trying to figure this out for the past few hours, but the documentation is extremely sparse and I haven't been able to figure this out.
I want to write some text to the screen, kind of like an FPS meter. Unfortunately for me, my mod currently doesn't display anything at all. There aren't any errors, and from what I have been able to find, the way I'm going about this is correct.
I'm using Minecraft 1.11.2.
Here's the code in question:
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.Gui;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
@Mod.EventBusSubscriber
public class MessageGui extends Gui {
private static String text = "Test Text";
private static int color = 0xFFFFFF;
private FontRenderer fontRenderer;
private void verifyRenderer() {
if (fontRenderer != null) return;
Minecraft minecraft = Minecraft.getMinecraft();
fontRenderer = minecraft.fontRendererObj;
}
@SubscribeEvent
public void render(RenderGameOverlayEvent.Post event) {
verifyRenderer();
fontRenderer.drawStringWithShadow(text, 10, 20, color);
}
}
As far as I've been told, @Mod.EventBusSubscriber and @SubscribeEvent should automatically subscribe the RenderGameOverlayEvent to the correct bus... but it's not doing anything at all. Can someone tell me what I'm missing here?
EDIT: I AM creating an instance of this class in my mod's init() function. There shouldn't be a reason for this not to work.