fix overlay on player head
All checks were successful
Deploy App / docker (ubuntu-latest, 2.44.0, 17, 3.8.5) (push) Successful in 1m32s

This commit is contained in:
Lee 2024-04-11 07:45:16 +01:00
parent 654037c8e1
commit d9e6becebb
3 changed files with 66 additions and 80 deletions

@ -19,7 +19,7 @@ public class BodyRenderer extends SkinRenderer {
@Override
public byte[] renderPart(Skin skin, String partName, boolean renderOverlay, int size) {
log.info("Getting {} part bytes for {} with size {}", partName, skin.getUrl(), size);
try {
BufferedImage outputImage = new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_INT_ARGB);
Graphics2D graphics = outputImage.createGraphics();
@ -50,9 +50,5 @@ public class BodyRenderer extends SkinRenderer {
graphics.dispose(); // Clean up
return super.getBytes(ImageUtils.resize(outputImage, (double) size / HEIGHT), skin, partName);
} catch (Exception ex) {
log.error("Failed to get {} part bytes for {}", partName, skin.getUrl(), ex);
throw new RuntimeException("Failed to get " + partName + " part for " + skin.getUrl());
}
}
}

@ -17,7 +17,6 @@ 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);
try {
BufferedImage outputImage = new BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB);
Graphics2D graphics = outputImage.createGraphics();
@ -29,9 +28,5 @@ public class HeadRenderer extends SkinRenderer {
}
return super.getBytes(outputImage, skin, partName);
} catch (Exception ex) {
log.error("Failed to get {} part bytes for {}", partName, skin.getUrl(), ex);
throw new RuntimeException("Failed to get " + partName + " part for " + skin.getUrl());
}
}
}

@ -31,22 +31,21 @@ public class IsometricHeadRenderer extends SkinRenderer {
double x, y, z; // The x, y, and z positions
double zOffset = scale * 3.5d;
double xOffset = scale * 2d;
try {
BufferedImage outputImage = new BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB);
Graphics2D graphics = outputImage.createGraphics();
// Get all the required head parts
BufferedImage headTop = ImageUtils.resize(this.getSkinPart(skin, Skin.PartPosition.HEAD_TOP, 1), scale);
BufferedImage headFront = ImageUtils.resize(this.getSkinPart(skin, Skin.PartPosition.HEAD_FRONT, 1), scale);
BufferedImage headRight = ImageUtils.resize(this.getSkinPart(skin, Skin.PartPosition.HEAD_RIGHT, 1), scale);
BufferedImage headTop = this.getSkinPart(skin, Skin.PartPosition.HEAD_TOP, scale);
BufferedImage headFront = this.getSkinPart(skin, Skin.PartPosition.HEAD_FRONT, scale);
BufferedImage headRight = this.getSkinPart(skin, Skin.PartPosition.HEAD_RIGHT, scale);
if (renderOverlay) { // Render the skin layers
applyOverlay(headTop, this.getSkinPart(skin, Skin.PartPosition.HEAD_OVERLAY_TOP, 1));
applyOverlay(headFront, this.getSkinPart(skin, Skin.PartPosition.HEAD_OVERLAY_FRONT, 1));
applyOverlay(headRight, this.getSkinPart(skin, Skin.PartPosition.HEAD_OVERLAY_RIGHT, 1));
applyOverlay(headTop, this.getSkinPart(skin, Skin.PartPosition.HEAD_OVERLAY_TOP, scale));
applyOverlay(headFront, this.getSkinPart(skin, Skin.PartPosition.HEAD_OVERLAY_FRONT, scale));
applyOverlay(headRight, this.getSkinPart(skin, Skin.PartPosition.HEAD_OVERLAY_RIGHT, scale));
}
// Draw the head
// Draw the top of the head
x = xOffset;
y = -0.5;
z = zOffset;
@ -66,10 +65,6 @@ public class IsometricHeadRenderer extends SkinRenderer {
drawPart(graphics, headRight, RIGHT_TRANSFORM, x + y + 1, z - y - 0.5, headRight.getWidth(), headRight.getHeight());
return super.getBytes(outputImage, skin, partName);
} catch (Exception ex) {
log.error("Failed to get {} part bytes for {}", partName, skin.getUrl(), ex);
throw new RuntimeException("Failed to get " + partName + " part for " + skin.getUrl());
}
}
/**