Posted July 24, 20178 yr 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(); } } }
July 24, 20178 yr You shouldn't use custom capes website or something unless you are going to use advanced capes mod; thats fine. Dont get messed will all that code.
July 24, 20178 yr 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 July 24, 20178 yr 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.