@@ -228,7 +228,26 @@ private static boolean exportPlayerTexture(String textureUrl, NamespaceID texId)
228
228
if (texture .getHeight () == 32 ) { // Expand old 32px high player textures to new 64px size
229
229
Log .debug ("Expanding " +texId +" height from 32px to 64px" );
230
230
BufferedImage expandedTex = new BufferedImage (64 , 64 , BufferedImage .TYPE_INT_ARGB );
231
- expandedTex .getGraphics ().drawImage (texture , 0 , 0 , 64 , 32 , 0 , 0 , 64 , 32 , null );
231
+ Graphics2D expandedGraphics = expandedTex .createGraphics ();
232
+ expandedGraphics .drawImage (texture , 0 , 0 , 64 , 32 , 0 , 0 , 64 , 32 , null );
233
+
234
+ // Fix old skins that have opaque black pixels in the hat area (Notch)
235
+ boolean blackHat = true ;
236
+ for (int x = 32 ; x < 64 && blackHat ; x ++) {
237
+ for (int y = 0 ; y < 16 ; y ++) {
238
+ Color pixel = new Color (texture .getRGB (x , y ), true );
239
+ if (pixel .getRed () != 0 || pixel .getGreen () != 0 || pixel .getBlue () != 0 || pixel .getAlpha () != 255 ) {
240
+ blackHat = false ;
241
+ break ;
242
+ }
243
+ }
244
+ }
245
+ if (blackHat ) {
246
+ expandedGraphics .setColor (new Color (0 ,0 ,0 ,0 ));
247
+ expandedGraphics .setComposite (AlphaComposite .Src );
248
+ expandedGraphics .fillRect (32 , 0 , 32 , 16 );
249
+ }
250
+
232
251
texture = expandedTex ;
233
252
}
234
253
TextureEntry texEntry = Registries .getTexture (texId );
0 commit comments