From e9e4f9ae91391c03cfd980b7effacb95f290cc03 Mon Sep 17 00:00:00 2001 From: Fallen_Breath Date: Fri, 6 Dec 2024 02:31:41 +0800 Subject: [PATCH] (mc1.20.2+) fix `playerSkinBlockingLoading` causing the client to get stuck forever --- .../PlayerSkinProviderMixin.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/versions/1.20.2/src/main/java/me/fallenbreath/tweakermore/mixins/tweaks/mc_tweaks/playerSkinBlockingLoading/PlayerSkinProviderMixin.java b/versions/1.20.2/src/main/java/me/fallenbreath/tweakermore/mixins/tweaks/mc_tweaks/playerSkinBlockingLoading/PlayerSkinProviderMixin.java index f49e9ffd..2017d374 100644 --- a/versions/1.20.2/src/main/java/me/fallenbreath/tweakermore/mixins/tweaks/mc_tweaks/playerSkinBlockingLoading/PlayerSkinProviderMixin.java +++ b/versions/1.20.2/src/main/java/me/fallenbreath/tweakermore/mixins/tweaks/mc_tweaks/playerSkinBlockingLoading/PlayerSkinProviderMixin.java @@ -20,7 +20,7 @@ package me.fallenbreath.tweakermore.mixins.tweaks.mc_tweaks.playerSkinBlockingLoading; -import com.llamalad7.mixinextras.injector.ModifyReturnValue; +import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import me.fallenbreath.conditionalmixin.api.annotation.Condition; import me.fallenbreath.conditionalmixin.api.annotation.Restriction; import me.fallenbreath.tweakermore.config.TweakerMoreConfigs; @@ -43,12 +43,18 @@ @Mixin(targets = "net/minecraft/client/texture/PlayerSkinProvider$1") // the CacheLoader subclass in PlayerSkinProvider's constructor public abstract class PlayerSkinProviderMixin { - @ModifyReturnValue(method = "load(Ljava/lang/Object;)Ljava/lang/Object;", at = @At(value = "TAIL")) - private Object playerSkinBlockingLoading_blockingProfileFetching(Object completableFuture) + @ModifyExpressionValue( + method = "load(Lnet/minecraft/client/texture/PlayerSkinProvider$Key;)Ljava/util/concurrent/CompletableFuture;", + at = @At( + value = "INVOKE", + target = "Ljava/util/concurrent/CompletableFuture;supplyAsync(Ljava/util/function/Supplier;Ljava/util/concurrent/Executor;)Ljava/util/concurrent/CompletableFuture;" + ) + ) + private CompletableFuture playerSkinBlockingLoading_blockingProfileFetching(CompletableFuture completableFuture) { if (TweakerMoreConfigs.PLAYER_SKIN_BLOCKING_LOADING.getBooleanValue()) { - completableFuture = TaskSynchronizer.createSyncedFuture((CompletableFuture)completableFuture); + completableFuture = TaskSynchronizer.createSyncedFuture(completableFuture); } return completableFuture; }