Advertisement
TurtyWurty

Untitled

Dec 24th, 2021
832
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.35 KB | None | 0 0
  1. public void renderButton(PoseStack p_94160_, int p_94161_, int p_94162_, float p_94163_) {
  2.       if (this.isVisible()) {
  3.          if (this.isBordered()) {
  4.             int i = this.isFocused() ? -1 : -6250336;
  5.             fill(p_94160_, this.x - 1, this.y - 1, this.x + this.width + 1, this.y + this.height + 1, i);
  6.             fill(p_94160_, this.x, this.y, this.x + this.width, this.y + this.height, -16777216);
  7.          }
  8.  
  9.          int i2 = this.isEditable ? this.textColor : this.textColorUneditable;
  10.          int j = this.cursorPos - this.displayPos;
  11.          int k = this.highlightPos - this.displayPos;
  12.          String s = this.font.plainSubstrByWidth(this.value.substring(this.displayPos), this.getInnerWidth());
  13.          boolean flag = j >= 0 && j <= s.length();
  14.          boolean flag1 = this.isFocused() && this.frame / 6 % 2 == 0 && flag;
  15.          int l = this.bordered ? this.x + 4 : this.x;
  16.          int i1 = this.bordered ? this.y + (this.height - 8) / 2 : this.y;
  17.          int j1 = l;
  18.          if (k > s.length()) {
  19.             k = s.length();
  20.          }
  21.  
  22.          if (!s.isEmpty()) {
  23.             String s1 = flag ? s.substring(0, j) : s;
  24.             j1 = this.font.drawShadow(p_94160_, this.formatter.apply(s1, this.displayPos), (float)l, (float)i1, i2);
  25.          }
  26.  
  27.          boolean flag2 = this.cursorPos < this.value.length() || this.value.length() >= this.getMaxLength();
  28.          int k1 = j1;
  29.          if (!flag) {
  30.             k1 = j > 0 ? l + this.width : l;
  31.          } else if (flag2) {
  32.             k1 = j1 - 1;
  33.             --j1;
  34.          }
  35.  
  36.          if (!s.isEmpty() && flag && j < s.length()) {
  37.             this.font.drawShadow(p_94160_, this.formatter.apply(s.substring(j), this.cursorPos), (float)j1, (float)i1, i2);
  38.          }
  39.  
  40.          if (!flag2 && this.suggestion != null) {
  41.             this.font.drawShadow(p_94160_, this.suggestion, (float)(k1 - 1), (float)i1, -8355712);
  42.          }
  43.  
  44.          if (flag1) {
  45.             if (flag2) {
  46.                GuiComponent.fill(p_94160_, k1, i1 - 1, k1 + 1, i1 + 1 + 9, -3092272);
  47.             } else {
  48.                this.font.drawShadow(p_94160_, "_", (float)k1, (float)i1, i2);
  49.             }
  50.          }
  51.  
  52.          if (k != j) {
  53.             int l1 = l + this.font.width(s.substring(0, k));
  54.             this.renderHighlight(k1, i1 - 1, l1 - 1, i1 + 1 + 9);
  55.          }
  56.  
  57.       }
  58.    }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement