This commit is contained in:
Lukas Rieger (Blue) 2022-10-24 23:25:02 +02:00
commit 80d08f026e
No known key found for this signature in database
GPG Key ID: 2D09EC5ED2687FF2

View File

@ -83,19 +83,21 @@ public void update(File storageFolder, File fallback) {
} }
public BufferedImage createHead(BufferedImage skinTexture) { public BufferedImage createHead(BufferedImage skinTexture) {
BufferedImage head = new BufferedImage(8, 8, skinTexture.getType()); BufferedImage head;
BufferedImage layer1 = skinTexture.getSubimage(8, 8, 8, 8); BufferedImage layer1 = skinTexture.getSubimage(8, 8, 8, 8);
BufferedImage layer2 = skinTexture.getSubimage(40, 8, 8, 8); BufferedImage layer2 = skinTexture.getSubimage(40, 8, 8, 8);
try { try {
head = new BufferedImage(48, 48, BufferedImage.TYPE_INT_ARGB);
Graphics2D g = head.createGraphics(); Graphics2D g = head.createGraphics();
g.drawImage(layer1, 0, 0, null); g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
g.drawImage(layer2, 0, 0, null); g.drawImage(layer1, 4, 4, 40, 40, null);
g.drawImage(layer2, 0, 0, 48, 48, null);
} catch (Throwable t) { // There might be problems with headless servers when loading the graphics class, so we catch every exception and error on purpose here } catch (Throwable t) { // There might be problems with headless servers when loading the graphics class, so we catch every exception and error on purpose here
Logger.global.noFloodWarning("headless-graphics-fail", Logger.global.noFloodWarning("headless-graphics-fail",
"Could not access Graphics2D to render player-skin texture. Try adding '-Djava.awt.headless=true' to your startup flags or ignore this warning."); "Could not access Graphics2D to render player-skin texture. Try adding '-Djava.awt.headless=true' to your startup flags or ignore this warning.");
head = new BufferedImage(8, 8, skinTexture.getType());
layer1.copyData(head.getRaster()); layer1.copyData(head.getRaster());
} }