Guest User

Untitled

a guest
May 12th, 2015
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.89 KB | None | 0 0
  1. package com.makersfactory.mfygps;
  2.  
  3. import java.util.Collection;
  4. import java.util.Iterator;
  5.  
  6. import org.lwjgl.opengl.GL11;
  7.  
  8. import cpw.mods.fml.common.eventhandler.SubscribeEvent;
  9. import cpw.mods.fml.relauncher.Side;
  10. import cpw.mods.fml.relauncher.SideOnly;
  11. import net.minecraft.client.Minecraft;
  12. import net.minecraft.client.gui.Gui;
  13. import net.minecraft.init.Items;
  14. import net.minecraft.item.Item;
  15. import net.minecraft.item.ItemStack;
  16. import net.minecraft.potion.Potion;
  17. import net.minecraft.potion.PotionEffect;
  18. import net.minecraft.util.MathHelper;
  19. import net.minecraft.util.ResourceLocation;
  20. import net.minecraft.util.Vec3;
  21. import net.minecraftforge.client.event.RenderGameOverlayEvent;
  22. import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
  23.  
  24. public class GuiGPS extends Gui {
  25.  
  26. private Minecraft mc;
  27.  
  28. public GuiGPS(Minecraft mc) {
  29. super();
  30. this.mc = mc;
  31. }
  32.  
  33. static final Item gpsItem = MFYGPS.handheldGPS;
  34. static final int LS = 10;
  35. static final int TOP = 10;
  36. static final int LEFT = 10;
  37. static final int WIDTH = 70;
  38. static final int HEIGHT = 44;
  39.  
  40. @SubscribeEvent
  41. public void eventHandler(RenderGameOverlayEvent e) {
  42. ItemStack currItem = this.mc.thePlayer.getCurrentEquippedItem();
  43. if (currItem == null || currItem.getItem() != gpsItem) {
  44. return;
  45. }
  46.  
  47. // Draw Background
  48. GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
  49. GL11.glDisable(GL11.GL_LIGHTING);
  50. this.mc.renderEngine.bindTexture(new ResourceLocation("mfygps-assets:textures/gui/gps-background.png"));
  51. this.drawTexturedModalRect(LEFT-8, TOP-7, 0, 0, 148, 61);
  52.  
  53. // Calculate coordinates and direction
  54. String l1 = "X: " + (int)this.mc.thePlayer.posX;
  55. String l2 = "Y: " + (int)this.mc.thePlayer.posY;
  56. String l3 = "Z: " + (int)this.mc.thePlayer.posZ;
  57. String l4 = "Heading: ";
  58. Vec3 look = this.mc.thePlayer.getLookVec();
  59. double f1 = MathHelper.cos(-mc.thePlayer.rotationYaw * 0.017453292F - (float)Math.PI);
  60. // +1 north, -1 south
  61. double f2 = MathHelper.sin(-mc.thePlayer.rotationYaw * 0.017453292F - (float)Math.PI);
  62. // +1 west, -1 east
  63. String direction = "";
  64.  
  65. double f3 = Math.abs(f1);
  66. double f4 = Math.abs(f2);
  67. double per;
  68.  
  69. if (f3 > f4) {
  70. per = (Math.floor(f3*100));
  71. if (f3 > 0.999) per = 100;
  72. direction = "";
  73. direction += f1 > 0 ? "North" : "South";
  74. }
  75. else {
  76. per = (Math.floor(f4*100));
  77. if (f4 > 0.999) per = 100;
  78. direction = "";
  79. direction += f2 > 0 ? "West" : "East";
  80. }
  81.  
  82. direction = (per == 100 ? "Exactly " : (per > 95 ? "Mostly " : "Somewhat ")) + direction;
  83.  
  84. // Draw coordinates and direction
  85. this.drawString(mc.fontRenderer, l1, LEFT, TOP, 0xff7070);
  86. this.drawString(mc.fontRenderer, l2, LEFT, TOP+LS, 0x3dff87);
  87. this.drawString(mc.fontRenderer, l3, LEFT, TOP+LS+LS, 0x758aff);
  88. this.drawString(mc.fontRenderer, "Direction: " + direction, LEFT, TOP+LS+LS+LS, 0xFFFFFF);
  89. }
  90.  
  91. }
Advertisement
Add Comment
Please, Sign In to add comment