From 83a95fb26cec82114b9389cb6b8644d124682a36 Mon Sep 17 00:00:00 2001 From: Liam Date: Thu, 11 Apr 2024 08:21:53 +0100 Subject: [PATCH] cleanup head renderer --- .../service/skin/impl/HeadRenderer.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/cc.fascinated/service/skin/impl/HeadRenderer.java b/src/main/java/cc.fascinated/service/skin/impl/HeadRenderer.java index 017bdfa..614df3f 100644 --- a/src/main/java/cc.fascinated/service/skin/impl/HeadRenderer.java +++ b/src/main/java/cc.fascinated/service/skin/impl/HeadRenderer.java @@ -17,15 +17,17 @@ public class HeadRenderer extends SkinRenderer { double scale = (double) size / 8d; log.info("Getting {} part bytes for {} with size {} and scale {}", partName, skin.getUrl(), size, scale); + BufferedImage skinPart = this.getSkinPart(skin, Skin.PartPosition.HEAD_FACE, scale); + if (!renderOverlay) { + return super.getBytes(skinPart, skin, partName); + } + BufferedImage outputImage = new BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB); Graphics2D graphics = outputImage.createGraphics(); + graphics.drawImage(skinPart, 0, 0, null); - graphics.setTransform(AffineTransform.getScaleInstance(scale, scale)); - graphics.drawImage(this.getSkinPart(skin, Skin.PartPosition.HEAD_FACE, 1), 0, 0, null); - - if (renderOverlay) { // Render the skin layers - applyOverlay(outputImage, this.getSkinPart(skin, Skin.PartPosition.HEAD_OVERLAY_FACE, 1)); - } + // Apply the skin overlays + applyOverlay(outputImage, this.getSkinPart(skin, Skin.PartPosition.HEAD_OVERLAY_FACE, scale)); return super.getBytes(outputImage, skin, partName); }