Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.ignatio.wilsonsanity;
- import java.text.DecimalFormat;
- import cpw.mods.fml.common.eventhandler.EventPriority;
- import cpw.mods.fml.common.eventhandler.SubscribeEvent;
- import net.minecraft.client.Minecraft;
- import net.minecraftforge.client.event.RenderGameOverlayEvent;
- import net.minecraftforge.common.MinecraftForge;
- public class OverlaySanity {
- public static class GUIRenderEventClass {
- DecimalFormat df = new DecimalFormat("#.##"); //Format Sanity to a nice string with 2 decimals
- @SubscribeEvent(priority = EventPriority.NORMAL)
- public void eventHandler(RenderGameOverlayEvent.Text event) { // on the rendergameoverlaytext event
- ExtendedPlayer props = ExtendedPlayer.get(Minecraft.getMinecraft().thePlayer);
- int posX = (event.resolution.getScaledWidth()) / 2; //get the center of the screen coords
- int posY = (event.resolution.getScaledHeight()) / 2;
- if (true) {
- //Draw the Sanity tag and print the variable with the decimal formatted to 2 places
- Minecraft.getMinecraft().fontRenderer.drawString("Sanity: " + df.format(props.getCurrentSanity()), posX + (posX / 2), posY + (posY / 3), 0xffffff);
- }
- }
- }
- public OverlaySanity() {
- }
- public Object instance;
- public void load() {
- MinecraftForge.EVENT_BUS.register(new GUIRenderEventClass());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment