net.minecraft.client.renderer.ThreadDownloadImageData Java Examples

The following examples show how to use net.minecraft.client.renderer.ThreadDownloadImageData. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StaticCape.java    From DeveloperCapes with MIT License 5 votes vote down vote up
public void setURL(URL url) {
    if (url == null) {
        this.texture = null;
        return;
    }
    this.texture = new ThreadDownloadImageData(null, url.toString(), null, new HDImageBuffer());
}
 
Example #2
Source File: HyperiumCapeHandler.java    From Hyperium with GNU Lesser General Public License v3.0 4 votes vote down vote up
public HyperiumCapeHandler(GameProfile profile) {
    Multithreading.runAsync(() -> {
        HyperiumPurchase purchase = PurchaseApi.getInstance().getPackageSync(profile.getId());
        JsonHolder holder = purchase.getPurchaseSettings().optJSONObject("cape");
        String type = holder.optString("type");
        String url = null;

        if (type.equals("CUSTOM_IMAGE")) {
            url = holder.optString("url");
        } else if (!type.isEmpty()) {
            JsonHolder atlasHolder = PurchaseApi.getInstance().getCapeAtlas().optJSONObject(type);
            url = atlasHolder.optString("url");
            if (url.isEmpty()) return;
        }

        ResourceLocation resourceLocation = new ResourceLocation(String.format("hyperium/capes/%s.png", profile.getId()));

        TextureManager textureManager = Minecraft.getMinecraft().getTextureManager();
        ThreadDownloadImageData threadDownloadImageData = new ThreadDownloadImageData(null, url, null, new IImageBuffer() {
            @Override
            public BufferedImage parseUserSkin(BufferedImage image) {
                return HyperiumCapeUtils.parseCape(image);
            }

            @Override
            public void skinAvailable() {
                LOCATION_CACHE.add(location = resourceLocation);
                ready = true;
            }
        });

        try {
            textureManager.loadTexture(resourceLocation, threadDownloadImageData);
        } catch (Exception e) {
            e.printStackTrace();
        }
    });
}