forked from GeyserMC/Geyser
Update SkinProvider.java
Fix OptiFine capes and downscales banner capes so they work on PE too.
This commit is contained in:
parent
374436172a
commit
16950bf8f2
1 changed files with 18 additions and 3 deletions
|
@ -164,11 +164,17 @@ public class SkinProvider {
|
||||||
BufferedImage image = ImageIO.read(new URL(imageUrl));
|
BufferedImage image = ImageIO.read(new URL(imageUrl));
|
||||||
Geyser.getLogger().debug("Downloaded " + imageUrl);
|
Geyser.getLogger().debug("Downloaded " + imageUrl);
|
||||||
|
|
||||||
if (cape) {
|
if (cape && image.getWidth() <= 64) {
|
||||||
BufferedImage newImage = new BufferedImage(64, 32, BufferedImage.TYPE_INT_RGB);
|
BufferedImage newImage = new BufferedImage(64, 32, BufferedImage.TYPE_INT_RGB);
|
||||||
|
|
||||||
Graphics g = newImage.createGraphics();
|
Graphics g = newImage.createGraphics();
|
||||||
g.drawImage(image, 0, 0, 64, 32, null);
|
g.drawImage(image, 0, 0, image.getWidth(), image.getHeight(), null);
|
||||||
|
g.dispose();
|
||||||
|
image = newImage;
|
||||||
|
}
|
||||||
|
else if(cape && image.getWidth() >= 64 && image.getWidth() <= 128) {
|
||||||
|
BufferedImage newImage = new BufferedImage(64, 32, BufferedImage.TYPE_INT_RGB);
|
||||||
|
Graphics g = newImage.createGraphics();
|
||||||
|
g.drawImage(scale(image), 0, 0, scale(image).getWidth(), scale(image).getHeight(), null);
|
||||||
g.dispose();
|
g.dispose();
|
||||||
image = newImage;
|
image = newImage;
|
||||||
}
|
}
|
||||||
|
@ -193,6 +199,15 @@ public class SkinProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static BufferedImage scale (BufferedImage bufferedImage) {
|
||||||
|
BufferedImage resized = new BufferedImage(bufferedImage.getWidth() / 2, bufferedImage.getHeight() / 2, BufferedImage.TYPE_INT_RGB);
|
||||||
|
Graphics2D g2 = resized.createGraphics();
|
||||||
|
g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
|
||||||
|
g2.drawImage(bufferedImage, 0, 0, bufferedImage.getWidth() / 2, bufferedImage.getHeight() / 2, null);
|
||||||
|
g2.dispose();
|
||||||
|
return resized;
|
||||||
|
}
|
||||||
|
|
||||||
public static <T> T getOrDefault(CompletableFuture<T> future, T defaultValue, int timeoutInSeconds) {
|
public static <T> T getOrDefault(CompletableFuture<T> future, T defaultValue, int timeoutInSeconds) {
|
||||||
try {
|
try {
|
||||||
return future.get(timeoutInSeconds, TimeUnit.SECONDS);
|
return future.get(timeoutInSeconds, TimeUnit.SECONDS);
|
||||||
|
|
Loading…
Reference in a new issue