Skip to content

Commit ca1febf

Browse files
committed
Fix Notch skin helm rendering
1 parent edb985b commit ca1febf

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/main/java/net/minecrell/serverlistplus/core/favicon/FaviconHelper.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public static BufferedImage fromURL(ServerListPlusCore core, URL url) throws IOE
9292

9393
private static BufferedImage fromSkin(ServerListPlusCore core, URL url, boolean helm) throws IOException {
9494
BufferedImage skin = fromURL(core, url);
95-
if (helm) {
95+
if (helm && !isSolidColor(skin, HELM_X, HELM_Y, HEAD_SIZE, HEAD_SIZE)) {
9696
Graphics2D g = skin.createGraphics();
9797
g.copyArea(HELM_X, HELM_Y, HEAD_SIZE, HEAD_SIZE, HEAD_X - HELM_X, HEAD_Y - HELM_Y);
9898
g.dispose();
@@ -168,4 +168,17 @@ public static BufferedImage loadSafely(ServerListPlusCore core, FaviconSource so
168168
return null;
169169
}
170170
}
171+
172+
private static boolean isSolidColor(BufferedImage image, int x, int y, int width, int height) {
173+
int base = image.getRGB(x, y);
174+
for (; x < width; x++) {
175+
for (; y < height; y++) {
176+
if (base != image.getRGB(x, y)) {
177+
return false;
178+
}
179+
}
180+
}
181+
return true;
182+
}
183+
171184
}

0 commit comments

Comments
 (0)