public ThreadDownloadImageData downloadCape() { try { File capeFile = new File(resourceLocation.getResourcePath() + ".png"); if(capeFile.exists()) { capeFile.delete(); } TextureManager manager = Minecraft.getMinecraft().getTextureManager(); ThreadDownloadImageData data = new ThreadDownloadImageData(capeFile, staticCapeUrl, null, null); manager.loadTexture(resourceLocation, data); return data; } catch(Exception e) { e.printStackTrace(); } return null; }
/** * Fetches a cape for the given player and stores it's ResourceLocation in * the capes map * * @param uuid UUID of the player to load the cape for */ public static void loadCape(final UUID uuid) { if (CapesAPI.hasPendingRequests(uuid)) { return; } CapesAPI.setCape(uuid, null); String url = String.format(CapesAPI.BASE_URL, uuid); ResourceLocation resourceLocation = new ResourceLocation( String.format("capesapi/capes/%s.png", new Date().getTime()) ); TextureManager textureManager = Minecraft.getMinecraft().getTextureManager(); ThreadDownloadImageData threadDownloadImageData = new ThreadDownloadImageData(null, url, null, new IImageBuffer() { @Override public BufferedImage parseUserSkin(BufferedImage image) { return image; } @Override public void skinAvailable() { CapesAPI.setCape(uuid, resourceLocation); // useless reloading Image whenever a Player dies, joins, leaves and re-enters Render range // CapesAPI.pendingRequests.remove(uuid); } }); textureManager.loadTexture(resourceLocation, threadDownloadImageData); CapesAPI.pendingRequests.add(uuid); }
@Nullable private BufferedImage getBufferedImage(@Nonnull ResourceLocation textureResourceLocation) { BufferedImage skinImage = null; try { IResource skin = Minecraft.getMinecraft().getResourceManager().getResource(textureResourceLocation); skinImage = TextureUtil.readBufferedImage(skin.getInputStream()); MineLittlePony.logger.debug("Obtained skin from resource location {}", textureResourceLocation); // this.checkSkin(skinImage); } catch (IOException e) { try { ITextureObject e2 = Minecraft.getMinecraft().getTextureManager().getTexture(textureResourceLocation); if (e2 instanceof ThreadDownloadImageData) { skinImage = PonyFields.downloadedImage.get((ThreadDownloadImageData) e2); if (skinImage != null) { MineLittlePony.logger.debug("Successfully reflected downloadedImage from texture object", e); // this.checkSkin(skinImage); } } else if (e2 instanceof ThreadDownloadImageETag) { skinImage = ((ThreadDownloadImageETag) e2).getBufferedImage(); } else if (e2 instanceof DynamicTextureImage) { skinImage = ((DynamicTextureImage) e2).getImage(); } } catch (Exception ignored) { } } return skinImage; }
public void setURL (URL url) { if (url == null) { this.texture = null; return; } this.texture = new ThreadDownloadImageData(null, url.toString(), null, new HDImageBuffer()); }
public static ThreadDownloadImageData getDownloadImageSkin( ResourceLocation par0ResourceLocation, String par1Str) { String theUrl = ""; if (par1Str.matches("\\d{10,}")) { theUrl = getSkindexUrl(par1Str); } else { theUrl = getSkinUrl(par1Str); } return getDownloadImage(par0ResourceLocation, theUrl, locationStevePng, new ImageBufferDownload()); }
public void setURL(URL url) { if (url == null) { this.texture = null; return; } this.texture = new ThreadDownloadImageData(null, url.toString(), null, new HDImageBuffer()); }
/** * Adds capes to our team Player Entities. May become invalid as soon as the * UUID system is fully implemented by Mojang. */ @Override public void registerTeamCapes() { final String capeURL = "http://www.mccapes.com/GalleryImages6x/0c1865261d2d0247fb6b776bdc5d6730.png"; // Temporary. // Can // someone // make // us // a // proper // cape? // We // should // be // able // to // have // a // HD // one // I // think! String[] teamMembers = { "nxsupert, ProfessorVennie", "roborave", "InternetAthiest", "MushroomLT" }; // Please add your minecraft user names // here. You will get a cape if you do so! ThreadDownloadImageData capeImage = new ThreadDownloadImageData( capeURL, null, null); Minecraft mcInstance = Minecraft.getMinecraft(); for (String username : teamMembers) { mcInstance.renderEngine.loadTexture(new ResourceLocation("cloaks/" + username), capeImage); } }
public void run() { HttpURLConnection var1 = null; try { var1 = (HttpURLConnection)(new URL(ThreadDownloadImageData.func_110554_a(this.field_110932_a))).openConnection(Minecraft.func_71410_x().func_110437_J()); var1.setDoInput(true); var1.setDoOutput(false); var1.connect(); if(var1.getResponseCode() / 100 != 2) { return; } BufferedImage var2 = ImageIO.read(var1.getInputStream()); if(ThreadDownloadImageData.func_110555_b(this.field_110932_a) != null) { var2 = ThreadDownloadImageData.func_110555_b(this.field_110932_a).func_78432_a(var2); } this.field_110932_a.func_110556_a(var2); } catch (Exception var6) { var6.printStackTrace(); } finally { if(var1 != null) { var1.disconnect(); } } }
@Override public void loadTexture(AbstractClientPlayer player) { if (this.texture == null) { this.texture = readImageData(capeImage); } ThreadDownloadImageData data = player.getTextureCape(); data.setBufferedImage(this.capeImage); TextureUtil.uploadTexture(data.getGlTextureId(), this.texture, capeImage.getWidth(), capeImage.getHeight()); }
/** * Object constructor. */ private DevCapes() { users = new HashMap<String, String>(); capeResources = new HashMap<String, ResourceLocation>(); downloadThreads = new HashMap<String, ThreadDownloadImageData>(); }
/** * Adds an ThreadDownloadImageData. Needed to change cape. * * @param parGroup * @param parResource */ void addDownloadThread(String parGroup, ThreadDownloadImageData parResource) { if (getDownloadThread(parGroup) == null) { downloadThreads.put(parGroup, parResource); } }
/** * Used to download images. Copied from AbstractClientPlayer to remove * a conditional. * * @param par0ResourceLocation * @param par1Str * @param par2ResourceLocation * @param par3IImageBuffer * @return */ private static ThreadDownloadImageData makeDownloadThread(ResourceLocation par0ResourceLocation, String par1Str, ResourceLocation par2ResourceLocation, IImageBuffer par3IImageBuffer) { TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager(); TextureObject object = new ThreadDownloadImageData(par1Str, par2ResourceLocation, par3IImageBuffer); // Binds ResourceLocation to this. texturemanager.loadTexture(par0ResourceLocation, object); return (ThreadDownloadImageData) object; }
/** * May download the skin if its not in the cache, can be passed a SkinManager#SkinAvailableCallback for handling */ public ResourceLocation loadSkin(final MinecraftProfileTexture profileTexture, final Type p_152789_2_, final SkinManager.SkinAvailableCallback skinAvailableCallback) { final ResourceLocation resourcelocation = new ResourceLocation("skins/" + profileTexture.getHash()); ITextureObject itextureobject = this.textureManager.getTexture(resourcelocation); if (itextureobject != null) { if (skinAvailableCallback != null) { skinAvailableCallback.skinAvailable(p_152789_2_, resourcelocation, profileTexture); } } else { File file1 = new File(this.skinCacheDir, profileTexture.getHash().length() > 2 ? profileTexture.getHash().substring(0, 2) : "xx"); File file2 = new File(file1, profileTexture.getHash()); final IImageBuffer iimagebuffer = p_152789_2_ == Type.SKIN ? new ImageBufferDownload() : null; ThreadDownloadImageData threaddownloadimagedata = new ThreadDownloadImageData(file2, profileTexture.getUrl(), DefaultPlayerSkin.getDefaultSkinLegacy(), new IImageBuffer() { public BufferedImage parseUserSkin(BufferedImage image) { if (iimagebuffer != null) { image = iimagebuffer.parseUserSkin(image); } return image; } public void skinAvailable() { if (iimagebuffer != null) { iimagebuffer.skinAvailable(); } if (skinAvailableCallback != null) { skinAvailableCallback.skinAvailable(p_152789_2_, resourcelocation, profileTexture); } } }); this.textureManager.loadTexture(resourcelocation, threaddownloadimagedata); } return resourcelocation; }
public static void downloadCape(final AbstractClientPlayer p_downloadCape_0_) { String s = p_downloadCape_0_.getNameClear(); if (s != null && !s.isEmpty()) { String s1 = "http://s.optifine.net/capes/" + s + ".png"; String s2 = FilenameUtils.getBaseName(s1); final ResourceLocation resourcelocation = new ResourceLocation("capeof/" + s2); TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager(); ITextureObject itextureobject = texturemanager.getTexture(resourcelocation); if (itextureobject != null && itextureobject instanceof ThreadDownloadImageData) { ThreadDownloadImageData threaddownloadimagedata = (ThreadDownloadImageData)itextureobject; if (threaddownloadimagedata.imageFound != null) { if (threaddownloadimagedata.imageFound.booleanValue()) { p_downloadCape_0_.setLocationOfCape(resourcelocation); } return; } } IImageBuffer iimagebuffer = new IImageBuffer() { ImageBufferDownload ibd = new ImageBufferDownload(); public BufferedImage parseUserSkin(BufferedImage image) { return CapeUtils.parseCape(image); } public void skinAvailable() { p_downloadCape_0_.setLocationOfCape(resourcelocation); } }; ThreadDownloadImageData threaddownloadimagedata1 = new ThreadDownloadImageData((File)null, s1, (ResourceLocation)null, iimagebuffer); threaddownloadimagedata1.pipeline = true; texturemanager.loadTexture(resourcelocation, threaddownloadimagedata1); } }
private void downloadCape(String p_downloadCape_1_) { if (p_downloadCape_1_ != null && !p_downloadCape_1_.isEmpty()) { p_downloadCape_1_ = StringUtils.stripControlCodes(p_downloadCape_1_); String s = "http://s.optifine.net/capes/" + p_downloadCape_1_ + ".png"; String s1 = FilenameUtils.getBaseName(s); final ResourceLocation resourcelocation = new ResourceLocation("capeof/" + s1); TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager(); ITextureObject itextureobject = texturemanager.getTexture(resourcelocation); if (itextureobject != null && itextureobject instanceof ThreadDownloadImageData) { ThreadDownloadImageData threaddownloadimagedata = (ThreadDownloadImageData)itextureobject; if (threaddownloadimagedata.imageFound != null) { if (threaddownloadimagedata.imageFound.booleanValue()) { this.ofLocationCape = resourcelocation; } return; } } IImageBuffer iimagebuffer = new IImageBuffer() { ImageBufferDownload ibd = new ImageBufferDownload(); public BufferedImage parseUserSkin(BufferedImage image) { return AbstractClientPlayer.this.parseCape(image); } public void skinAvailable() { AbstractClientPlayer.this.ofLocationCape = resourcelocation; } }; ThreadDownloadImageData threaddownloadimagedata1 = new ThreadDownloadImageData((File)null, s, (ResourceLocation)null, iimagebuffer); texturemanager.loadTexture(resourcelocation, threaddownloadimagedata1); } }
/** * May download the skin if its not in the cache, can be passed a SkinManager#SkinAvailableCallback for handling */ public ResourceLocation loadSkin(final MinecraftProfileTexture profileTexture, final Type textureType, @Nullable final SkinManager.SkinAvailableCallback skinAvailableCallback) { final ResourceLocation resourcelocation = new ResourceLocation("skins/" + profileTexture.getHash()); ITextureObject itextureobject = this.textureManager.getTexture(resourcelocation); if (itextureobject != null) { if (skinAvailableCallback != null) { skinAvailableCallback.skinAvailable(textureType, resourcelocation, profileTexture); } } else { File file1 = new File(this.skinCacheDir, profileTexture.getHash().length() > 2 ? profileTexture.getHash().substring(0, 2) : "xx"); File file2 = new File(file1, profileTexture.getHash()); final IImageBuffer iimagebuffer = textureType == Type.SKIN ? new ImageBufferDownload() : null; ThreadDownloadImageData threaddownloadimagedata = new ThreadDownloadImageData(file2, profileTexture.getUrl(), DefaultPlayerSkin.getDefaultSkinLegacy(), new IImageBuffer() { public BufferedImage parseUserSkin(BufferedImage image) { if (iimagebuffer != null) { image = iimagebuffer.parseUserSkin(image); } return image; } public void skinAvailable() { if (iimagebuffer != null) { iimagebuffer.skinAvailable(); } if (skinAvailableCallback != null) { skinAvailableCallback.skinAvailable(textureType, resourcelocation, profileTexture); } } }); this.textureManager.loadTexture(resourcelocation, threaddownloadimagedata); } return resourcelocation; }
public static ThreadDownloadImageData getDownloadImageFace(ResourceLocation par0ResourceLocation, String par1Str, MCAPIType type, int size, boolean helmet) { ResourceLocation defaultF = new ResourceLocation(String.format("crystalmod:textures/misc/steve_face_%s.png", type.ending)); return getDownloadImage(par0ResourceLocation, getFaceUrl(par1Str, type, size, helmet), defaultF, new ImageBufferFaceLarge(size, size)); }
public static ThreadDownloadImageData getDownloadImagePlayer(ResourceLocation par0ResourceLocation, String par1Str, MCAPIType type, int size, boolean helmet) { ResourceLocation defaultF = new ResourceLocation(String.format("crystalmod:textures/misc/steve_%s.png", type.ending)); return getDownloadImage(par0ResourceLocation, getPlayerUrl(par1Str, type, size, helmet), defaultF, new ImageBufferFaceLarge(size, size*2)); }
public ThreadDownloadImageData getImage() { return capeImage; }
public ThreadDownloadImageData getTextureSkin() { return this.downloadImageSkin; }
public ThreadDownloadImageData getTextureCape() { return this.downloadImageCape; }
public static ThreadDownloadImageData getDownloadImageSkin(ResourceLocation par0ResourceLocation, String par1Str) { return getDownloadImage(par0ResourceLocation, getSkinUrl(par1Str), locationStevePng, new ImageBufferDownload()); }
public static ThreadDownloadImageData getDownloadImageCape(ResourceLocation par0ResourceLocation, String par1Str) { return getDownloadImage(par0ResourceLocation, getCapeUrl(par1Str), (ResourceLocation)null, (IImageBuffer)null); }
public ThreadDownloadImage(ThreadDownloadImageData parent, String urlStr, IImageBuffer imageBuffer) { this.parent = parent; this.urlStr = urlStr; this.imageBuffer = imageBuffer; }
private static ThreadDownloadImageData getTextureSkin(String player) { return downloadThreads.get(player); }
private static ThreadDownloadImageData getDownloadImageSkin(ResourceLocation par0ResourceLocation, String par1Str) { return getDownloadImage(par0ResourceLocation, getSkinUrl(par1Str), STEVE, new ImageBufferDownload()); }
public static BufferedImage getImage(IResourceManager resourceManager, ResourceLocation location, Logger logger) throws IOException { ITextureObject textureObject = Minecraft.getMinecraft().getTextureManager().getTexture(location); if (textureObject instanceof ThreadDownloadImageData) { return ReflectionHelper.getPrivateValue(ThreadDownloadImageData.class, (ThreadDownloadImageData) textureObject, "bufferedImage", "field_110560_d"); } else if (textureObject instanceof LayeredTexture) { BufferedImage bufferedimage = null; for (Object layeredTextureNameObj : ((LayeredTexture) textureObject).layeredTextureNames) { String layeredTextureName = (String) layeredTextureNameObj; if (layeredTextureName != null) { try (InputStream inputstream = resourceManager.getResource(new ResourceLocation(layeredTextureName)).getInputStream()) { BufferedImage bufferImageLayer = ImageIO.read(inputstream); if (bufferedimage == null) { bufferedimage = new BufferedImage(bufferImageLayer.getWidth(), bufferImageLayer.getHeight(), 2); } bufferedimage.getGraphics().drawImage(bufferImageLayer, 0, 0, null); } } } return bufferedimage; } else if (textureObject instanceof PreBufferedTexture) { return ((PreBufferedTexture) textureObject).getBufferedImage(); } else { IResource iresource = resourceManager.getResource(location); try (InputStream inputstream = iresource.getInputStream()) { return ImageIO.read(inputstream); } } }
public ResourceLocation func_152789_a(MinecraftProfileTexture p_152789_1_, final Type p_152789_2_, final SkinManager.SkinAvailableCallback p_152789_3_) { final ResourceLocation resourcelocation = new ResourceLocation("skins/" + p_152789_1_.getHash()); ITextureObject itextureobject = this.field_152795_c.getTexture(resourcelocation); if (itextureobject != null) { if (p_152789_3_ != null) { p_152789_3_.func_152121_a(p_152789_2_, resourcelocation); } } else { File file1 = new File(this.field_152796_d, p_152789_1_.getHash().substring(0, 2)); File file2 = new File(file1, p_152789_1_.getHash()); final ImageBufferDownload imagebufferdownload = p_152789_2_ == Type.SKIN ? new ImageBufferDownload() : null; ThreadDownloadImageData threaddownloadimagedata = new ThreadDownloadImageData(file2, p_152789_1_.getUrl(), field_152793_a, new IImageBuffer() { private static final String __OBFID = "CL_00001828"; public BufferedImage parseUserSkin(BufferedImage p_78432_1_) { if (imagebufferdownload != null) { p_78432_1_ = imagebufferdownload.parseUserSkin(p_78432_1_); } return p_78432_1_; } public void func_152634_a() { if (imagebufferdownload != null) { imagebufferdownload.func_152634_a(); } if (p_152789_3_ != null) { p_152789_3_.func_152121_a(p_152789_2_, resourcelocation); } } }); this.field_152795_c.loadTexture(resourcelocation, threaddownloadimagedata); } return resourcelocation; }
public ThreadDownloadImageData func_110309_l() { return this.field_110316_a; }