Advertisement
TurtyWurty

Untitled

Dec 10th, 2021
817
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.55 KB | None | 0 0
  1. @Override
  2.     public void render(PoseStack stack, int mouseX, int mouseY, float partialTicks) {
  3.         if (this.visible) {
  4.             this.isHovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width
  5.                     && mouseY < this.y + this.height;
  6.             RenderSystem.setShader(GameRenderer::getPositionTexShader);
  7.             RenderSystem.setShaderTexture(0, this.texture);
  8.             final float alpha = this.alpha.getFloat(this);
  9.             RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f,
  10.                     alpha >= 0 && this.alpha.getFloat(this) <= 1 ? alpha : 1.0f);
  11.             final int yTexOffset = this.isHovered ? this.height : 0;
  12.             RenderSystem.enableBlend();
  13.             RenderSystem.defaultBlendFunc();
  14.             RenderSystem.enableDepthTest();
  15.             final var pivot = new Vector3f(this.width / 2, this.height / 2, 0);
  16.             rotateAround(stack, pivot, Vector3f.ZP, this.orientation.rotDegrees);
  17.             // rotateAround(stack, pivot, Vector3f.YP, 180f);
  18.             stack.translate(-this.y, this.x, 0);
  19.             blit(stack, 0, 0, this.texX, this.texY + yTexOffset, this.width, this.height, 256, 256);
  20.             ClientUtils.getFont().draw(stack, new TextComponent("beans"), this.x, this.y, 0xFF0000);
  21.         }
  22.     }
  23.  
  24. private void rotateAround(PoseStack stack, Vector3f pivot, Vector3f axis, float angle) {
  25.         stack.translate(pivot.x(), pivot.y(), pivot.z());
  26.         stack.mulPose(axis.rotationDegrees(angle));
  27.         stack.translate(-pivot.x(), -pivot.y(), -pivot.z());
  28.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement