From 9b7b761ffd41c2c3f4236412e826839a51c6c981 Mon Sep 17 00:00:00 2001 From: Liam Date: Thu, 11 Apr 2024 06:33:51 +0100 Subject: [PATCH] add working skin layers and rename param for overlay --- .../controller/PlayerController.java | 4 +-- .../java/cc.fascinated/model/player/Skin.java | 29 +++++++++---------- .../service/skin/impl/BodyRenderer.java | 2 +- .../service/skin/impl/HeadRenderer.java | 2 +- .../skin/impl/IsometricHeadRenderer.java | 2 +- 5 files changed, 18 insertions(+), 21 deletions(-) diff --git a/src/main/java/cc.fascinated/controller/PlayerController.java b/src/main/java/cc.fascinated/controller/PlayerController.java index 992fade..361fb7f 100644 --- a/src/main/java/cc.fascinated/controller/PlayerController.java +++ b/src/main/java/cc.fascinated/controller/PlayerController.java @@ -49,7 +49,7 @@ public class PlayerController { @Parameter(description = "The part of the skin", example = "head") @PathVariable String part, @Parameter(description = "The UUID or Username of the player", example = "ImFascinated") @PathVariable String id, @Parameter(description = "The size of the image", example = "256") @RequestParam(required = false, defaultValue = "256") int size, - @Parameter(description = "Whether to render the skin overlay (skin layers)", example = "false") @RequestParam(required = false, defaultValue = "false") boolean renderOverlay, + @Parameter(description = "Whether to render the skin overlay (skin layers)", example = "false") @RequestParam(required = false, defaultValue = "false") boolean overlay, @Parameter(description = "Whether to download the image") @RequestParam(required = false, defaultValue = "false") boolean download) { CachedPlayer player = playerService.getPlayer(id); Skin.Parts skinPart = Skin.Parts.fromName(part); @@ -60,6 +60,6 @@ public class PlayerController { .cacheControl(cacheControl) .contentType(MediaType.IMAGE_PNG) .header(HttpHeaders.CONTENT_DISPOSITION, dispositionHeader.formatted(player.getUsername())) - .body(playerService.getSkinPart(player, skinPart, renderOverlay, size).getBytes()); + .body(playerService.getSkinPart(player, skinPart, overlay, size).getBytes()); } } diff --git a/src/main/java/cc.fascinated/model/player/Skin.java b/src/main/java/cc.fascinated/model/player/Skin.java index 66e97a8..798917a 100644 --- a/src/main/java/cc.fascinated/model/player/Skin.java +++ b/src/main/java/cc.fascinated/model/player/Skin.java @@ -148,41 +148,38 @@ public class Skin { /** * Skin postions */ - HEAD(8, 8, 8, 8, new LegacyPartPositionData(8, 8, false)), + HEAD(8, 8, 8, 8, null), HEAD_TOP(8, 0, 8, 8, null), HEAD_FRONT(8, 8, 8, 8, null), HEAD_RIGHT(0, 8, 8, 8, null), - BODY(20, 20, 8, 12, new LegacyPartPositionData(20, 20, false)), + BODY(20, 20, 8, 12, null), BODY_BACK(20, 36, 8, 12, null), BODY_LEFT(32, 52, 8, 12, null), BODY_RIGHT(44, 20, 8, 12, null), - RIGHT_ARM(44, 20, 4, 12, new LegacyPartPositionData(44, 20, false)), + RIGHT_ARM(44, 20, 4, 12, null), LEFT_ARM(36, 52, 4, 12, new LegacyPartPositionData(43, 20, true)), - RIGHT_LEG(4, 20, 4, 12, new LegacyPartPositionData(4, 20, false)), + RIGHT_LEG(4, 20, 4, 12, null), LEFT_LEG(20, 52, 4, 12, new LegacyPartPositionData(3, 20, true)), /** * Skin overlay (layer) positions */ - HEAD_OVERLAY(40, 8, 8, 8, null), // todo: finish these below - HEAD_OVERLAY_TOP(40, 0, 40, 0, null), - HEAD_OVERLAY_FRONT(40, 8, 40, 8, null), - HEAD_OVERLAY_RIGHT(32, 8, 32, 8, null), + HEAD_OVERLAY_TOP(40, 0, 8, 8, null), + HEAD_OVERLAY_FRONT(40, 8, 8, 8, null), + HEAD_OVERLAY_RIGHT(32, 8, 8, 8, null), + HEAD_OVERLAY_LEFT(48, 8, 8, 8, null), - BODY_OVERLAY(20, 32, 20, 12, null), - BODY_OVERLAY_BACK(20, 36, 20, 12, null), - BODY_OVERLAY_LEFT(32, 52, 32, 12, null), - BODY_OVERLAY_RIGHT(44, 32, 44, 12, null), + BODY_OVERLAY_FRONT(20, 36, 8, 12, null), - RIGHT_ARM_OVERLAY(44, 32, 44, 12, null), - LEFT_ARM_OVERLAY(36, 52, 36, 12, null), + RIGHT_ARM_OVERLAY(44, 36, 8, 12, null), + LEFT_ARM_OVERLAY(52, 52, 8, 12, null), - RIGHT_LEG_OVERLAY(4, 32, 4, 12, null), - LEFT_LEG_OVERLAY(20, 52, 20, 12, null); + RIGHT_LEG_OVERLAY(4, 36, 4, 12, null), + LEFT_LEG_OVERLAY(4, 52, 20, 12, null); /** * The x, and y position of the part. diff --git a/src/main/java/cc.fascinated/service/skin/impl/BodyRenderer.java b/src/main/java/cc.fascinated/service/skin/impl/BodyRenderer.java index 217b13d..47e4832 100644 --- a/src/main/java/cc.fascinated/service/skin/impl/BodyRenderer.java +++ b/src/main/java/cc.fascinated/service/skin/impl/BodyRenderer.java @@ -34,7 +34,7 @@ public class BodyRenderer extends SkinRenderer { if (renderOverlay) { // Render the skin layers Graphics2D overlayGraphics = head.createGraphics(); - applyOverlay(overlayGraphics, this.getSkinPart(skin, Skin.PartPosition.HEAD_OVERLAY, 1)); + applyOverlay(overlayGraphics, this.getSkinPart(skin, Skin.PartPosition.HEAD_OVERLAY_FRONT, 1)); } // Draw the body 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 d53920f..c32a3f9 100644 --- a/src/main/java/cc.fascinated/service/skin/impl/HeadRenderer.java +++ b/src/main/java/cc.fascinated/service/skin/impl/HeadRenderer.java @@ -25,7 +25,7 @@ public class HeadRenderer extends SkinRenderer { graphics.drawImage(this.getSkinPart(skin, Skin.PartPosition.HEAD, 1), 0, 0, null); if (renderOverlay) { // Render the skin layers - applyOverlay(outputImage.createGraphics(), this.getSkinPart(skin, Skin.PartPosition.HEAD_OVERLAY, 1)); + applyOverlay(outputImage.createGraphics(), this.getSkinPart(skin, Skin.PartPosition.HEAD_OVERLAY_FRONT, 1)); } return super.getBytes(outputImage, skin, partName); diff --git a/src/main/java/cc.fascinated/service/skin/impl/IsometricHeadRenderer.java b/src/main/java/cc.fascinated/service/skin/impl/IsometricHeadRenderer.java index c70f5e6..cead04f 100644 --- a/src/main/java/cc.fascinated/service/skin/impl/IsometricHeadRenderer.java +++ b/src/main/java/cc.fascinated/service/skin/impl/IsometricHeadRenderer.java @@ -42,7 +42,7 @@ public class IsometricHeadRenderer extends SkinRenderer { if (renderOverlay) { // Render the skin layers Graphics2D headGraphics = headTop.createGraphics(); - applyOverlay(headGraphics, this.getSkinPart(skin, Skin.PartPosition.HEAD_OVERLAY, 1)); + applyOverlay(headGraphics, this.getSkinPart(skin, Skin.PartPosition.HEAD_OVERLAY_TOP, 1)); headGraphics = headFront.createGraphics(); applyOverlay(headGraphics, this.getSkinPart(skin, Skin.PartPosition.HEAD_OVERLAY_FRONT, 1));