Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,19 @@ private static String getTexture(Player player) {

private static void saveTexture(String name, String url) {
try {
BufferedImage img = ImageIO.read(new URL(url)).getSubimage(8, 8, 8, 8);
BufferedImage skin = ImageIO.read(new URL(url));
BufferedImage head = skin.getSubimage(8, 8, 8, 8);
BufferedImage mask = skin.getSubimage(40, 8, 8, 8);
for (int y = 0; y < 8; y++) {
for (int x = 0; x < 8; x++) {
int rgb = mask.getRGB(x, y);
if ((rgb & 0xff000000) != 0) {
head.setRGB(x, y, rgb);
}
}
}
File file = new File(skinsDir, name + ".png");
ImageIO.write(img, "png", file);
ImageIO.write(head, "png", file);
} catch (IOException e) {
e.printStackTrace();
}
Expand Down