Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Minecraft extra F3 debug information
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.Vec3;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.ForgeSubscribe;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@Mod(modid="f3guidemo", name="F3GuiDemo", version="1.0.0")
@NetworkMod(clientSideRequired=true, serverSideRequired=false)
public class F3GuiDemo {
@EventHandler
public void load(FMLInitializationEvent event)
{
if(FMLCommonHandler.instance().getSide() == Side.CLIENT)
{
MinecraftForge.EVENT_BUS.register(this);
}
}
@SideOnly(Side.CLIENT)
@ForgeSubscribe
public void renderGameOverlayEvent(RenderGameOverlayEvent event)
{
if(event.type == ElementType.TEXT && RenderManager.instance.getFontRenderer() != null && Minecraft.getMinecraft().gameSettings.showDebugInfo)
{
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
Vec3 vec3 = player.getLookVec();
RenderManager.instance.getFontRenderer().drawStringWithShadow("X:"+(Math.abs(vec3.xCoord)<-0.0001?0:String.format("%.4f",vec3.xCoord)), 50, 20, 0xFFFFFF);
RenderManager.instance.getFontRenderer().drawStringWithShadow("Y:"+(Math.abs(vec3.yCoord)<-0.0001?0:String.format("%.4f",vec3.yCoord)), 50, 28, 0xFFFFFF);
RenderManager.instance.getFontRenderer().drawStringWithShadow("Z:"+(Math.abs(vec3.zCoord)<-0.0001?0:String.format("%.4f",vec3.zCoord)), 50, 36, 0xFFFFFF);
RenderManager.instance.getFontRenderer().drawStringWithShadow("yaw:"+player.rotationYaw, 50, 44, 0xFFFFFF);
RenderManager.instance.getFontRenderer().drawStringWithShadow("pitch:"+player.rotationPitch, 50, 52, 0xFFFFFF);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment