cleanup isometric head
All checks were successful
Deploy App / docker (ubuntu-latest, 2.44.0, 17, 3.8.5) (push) Successful in 1m42s
All checks were successful
Deploy App / docker (ubuntu-latest, 2.44.0, 17, 3.8.5) (push) Successful in 1m42s
This commit is contained in:
parent
d9e6becebb
commit
9acb7c259a
@ -115,7 +115,7 @@ public class Skin {
|
||||
/**
|
||||
* The skin part renderer for the part.
|
||||
*/
|
||||
private final SkinRenderer skinRenderer;
|
||||
private final SkinRenderer renderer;
|
||||
|
||||
/**
|
||||
* Gets the name of the part.
|
||||
@ -151,7 +151,7 @@ public class Skin {
|
||||
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),
|
||||
HEAD_LEFT(0, 8, 8, 8, null),
|
||||
|
||||
BODY(20, 20, 8, 12, null),
|
||||
BODY_BACK(20, 36, 8, 12, null),
|
||||
@ -169,7 +169,6 @@ public class Skin {
|
||||
*/
|
||||
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_FRONT(20, 36, 8, 12, null),
|
||||
|
@ -139,7 +139,7 @@ public class PlayerService {
|
||||
}
|
||||
|
||||
long before = System.currentTimeMillis();
|
||||
byte[] skinPartBytes = part.getSkinRenderer().renderPart(player.getSkin(), part.getName(), renderOverlay, size);
|
||||
byte[] skinPartBytes = part.getRenderer().renderPart(player.getSkin(), part.getName(), renderOverlay, size);
|
||||
log.info("Took {}ms to render skin part {} for player: {}", System.currentTimeMillis() - before, part.getName(), player.getUniqueId());
|
||||
CachedPlayerSkinPart skinPart = new CachedPlayerSkinPart(
|
||||
key,
|
||||
|
@ -7,7 +7,6 @@ import lombok.Getter;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
@Getter @Log4j2
|
||||
|
@ -1,6 +1,5 @@
|
||||
package cc.fascinated.service.skin.impl;
|
||||
|
||||
import cc.fascinated.common.ImageUtils;
|
||||
import cc.fascinated.model.player.Skin;
|
||||
import cc.fascinated.service.skin.SkinRenderer;
|
||||
import lombok.Getter;
|
||||
@ -19,16 +18,15 @@ public class IsometricHeadRenderer extends SkinRenderer {
|
||||
/**
|
||||
* The head transforms
|
||||
*/
|
||||
private static final AffineTransform HEAD_TRANSFORM = new AffineTransform(1d, -SKEW_A, 1, SKEW_A, 0, 0);
|
||||
private static final AffineTransform FRONT_TRANSFORM = new AffineTransform(1d, -SKEW_A, 0d, SKEW_B, 0d, SKEW_A);
|
||||
private static final AffineTransform RIGHT_TRANSFORM = new AffineTransform(1d, SKEW_A, 0d, SKEW_B, 0d, 0d);
|
||||
private static final AffineTransform HEAD_TOP_TRANSFORM = new AffineTransform(1D, -SKEW_A, 1, SKEW_A, 0, 0);
|
||||
private static final AffineTransform FACE_TRANSFORM = new AffineTransform(1D, -SKEW_A, 0D, SKEW_B, 0d, SKEW_A);
|
||||
private static final AffineTransform HEAD_LEFT_TRANSFORM = new AffineTransform(1D, SKEW_A, 0D, SKEW_B, 0D, 0D);
|
||||
|
||||
@Override
|
||||
public byte[] renderPart(Skin skin, String partName, boolean renderOverlay, int size) {
|
||||
double scale = (size / 8d) / 2.5;
|
||||
log.info("Getting {} part bytes for {} with size {} and scale {}", partName, skin.getUrl(), size, scale);
|
||||
|
||||
double x, y, z; // The x, y, and z positions
|
||||
double zOffset = scale * 3.5d;
|
||||
double xOffset = scale * 2d;
|
||||
BufferedImage outputImage = new BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB);
|
||||
@ -37,32 +35,23 @@ public class IsometricHeadRenderer extends SkinRenderer {
|
||||
// Get all the required head parts
|
||||
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);
|
||||
BufferedImage headLeft = this.getSkinPart(skin, Skin.PartPosition.HEAD_LEFT, scale);
|
||||
|
||||
if (renderOverlay) { // Render the skin layers
|
||||
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));
|
||||
applyOverlay(headLeft, this.getSkinPart(skin, Skin.PartPosition.HEAD_OVERLAY_LEFT, scale));
|
||||
}
|
||||
|
||||
// Draw the top of the head
|
||||
x = xOffset;
|
||||
y = -0.5;
|
||||
z = zOffset;
|
||||
// The head is offset by 2 pixels for whatever reason
|
||||
drawPart(graphics, headTop, HEAD_TRANSFORM, y - z, x + z, headTop.getWidth(), headTop.getHeight() + 2);
|
||||
// Draw the top of the left
|
||||
drawPart(graphics, headTop, HEAD_TOP_TRANSFORM, -0.5 - zOffset, xOffset + zOffset, headTop.getWidth(), headTop.getHeight() + 2);
|
||||
|
||||
// Draw the front of the head
|
||||
x = xOffset + 8 * scale;
|
||||
y = 0;
|
||||
z = zOffset - 0.5;
|
||||
drawPart(graphics, headFront, FRONT_TRANSFORM, y + x, x + z, headFront.getWidth(), headFront.getHeight());
|
||||
// Draw the face of the head
|
||||
double x = xOffset + 8 * scale;
|
||||
drawPart(graphics, headFront, FACE_TRANSFORM, x, x + zOffset - 0.5, headFront.getWidth(), headFront.getHeight());
|
||||
|
||||
// Draw the right side of the head
|
||||
x = xOffset;
|
||||
y = 0;
|
||||
z = zOffset;
|
||||
drawPart(graphics, headRight, RIGHT_TRANSFORM, x + y + 1, z - y - 0.5, headRight.getWidth(), headRight.getHeight());
|
||||
// Draw the left side of the head
|
||||
drawPart(graphics, headLeft, HEAD_LEFT_TRANSFORM, xOffset + 1, zOffset - 0.5, headLeft.getWidth(), headLeft.getHeight());
|
||||
|
||||
return super.getBytes(outputImage, skin, partName);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user