Skip to content

Commit

Permalink
(1.5.1) Move cape loading to its own thread pool (Closes #64 fr this …
Browse files Browse the repository at this point in the history
…time on god no cap).
  • Loading branch information
CaelTheColher committed Dec 15, 2022
1 parent 9f96fea commit e3e7fdc
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 0 additions & 4 deletions src/main/java/me/cael/capes/mixins/MixinPlayerListEntry.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<Type, Identifier> textures;
@Shadow private boolean texturesLoaded;

@Inject(method = "loadTextures", at = @At("HEAD"))
Expand Down
7 changes: 4 additions & 3 deletions src/main/kotlin/me/cael/capes/handler/PlayerHandler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -36,6 +36,7 @@ class PlayerHandler(var profile: GameProfile) {

companion object {
val instances = HashMap<UUID, PlayerHandler>()
val capeExecutor = Executors.newFixedThreadPool(2)

fun fromProfile(profile: GameProfile) = instances[profile.id] ?: PlayerHandler(profile)

Expand All @@ -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
Expand Down

0 comments on commit e3e7fdc

Please sign in to comment.