3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-11-03 14:50:19 +01:00

Fix capes of a *smaller* size throwing an error (#1998)

Dieser Commit ist enthalten in:
Camotoy 2021-03-04 11:32:56 -05:00 committet von GitHub
Ursprung e0e435fdc5
Commit f926b83b33
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23

Datei anzeigen

@ -412,7 +412,7 @@ public class SkinProvider {
// if the requested image is a cape // if the requested image is a cape
if (provider != null) { if (provider != null) {
if (image.getWidth() > 64) { if (image.getWidth() > 64 || image.getHeight() > 32) {
// Prevent weirdly-scaled capes from being cut off // Prevent weirdly-scaled capes from being cut off
BufferedImage newImage = new BufferedImage(128, 64, BufferedImage.TYPE_INT_ARGB); BufferedImage newImage = new BufferedImage(128, 64, BufferedImage.TYPE_INT_ARGB);
Graphics g = newImage.createGraphics(); Graphics g = newImage.createGraphics();
@ -420,6 +420,14 @@ public class SkinProvider {
g.dispose(); g.dispose();
image.flush(); image.flush();
image = scale(newImage, 64, 32); image = scale(newImage, 64, 32);
} else if (image.getWidth() < 64 || image.getHeight() < 32) {
// Bedrock doesn't like smaller-sized capes, either.
BufferedImage newImage = new BufferedImage(64, 32, BufferedImage.TYPE_INT_ARGB);
Graphics g = newImage.createGraphics();
g.drawImage(image, 0, 0, image.getWidth(), image.getHeight(), null);
g.dispose();
image.flush();
image = newImage;
} }
} else { } else {
// Very rarely, skins can be larger than Minecraft's default. // Very rarely, skins can be larger than Minecraft's default.