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 was pretty happy when I got my mod working, but then I noticed this strange rendering bug.

It looks like as if the font texture overrides the HUD elements texture.

swfLMN8.png

Here's my code:

Helper.java

 

 

package at.diekiste.helper;

import java.io.File;

import net.minecraft.client.Minecraft;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.common.MinecraftForge;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;

@Mod(modid = Helper.MODID, version = Helper.VERSION)
public class Helper {

public static final String MODID = "helper";
public static final String VERSION = "0.1 Beta";
public boolean showFPS = true;
@Instance(MODID)
public static Helper instance;
public HelperOverlay overlay;

@EventHandler
public void preInit(FMLPreInitializationEvent event)
{
	this.instance = this;
}

@EventHandler
public void init(FMLInitializationEvent event)
{
	this.overlay = new HelperOverlay(Minecraft.getMinecraft(), this);
}

@EventHandler
public void postInit(FMLPostInitializationEvent event)
{
	MinecraftForge.EVENT_BUS.register(overlay);
}
}

 

 

HelperOverlay.java

 

 

package at.diekiste.helper;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;

public class HelperOverlay {

private Minecraft mc;
private DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
private String timeString, fpsString;
private Helper helper;

public HelperOverlay(Minecraft mc, Helper helper)
{
	this.mc = mc;
	this.helper = helper;
}

@SubscribeEvent
public void renderGameOverlay(RenderGameOverlayEvent event)
{
	timeString = dateFormat.format(new Date());
	fpsString = mc.debug.split(",")[0].toUpperCase();
	if(!mc.gameSettings.showDebugInfo)
	{
		mc.fontRenderer.drawStringWithShadow(timeString, 4, 4, 0xffffffff);
		mc.fontRenderer.drawStringWithShadow(fpsString, 4, 4 + mc.fontRenderer.FONT_HEIGHT + 2, 0xffffffff);
	}
}

}

 

 

 

 

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.