Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.makersfactory.mfygps;
- import java.util.Collection;
- import java.util.Iterator;
- import org.lwjgl.opengl.GL11;
- import cpw.mods.fml.common.eventhandler.SubscribeEvent;
- import cpw.mods.fml.relauncher.Side;
- import cpw.mods.fml.relauncher.SideOnly;
- import net.minecraft.client.Minecraft;
- import net.minecraft.client.gui.Gui;
- import net.minecraft.init.Items;
- import net.minecraft.item.Item;
- import net.minecraft.item.ItemStack;
- import net.minecraft.potion.Potion;
- import net.minecraft.potion.PotionEffect;
- import net.minecraft.util.MathHelper;
- import net.minecraft.util.ResourceLocation;
- import net.minecraft.util.Vec3;
- import net.minecraftforge.client.event.RenderGameOverlayEvent;
- import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
- public class GuiGPS extends Gui {
- private Minecraft mc;
- public GuiGPS(Minecraft mc) {
- super();
- this.mc = mc;
- }
- static final Item gpsItem = MFYGPS.handheldGPS;
- static final int LS = 10;
- static final int TOP = 10;
- static final int LEFT = 10;
- static final int WIDTH = 70;
- static final int HEIGHT = 44;
- @SubscribeEvent
- public void eventHandler(RenderGameOverlayEvent e) {
- ItemStack currItem = this.mc.thePlayer.getCurrentEquippedItem();
- if (currItem == null || currItem.getItem() != gpsItem) {
- return;
- }
- // Draw Background
- GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
- GL11.glDisable(GL11.GL_LIGHTING);
- this.mc.renderEngine.bindTexture(new ResourceLocation("mfygps-assets:textures/gui/gps-background.png"));
- this.drawTexturedModalRect(LEFT-8, TOP-7, 0, 0, 148, 61);
- // Calculate coordinates and direction
- String l1 = "X: " + (int)this.mc.thePlayer.posX;
- String l2 = "Y: " + (int)this.mc.thePlayer.posY;
- String l3 = "Z: " + (int)this.mc.thePlayer.posZ;
- String l4 = "Heading: ";
- Vec3 look = this.mc.thePlayer.getLookVec();
- double f1 = MathHelper.cos(-mc.thePlayer.rotationYaw * 0.017453292F - (float)Math.PI);
- // +1 north, -1 south
- double f2 = MathHelper.sin(-mc.thePlayer.rotationYaw * 0.017453292F - (float)Math.PI);
- // +1 west, -1 east
- String direction = "";
- double f3 = Math.abs(f1);
- double f4 = Math.abs(f2);
- double per;
- if (f3 > f4) {
- per = (Math.floor(f3*100));
- if (f3 > 0.999) per = 100;
- direction = "";
- direction += f1 > 0 ? "North" : "South";
- }
- else {
- per = (Math.floor(f4*100));
- if (f4 > 0.999) per = 100;
- direction = "";
- direction += f2 > 0 ? "West" : "East";
- }
- direction = (per == 100 ? "Exactly " : (per > 95 ? "Mostly " : "Somewhat ")) + direction;
- // Draw coordinates and direction
- this.drawString(mc.fontRenderer, l1, LEFT, TOP, 0xff7070);
- this.drawString(mc.fontRenderer, l2, LEFT, TOP+LS, 0x3dff87);
- this.drawString(mc.fontRenderer, l3, LEFT, TOP+LS+LS, 0x758aff);
- this.drawString(mc.fontRenderer, "Direction: " + direction, LEFT, TOP+LS+LS+LS, 0xFFFFFF);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment