Advertisement
Guest User

Untitled

a guest
Oct 18th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 KB | None | 0 0
  1. import java.awt.Graphics;
  2. import java.awt.Image;
  3. import java.awt.image.ImageObserver;
  4. import java.io.File;
  5. import java.awt.image.BufferedImage;
  6. import org.apache.commons.io.FilenameUtils;
  7.  
  8. public class CapeUtils {
  9. public static void downloadCape(final bet player) {
  10. final String username = player.getNameClear();
  11. if (username != null && !username.isEmpty()) {
  12. final String ofCapeUrl = "http://s.optifine.net/capes/" + username + ".png";
  13. final String mptHash = FilenameUtils.getBaseName(ofCapeUrl);
  14. final jy rl = new jy("capeof/" + mptHash);
  15. final bmj textureManager = ave.A().P();
  16. final bmk tex = textureManager.b(rl);
  17. if (tex != null && tex instanceof bma) {
  18. final bma tdid = (bma)tex;
  19. if (tdid.imageFound != null) {
  20. if (tdid.imageFound) {
  21. player.setLocationOfCape(rl);
  22. }
  23. return;
  24. }
  25. }
  26. final bfm iib = (bfm)new bfm() {
  27. bfs ibd = new bfs();
  28.  
  29. public BufferedImage a(final BufferedImage var1) {
  30. return CapeUtils.parseCape(var1);
  31. }
  32.  
  33. public void a() {
  34. player.setLocationOfCape(rl);
  35. }
  36. };
  37. final bma textureCape = new bma(null, ofCapeUrl, null, iib);
  38. textureCape.pipeline = true;
  39. textureManager.a(rl, textureCape);
  40. }
  41. }
  42.  
  43. public static BufferedImage parseCape(final BufferedImage img) {
  44. int imageWidth = 64;
  45. int imageHeight = 32;
  46. for (int srcWidth = img.getWidth(), srcHeight = img.getHeight(); imageWidth < srcWidth || imageHeight < srcHeight; imageWidth *= 2, imageHeight *= 2) {}
  47. final BufferedImage imgNew = new BufferedImage(imageWidth, imageHeight, 2);
  48. final Graphics g = imgNew.getGraphics();
  49. g.drawImage(img, 0, 0, null);
  50. g.dispose();
  51. return imgNew;
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement