diff options
author | Glease <4586901+Glease@users.noreply.github.com> | 2023-10-21 21:27:00 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-21 15:27:00 +0200 |
commit | 7362ffc43837d3e28ef86cdc6347c271f1e35895 (patch) | |
tree | 73cf8bc8d9e148a9f1f8d328263234890adebc59 /src/main | |
parent | fbdbb388c369fae549cfde3eed38b536f7461d90 (diff) | |
download | GT5-Unofficial-7362ffc43837d3e28ef86cdc6347c271f1e35895.tar.gz GT5-Unofficial-7362ffc43837d3e28ef86cdc6347c271f1e35895.tar.bz2 GT5-Unofficial-7362ffc43837d3e28ef86cdc6347c271f1e35895.zip |
asynchronous cape download (#770)
* asynchronous cape download
* spotlessApply (#771)
Co-authored-by: GitHub GTNH Actions <>
---------
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/gtPlusPlus/xmod/gregtech/common/render/GTPP_CapeRenderer.java | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/render/GTPP_CapeRenderer.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/render/GTPP_CapeRenderer.java index 6344632a6b..1e097f910b 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/render/GTPP_CapeRenderer.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/render/GTPP_CapeRenderer.java @@ -7,6 +7,7 @@ import java.io.InputStream; import java.net.URL; import java.util.Date; import java.util.List; +import java.util.concurrent.ForkJoinPool; import net.minecraft.client.entity.AbstractClientPlayer; import net.minecraft.client.model.ModelBiped; @@ -80,6 +81,14 @@ public class GTPP_CapeRenderer extends RenderPlayer { return; } + if (!CapeUtils.mapsPopulated) { + if (!CapeUtils.cacheReady) { + return; + } + CapeUtils.writeCacheToMaps(); + CapeUtils.mapsPopulated = true; + } + // We have already checked if this player has a cape, but since they do not, we best not render. if (hasResourceChecked) { if (!hasCape && !CORE.DEVENV) { @@ -233,6 +242,8 @@ public class GTPP_CapeRenderer extends RenderPlayer { private static char SPLIT_CHARACTER = 'ยง'; private static AES sAES; + private static volatile boolean cacheReady = false; + private static boolean mapsPopulated = false; // UUID - Username private static final AutoMap<Pair<String, String>> mOrangeCapes = new AutoMap<>(); @@ -246,14 +257,14 @@ public class GTPP_CapeRenderer extends RenderPlayer { if (CORE.DEVENV) { return true; } - try { - if (shouldDownloadCapeList()) { - downloadCapeList(); - } - } catch (Exception e) { - return false; - } - writeCacheToMaps(); + ForkJoinPool.commonPool().execute(() -> { + try { + if (shouldDownloadCapeList()) { + downloadCapeList(); + } + } catch (Exception ignored) {} + cacheReady = true; + }); return true; } |