Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.Graphics;
- import java.awt.Image;
- import java.awt.image.ImageObserver;
- import java.io.File;
- import java.awt.image.BufferedImage;
- import org.apache.commons.io.FilenameUtils;
- public class CapeUtils {
- public static void downloadCape(final bet player) {
- final String username = player.getNameClear();
- if (username != null && !username.isEmpty()) {
- final String ofCapeUrl = "http://s.optifine.net/capes/" + username + ".png";
- final String mptHash = FilenameUtils.getBaseName(ofCapeUrl);
- final jy rl = new jy("capeof/" + mptHash);
- final bmj textureManager = ave.A().P();
- final bmk tex = textureManager.b(rl);
- if (tex != null && tex instanceof bma) {
- final bma tdid = (bma)tex;
- if (tdid.imageFound != null) {
- if (tdid.imageFound) {
- player.setLocationOfCape(rl);
- }
- return;
- }
- }
- final bfm iib = (bfm)new bfm() {
- bfs ibd = new bfs();
- public BufferedImage a(final BufferedImage var1) {
- return CapeUtils.parseCape(var1);
- }
- public void a() {
- player.setLocationOfCape(rl);
- }
- };
- final bma textureCape = new bma(null, ofCapeUrl, null, iib);
- textureCape.pipeline = true;
- textureManager.a(rl, textureCape);
- }
- }
- public static BufferedImage parseCape(final BufferedImage img) {
- int imageWidth = 64;
- int imageHeight = 32;
- for (int srcWidth = img.getWidth(), srcHeight = img.getHeight(); imageWidth < srcWidth || imageHeight < srcHeight; imageWidth *= 2, imageHeight *= 2) {}
- final BufferedImage imgNew = new BufferedImage(imageWidth, imageHeight, 2);
- final Graphics g = imgNew.getGraphics();
- g.drawImage(img, 0, 0, null);
- g.dispose();
- return imgNew;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement