Advertisement
Guest User

DCompass

a guest
Mar 21st, 2017
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.31 KB | None | 0 0
  1. package mod.brandy.client.gui;
  2.  
  3. import java.io.IOException;
  4.  
  5. import org.lwjgl.opengl.GL11;
  6.  
  7. import net.minecraft.client.Minecraft;
  8. import net.minecraft.client.gui.GuiButton;
  9. import net.minecraft.client.gui.GuiScreen;
  10. import net.minecraft.client.renderer.GlStateManager;
  11.  
  12. public class GuiDCompass extends GuiScreen
  13. {
  14. GuiButton turn_on;
  15. GuiButton turn_off;
  16. GuiButton close;
  17. int buttonWidth = 80;
  18. int buttonHeight = 20;
  19. public static String facingF;
  20. public static boolean display;
  21.  
  22. public static String getFacing(Minecraft mc)
  23. {
  24. //swne
  25. int facing = mc.thePlayer.getHorizontalFacing().getHorizontalIndex();
  26.  
  27. String direction = null;
  28.  
  29. if(facing == 0)
  30. {
  31. direction = "South";
  32.  
  33. }
  34. else if(facing == 1)
  35. {
  36. direction = "West";
  37.  
  38. }
  39. else if(facing == 2)
  40. {
  41. direction = "North";
  42.  
  43. }
  44. else if(facing == 3)
  45. {
  46. direction = "East";
  47.  
  48. }
  49. return direction;
  50. }
  51.  
  52. private static int widthF;
  53. private static int heightF;
  54.  
  55. @Override
  56. public void drawScreen(int x, int y, float t)
  57. {
  58. this.drawDefaultBackground();
  59.  
  60. widthF = this.width;
  61. heightF = this.height;
  62.  
  63. int stringWidth = widthF / 2 - 25;
  64. int stringHeight = heightF / 4 + 50;
  65.  
  66. GL11.glPushMatrix();
  67. {
  68. GlStateManager.translate(stringWidth, stringHeight, 0);
  69. GL11.glScalef(2F, 2F, 2F);
  70. mc.fontRendererObj.drawString(getFacing(mc), 0, 0 - 8, 0xFFFFFF);
  71. }
  72. GL11.glPopMatrix();
  73.  
  74. super.drawScreen(x, y, t);
  75. }
  76.  
  77.  
  78. @Override
  79. public boolean doesGuiPauseGame()
  80. {
  81. return false;
  82. }
  83.  
  84. @Override
  85. public void initGui()
  86. {
  87. this.buttonList.add(this.turn_on = new GuiButton(24, this.width / 2 - 40, this.height / 4 + 60, buttonWidth, buttonHeight, "Turn On"));
  88. this.buttonList.add(this.turn_off = new GuiButton(25, this.width / 2 - 40, this.height / 4 + 80, buttonWidth, buttonHeight, "Turn Off"));
  89. this.buttonList.add(this.close = new GuiButton(26, this.width / 2 - 40, this.height / 4 + 100, buttonWidth, buttonHeight, "Close"));
  90. }
  91.  
  92. @Override
  93. public void actionPerformed(GuiButton button) throws IOException
  94. {
  95.  
  96. if(button.id == 26)
  97. {
  98. this.mc.setIngameFocus();
  99. }
  100. else
  101. if(button.id == 24)
  102. {
  103. display = true;
  104. }
  105. else
  106. if(button.id == 25)
  107. {
  108. display = false;
  109. }
  110.  
  111. }
  112.  
  113.  
  114. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement