Skip to content

Commit

Permalink
Fix a default icons issue in some versions of the game
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaming32 committed Jan 21, 2024
1 parent 9f98557 commit c16a2c0
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions src/main/java/io/github/gaming32/worldhost/WorldHost.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import net.minecraft.client.multiplayer.ServerData;
import net.minecraft.client.multiplayer.resolver.ServerAddress;
import net.minecraft.client.resources.DefaultPlayerSkin;
import net.minecraft.client.resources.PlayerSkin;
import net.minecraft.client.resources.SkinManager;
import net.minecraft.client.server.IntegratedServer;
import net.minecraft.commands.CommandSourceStack;
Expand Down Expand Up @@ -71,12 +70,12 @@
//#else
//$$ import com.mojang.authlib.minecraft.MinecraftProfileTexture;
//$$ import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService;
//$$ import net.minecraft.client.resources.DefaultPlayerSkin;
//$$ import net.minecraft.world.entity.player.Player;
//#endif

//#if MC >= 1.20.2
import com.mojang.authlib.yggdrasil.ProfileResult;
import net.minecraft.client.resources.PlayerSkin;
//#endif

//#if FABRIC
Expand Down Expand Up @@ -499,25 +498,27 @@ public static CompletableFuture<ResourceLocation> getInsecureSkinLocation(GamePr
final SkinManager skinManager = Minecraft.getInstance().getSkinManager();
//#if MC >= 1.20.2
return skinManager.getOrLoad(gameProfile).thenApply(PlayerSkin::texture);
//#elseif MC >= 1.19.2
//$$ return CompletableFuture.completedFuture(skinManager.getInsecureSkinLocation(gameProfile));
//#else
//$$ return CompletableFuture.supplyAsync(() -> {
//$$ //#if MC >= 1.19.2
//$$ //$$ return skinManager.getInsecureSkinLocation(gameProfile);
//$$ //#else
//$$ //$$ final MinecraftProfileTexture texture = skinManager.getInsecureSkinInformation(gameProfile)
//$$ //$$ .get(MinecraftProfileTexture.Type.SKIN);
//$$ //$$ return texture != null
//$$ //$$ ? skinManager.registerTexture(texture, MinecraftProfileTexture.Type.SKIN)
//$$ //$$ : DefaultPlayerSkin.getDefaultSkin(Player.createPlayerUUID(gameProfile));
//$$ //#endif
//$$ }, Util.backgroundExecutor());
//$$ final MinecraftProfileTexture texture = skinManager.getInsecureSkinInformation(gameProfile)
//$$ .get(MinecraftProfileTexture.Type.SKIN);
//$$ return CompletableFuture.completedFuture(
//$$ texture != null
//$$ ? skinManager.registerTexture(texture, MinecraftProfileTexture.Type.SKIN)
//$$ : DefaultPlayerSkin.getDefaultSkin(Player.createPlayerUUID(gameProfile))
//$$ );
//#endif
}

public static ResourceLocation getSkinLocationNow(GameProfile gameProfile) {
final ResourceLocation location = getInsecureSkinLocation(gameProfile).getNow(null);
if (location == null) {
//#if MC >= 1.20.2
return DefaultPlayerSkin.get(gameProfile).texture();
//#else
//$$ return DefaultPlayerSkin.getDefaultSkin(gameProfile.getId());
//#endif
}
return location;
}
Expand Down

0 comments on commit c16a2c0

Please sign in to comment.