Advertisement
Guest User

l kemo y klpe <3

a guest
Feb 23rd, 2020
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.85 KB | None | 0 0
  1. package scoreclient.mods;
  2.  
  3. import java.awt.Color;
  4.  
  5. import org.lwjgl.opengl.GL11;
  6.  
  7. import net.minecraft.client.Minecraft;
  8. import net.minecraft.client.gui.Gui;
  9. import net.minecraft.client.settings.KeyBinding;
  10. import scoreclient.hud.ScreenPosition;
  11. import scoreclient.utils.Rainbow;
  12.  
  13. public class ModKeystorkes extends ModDraggable {
  14.  
  15. public static enum KeystrokesMode{
  16.  
  17. WASD(Key.W, Key.A, Key.S, Key.D),
  18. WASD_MOUSE(Key.W, Key.A, Key.S, Key.D, Key.LMB, Key.RMB),
  19. WASD_SPRINT(Key.W, Key.A, Key.S, Key.D, new Key("§m------", Minecraft.getMinecraft().gameSettings.keyBindJump, 1, 41, 58, 18)),
  20. WASD_SPRINT_MOUSE(Key.W, Key.A, Key.S, Key.D, Key.LMB, Key.RMB, new Key("§m------", Minecraft.getMinecraft().gameSettings.keyBindJump, 1, 61, 58, 18))
  21. ;
  22.  
  23. private final Key[] keys;
  24. private int width = 0;
  25. private int height = 0;
  26.  
  27. private KeystrokesMode(Key... keysIn) {
  28. this.keys = keysIn;
  29.  
  30. for(Key key : keys) {
  31. this.width = Math.max(this.width, key.getX() + key.getWidth());
  32. this.height = Math.max(this.height, key.getY() + key.getHeight());
  33. }
  34. }
  35.  
  36. public int getHeight() {
  37. return height;
  38. }
  39.  
  40. public int getWidth() {
  41. return width;
  42. }
  43.  
  44. public Key[] getKeys() {
  45. return keys;
  46. }
  47. }
  48.  
  49. public static class Key{
  50.  
  51. private static final Key W = new Key("W", Minecraft.getMinecraft().gameSettings.keyBindForward, 21, 1, 18, 18);
  52. private static final Key A = new Key("A", Minecraft.getMinecraft().gameSettings.keyBindLeft, 1, 21, 18, 18);
  53. private static final Key S = new Key("S", Minecraft.getMinecraft().gameSettings.keyBindBack, 21, 21, 18, 18);
  54. private static final Key D = new Key("D", Minecraft.getMinecraft().gameSettings.keyBindRight, 41, 21, 18, 18);
  55.  
  56. private static final Key LMB = new Key("LMB", Minecraft.getMinecraft().gameSettings.keyBindAttack, 1, 41, 28, 18);
  57. private static final Key RMB = new Key("RMB", Minecraft.getMinecraft().gameSettings.keyBindUseItem, 31, 41, 28, 18);
  58.  
  59. private final String name;
  60. private final KeyBinding keyBind;
  61. private final int x;
  62. private final int y;
  63. private final int width;
  64. private final int height;
  65.  
  66. public Key(String name, KeyBinding keyBind, int x, int y, int width, int height) {
  67. this.name = name;
  68. this.x = x;
  69. this.y = y;
  70. this.width = width;
  71. this.height = height;
  72. this.keyBind = keyBind;
  73. }
  74.  
  75. public boolean isDown() {
  76. return keyBind.isKeyDown();
  77. }
  78. public int getHeight() {
  79. return height;
  80. }
  81. public int getWidth() {
  82. return width;
  83. }
  84. public String getName() {
  85. return name;
  86. }
  87. public int getX() {
  88. return x;
  89. }
  90. public int getY() {
  91. return y;
  92. }
  93. }
  94.  
  95.  
  96. private KeystrokesMode mode = KeystrokesMode.WASD_SPRINT_MOUSE;
  97.  
  98. public void setMode(KeystrokesMode mode) {
  99. this.mode = mode;
  100. }
  101.  
  102. @Override
  103. public int getWidth() {
  104. return mode.getWidth();
  105. }
  106.  
  107. @Override
  108. public int getHeight() {
  109. return mode.getHeight();
  110. }
  111.  
  112. @Override
  113. public void render(ScreenPosition pos) {
  114. GL11.glPushMatrix();
  115.  
  116. boolean blend = GL11.glIsEnabled(GL11.GL_BLEND);
  117.  
  118. for (Key key : mode.getKeys()) {
  119. int textWidth = font.getStringWidth(key.getName());
  120.  
  121. Gui.drawRect(pos.getAbslouteX() + key.getX(), pos.getAbslouteY() + key.getY(), pos.getAbslouteX() + key.getX() + key.getWidth(), pos.getAbslouteY() + key.getY() + key.getHeight(),
  122. key.isDown() ? new Color(255, 255, 255, 102).getRGB() : new Color(0, 0, 0, 102).getRGB());
  123.  
  124.  
  125. font.drawString(
  126. key.getName(),
  127. pos.getAbslouteX() + key.getX() + key.getWidth() / 2 - textWidth /2,
  128. pos.getAbslouteY() + key.getY() + key.getHeight() / 2 - 4,
  129. key.isDown() ? Color.BLACK.getRGB() : Rainbow.rainbowEffect(10L, 1F).getRGB()
  130. );
  131. }
  132.  
  133.  
  134.  
  135. if(blend) {
  136. GL11.glEnable(GL11.GL_BLEND);
  137. }
  138.  
  139.  
  140. GL11.glPopMatrix();
  141. }
  142.  
  143.  
  144.  
  145. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement