Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public void render(PoseStack stack, int mouseX, int mouseY, float partialTicks) {
- if (this.visible) {
- this.isHovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width
- && mouseY < this.y + this.height;
- RenderSystem.setShader(GameRenderer::getPositionTexShader);
- RenderSystem.setShaderTexture(0, this.texture);
- final float alpha = this.alpha.getFloat(this);
- RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f,
- alpha >= 0 && this.alpha.getFloat(this) <= 1 ? alpha : 1.0f);
- final int yTexOffset = this.isHovered ? this.height : 0;
- RenderSystem.enableBlend();
- RenderSystem.defaultBlendFunc();
- RenderSystem.enableDepthTest();
- final var pivot = new Vector3f(this.width / 2, this.height / 2, 0);
- rotateAround(stack, pivot, Vector3f.ZP, this.orientation.rotDegrees);
- // rotateAround(stack, pivot, Vector3f.YP, 180f);
- stack.translate(-this.y, this.x, 0);
- blit(stack, 0, 0, this.texX, this.texY + yTexOffset, this.width, this.height, 256, 256);
- ClientUtils.getFont().draw(stack, new TextComponent("beans"), this.x, this.y, 0xFF0000);
- }
- }
- private void rotateAround(PoseStack stack, Vector3f pivot, Vector3f axis, float angle) {
- stack.translate(pivot.x(), pivot.y(), pivot.z());
- stack.mulPose(axis.rotationDegrees(angle));
- stack.translate(-pivot.x(), -pivot.y(), -pivot.z());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement