Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

I make the Custom Cape rendering with PNG image from URL. Current method seems bad performance (And its make game lag 2~ second after finished download texture).

 

Current Code :

 

    public static void setCapeURL(String url, boolean startup)
    {
        URL jurl = null;
        boolean noConnection = false;
        JsonUtil json = new JsonUtil();

        try
        {
            jurl = new URL(url);
        }
        catch (MalformedURLException e)
        {
            noConnection = true;
            e.printStackTrace();
            return;
        }

        if (CapeUtils.textureUploaded && !noConnection)
        {
            try
            {
                CapeUtils.CAPE_TEXTURE.put(GameProfileUtil.getUsername(), new DynamicTexture(ImageIO.read(jurl)));
                ExtendedConfig.CAPE_URL = Base64Utils.encode(url);
                ExtendedConfig.save();
                CapeUtils.textureUploaded = false;
            }
            catch (MalformedURLException e)
            {
                if (IndicatiaMod.MC.player != null)
                {
                    IndicatiaMod.MC.player.sendMessage(json.text("Missing protocol or wrong URL format").setStyle(json.red()));
                }
                e.printStackTrace();
                return;
            }

 

I've changed to use Thread, but I don't know whats wrong with it.

It throw message "No OpenGL context found in the current thread."

 

public class ThreadDownloadedCustomCape extends Thread
{
    @Override
    public void run()
    {
        URL capeUrl = null;

        try
        {
            capeUrl = new URL("http://i.imgur.com/vXgIBgM.png");
            BufferedImage image = ImageIO.read(capeUrl);
            File pngFile = new File(IndicatiaMod.CONFIG, "custom_cape.png");
            ImageIO.write(image, "png", pngFile);
            Thread.sleep(5000);
            new ThreadReadCustomCape().start();
        }
        catch (MalformedURLException e)
        {
            e.printStackTrace();
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }
        catch (InterruptedException e)
        {
            e.printStackTrace();
        }
    }
}

 

public class ThreadReadCustomCape extends Thread
{
    @Override
    public void run()
    {
        try
        {
            File pngFile = new File(IndicatiaMod.CONFIG, "custom_cape.png");

            if (pngFile.exists())
            {
                BufferedImage image = ImageIO.read(pngFile);
                CapeUtils.CAPE_TEXTURE.put(GameProfileUtil.getUsername(), new DynamicTexture(image));
            }
        }
        catch (MalformedURLException e)
        {
            e.printStackTrace();
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }
    }
}

 

Well, yes capes are annoying and they suck I dont know why anyone wants them. But im just sayig mods are a better alternative.

Edited by OfficialZanyman

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.