cleanup isometric skin renderer
All checks were successful
Deploy App / docker (ubuntu-latest, 2.44.0, 17, 3.8.5) (push) Successful in 1m11s
All checks were successful
Deploy App / docker (ubuntu-latest, 2.44.0, 17, 3.8.5) (push) Successful in 1m11s
This commit is contained in:
parent
b682153ebb
commit
e9fa275002
@ -1,11 +1,13 @@
|
||||
package cc.fascinated.common;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
@Log4j2
|
||||
public class ImageUtils {
|
||||
|
||||
/**
|
||||
|
@ -3,7 +3,7 @@ package cc.fascinated.model.player;
|
||||
import cc.fascinated.common.PlayerUtils;
|
||||
import cc.fascinated.config.Config;
|
||||
import cc.fascinated.exception.impl.BadRequestException;
|
||||
import cc.fascinated.service.skin.SkinPartRenderer;
|
||||
import cc.fascinated.service.skin.SkinRenderer;
|
||||
import cc.fascinated.service.skin.impl.FlatRenderer;
|
||||
import cc.fascinated.service.skin.impl.IsometricHeadRenderer;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
@ -101,7 +101,7 @@ public class Skin {
|
||||
/**
|
||||
* The skin part parser for the part.
|
||||
*/
|
||||
private final SkinPartRenderer skinPartParser;
|
||||
private final SkinRenderer skinPartParser;
|
||||
|
||||
/**
|
||||
* Gets the name of the part.
|
||||
|
@ -13,7 +13,7 @@ import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
||||
@AllArgsConstructor @Getter @Log4j2
|
||||
public abstract class SkinPartRenderer {
|
||||
public abstract class SkinRenderer {
|
||||
|
||||
/**
|
||||
* Gets the skin part image.
|
@ -1,18 +1,16 @@
|
||||
package cc.fascinated.service.skin.impl;
|
||||
|
||||
import cc.fascinated.model.player.Skin;
|
||||
import cc.fascinated.service.skin.SkinPartRenderer;
|
||||
import cc.fascinated.service.skin.SkinRenderer;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.*;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
||||
@Getter @Log4j2
|
||||
public class FlatRenderer extends SkinPartRenderer {
|
||||
public class FlatRenderer extends SkinRenderer {
|
||||
|
||||
/**
|
||||
* The x and y position of the part.
|
||||
@ -49,14 +47,7 @@ public class FlatRenderer extends SkinPartRenderer {
|
||||
graphics.setTransform(AffineTransform.getScaleInstance(scale, scale));
|
||||
graphics.drawImage(this.getSkinPart(skin, this.x, this.y, this.widthAndHeight, this.widthAndHeight, 1), 0, 0, null);
|
||||
|
||||
try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
|
||||
ImageIO.write(outputImage, "png", outputStream);
|
||||
// Cleanup
|
||||
outputStream.flush();
|
||||
graphics.dispose();
|
||||
log.info("Successfully got {} part bytes for {}", partName, skin.getUrl());
|
||||
return outputStream.toByteArray();
|
||||
}
|
||||
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());
|
||||
|
@ -2,7 +2,7 @@ package cc.fascinated.service.skin.impl;
|
||||
|
||||
import cc.fascinated.common.ImageUtils;
|
||||
import cc.fascinated.model.player.Skin;
|
||||
import cc.fascinated.service.skin.SkinPartRenderer;
|
||||
import cc.fascinated.service.skin.SkinRenderer;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
|
||||
@ -11,7 +11,7 @@ import java.awt.geom.AffineTransform;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
@Getter @Log4j2
|
||||
public class IsometricHeadRenderer extends SkinPartRenderer {
|
||||
public class IsometricHeadRenderer extends SkinRenderer {
|
||||
|
||||
private static final double SKEW_A = 26d / 45d; // 0.57777777
|
||||
private static final double SKEW_B = SKEW_A * 2d; // 1.15555555
|
||||
|
Loading…
Reference in New Issue
Block a user