Bring in the UI fixes #36
@@ -2,11 +2,17 @@ package org.saturnclient.impl.provider;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.toast.SystemToast;
|
||||
//? if >=1.21.9 {
|
||||
import net.minecraft.entity.player.SkinTextures;
|
||||
//?} else
|
||||
//import net.minecraft.client.util.SkinTextures;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import org.saturnclient.common.provider.SaturnProvider;
|
||||
import org.saturnclient.common.ref.asset.IdentifierRef;
|
||||
@@ -16,6 +22,9 @@ import org.saturnclient.impl.cosmetics.utils.IdentifierUtils;
|
||||
import org.saturnclient.saturnclient.SaturnClient;
|
||||
|
||||
public class SaturnProviderImpl implements SaturnProvider {
|
||||
/** Looks up the signed-in player's skin; made once, since the skin provider caches it */
|
||||
private Supplier<Identifier> playerSkin;
|
||||
|
||||
@Override
|
||||
public MinecraftClientRef getClient() {
|
||||
return (MinecraftClientRef) SaturnClient.client;
|
||||
@@ -50,6 +59,23 @@ public class SaturnProviderImpl implements SaturnProvider {
|
||||
/** Shown longer than the vanilla default, since these ask the player to act. */
|
||||
private static final SystemToast.Type WARNING_TOAST = new SystemToast.Type(15_000L);
|
||||
|
||||
@Override
|
||||
public IdentifierRef getPlayerSkin() {
|
||||
if (playerSkin == null) {
|
||||
MinecraftClient client = MinecraftClient.getInstance();
|
||||
// 1.21.9 moved SkinTextures and renamed the skin provider's lookup.
|
||||
//? if >=1.21.9 {
|
||||
Supplier<SkinTextures> textures = client.getSkinProvider().supplySkinTextures(client.getGameProfile(), false);
|
||||
playerSkin = () -> textures.get().body().texturePath();
|
||||
//?} else {
|
||||
/*Supplier<SkinTextures> textures = client.getSkinProvider().getSkinTexturesSupplier(client.getGameProfile());
|
||||
playerSkin = () -> textures.get().texture();
|
||||
*///?}
|
||||
}
|
||||
|
||||
return (IdentifierRef) (Object) playerSkin.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModVersion() {
|
||||
return FabricLoader.getInstance().getModContainer(SaturnClient.MOD_ID)
|
||||
|
||||
Reference in New Issue
Block a user