From e3e7fdc5ad24b67d3d93ce4b0438b2a80ee9e3bc Mon Sep 17 00:00:00 2001 From: CaelTheColher <16297430+CaelTheColher@users.noreply.github.com> Date: Wed, 14 Dec 2022 21:28:59 -0300 Subject: [PATCH] (1.5.1) Move cape loading to its own thread pool (Closes #64 fr this time on god no cap). --- gradle.properties | 2 +- .../java/me/cael/capes/mixins/MixinPlayerListEntry.java | 4 ---- src/main/kotlin/me/cael/capes/handler/PlayerHandler.kt | 7 ++++--- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/gradle.properties b/gradle.properties index 3613637..afd2bb3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -12,7 +12,7 @@ org.gradle.jvmargs=-Xmx2G loom_version=1.0-SNAPSHOT # Mod Properties - mod_version = 1.5+1.19.3 + mod_version = 1.5.1+1.19.3 maven_group = me.cael archives_base_name = capes diff --git a/src/main/java/me/cael/capes/mixins/MixinPlayerListEntry.java b/src/main/java/me/cael/capes/mixins/MixinPlayerListEntry.java index f048a06..e2977df 100644 --- a/src/main/java/me/cael/capes/mixins/MixinPlayerListEntry.java +++ b/src/main/java/me/cael/capes/mixins/MixinPlayerListEntry.java @@ -1,7 +1,6 @@ package me.cael.capes.mixins; import com.mojang.authlib.GameProfile; -import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type; import me.cael.capes.handler.PlayerHandler; import net.minecraft.client.network.PlayerListEntry; import net.minecraft.util.Identifier; @@ -13,12 +12,9 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import java.util.Map; - @Mixin(PlayerListEntry.class) public class MixinPlayerListEntry { @Shadow @Final private GameProfile profile; - @Shadow @Final private Map textures; @Shadow private boolean texturesLoaded; @Inject(method = "loadTextures", at = @At("HEAD")) diff --git a/src/main/kotlin/me/cael/capes/handler/PlayerHandler.kt b/src/main/kotlin/me/cael/capes/handler/PlayerHandler.kt index 42c8bb4..ddff3d5 100644 --- a/src/main/kotlin/me/cael/capes/handler/PlayerHandler.kt +++ b/src/main/kotlin/me/cael/capes/handler/PlayerHandler.kt @@ -19,7 +19,7 @@ import java.io.* import java.net.HttpURLConnection import java.net.URL import java.util.* -import java.util.concurrent.ForkJoinPool +import java.util.concurrent.Executors class PlayerHandler(var profile: GameProfile) { val uuid: UUID = profile.id @@ -36,6 +36,7 @@ class PlayerHandler(var profile: GameProfile) { companion object { val instances = HashMap() + val capeExecutor = Executors.newFixedThreadPool(2) fun fromProfile(profile: GameProfile) = instances[profile.id] ?: PlayerHandler(profile) @@ -45,11 +46,11 @@ class PlayerHandler(var profile: GameProfile) { playerHandler.hasCape = false playerHandler.hasAnimatedCape = false val config = Capes.CONFIG - ForkJoinPool.commonPool().submit { + capeExecutor.submit { playerHandler.setCape(config.clientCapeType) } } else { - ForkJoinPool.commonPool().submit { + capeExecutor.submit { if (profile.id.toString() == "5f91fdfd-ea97-473c-bb77-c8a2a0ed3af9") { playerHandler.setStandardCape(connection("https://athena.wynntils.com/capes/user/${profile.id}")); return@submit } for (capeType in CapeType.values()) { if (playerHandler.setCape(capeType)) break