From 219193a53e604fd0a607968495e6ebd3823f4375 Mon Sep 17 00:00:00 2001 From: Sollace Date: Tue, 11 Apr 2023 16:50:08 +0200 Subject: [PATCH] Fixed preview skins on 1.19.2 --- .../api/pony/DefaultPonySkinHelper.java | 23 +++++++++++++------ .../client/hdskins/PonyPreview.java | 3 ++- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/minelittlepony/api/pony/DefaultPonySkinHelper.java b/src/main/java/com/minelittlepony/api/pony/DefaultPonySkinHelper.java index bdd4b331..c2445fbb 100644 --- a/src/main/java/com/minelittlepony/api/pony/DefaultPonySkinHelper.java +++ b/src/main/java/com/minelittlepony/api/pony/DefaultPonySkinHelper.java @@ -1,20 +1,29 @@ package com.minelittlepony.api.pony; +import net.minecraft.client.util.DefaultSkinHelper; import net.minecraft.util.Identifier; -import java.util.HashMap; -import java.util.Map; +import com.minelittlepony.client.MineLittlePony; +import com.minelittlepony.settings.PonyLevel; + +import java.util.*; public final class DefaultPonySkinHelper { public static final Identifier STEVE = new Identifier("minelittlepony", "textures/entity/player/wide/steve_pony.png"); - private static final Map SKINS = new HashMap<>(); + @Deprecated + public static final Identifier ALEX = new Identifier("minelittlepony", "textures/entity/player/slim/alex_pony.png"); public static Identifier getPonySkin(Identifier original) { - return SKINS.computeIfAbsent(original, DefaultPonySkinHelper::computePonySkin); + return original.getPath().contains("steve") ? STEVE : ALEX; } - private static Identifier computePonySkin(Identifier original) { - return new Identifier("minelittlepony", original.getPath().replace(".png", "_pony.png")); - } + @Deprecated + public static Identifier getPonySkin(UUID profileId, boolean slimArms) { + if (MineLittlePony.getInstance().getConfig().ponyLevel.get() != PonyLevel.PONIES) { + return DefaultSkinHelper.getTexture(profileId); + } + boolean alex = (profileId.hashCode() & 1) == 1; + return new Identifier("minelittlepony", "textures/entity/player/" + (slimArms ? "slim" : "wide") + "/" + (alex ? "alex" : "steve") + "_pony.png"); + } } diff --git a/src/main/java/com/minelittlepony/client/hdskins/PonyPreview.java b/src/main/java/com/minelittlepony/client/hdskins/PonyPreview.java index f26ee06b..a90d1f76 100644 --- a/src/main/java/com/minelittlepony/client/hdskins/PonyPreview.java +++ b/src/main/java/com/minelittlepony/client/hdskins/PonyPreview.java @@ -40,7 +40,8 @@ class PonyPreview extends PlayerPreview { return DefaultSkinGenerator.generateGreyScale(wearable.getDefaultTexture(), wearable.getDefaultTexture(), getExclusion()); } - return super.getDefaultSkin(type, slim); + Identifier skin = getBlankSkin(type, slim); + return DefaultSkinGenerator.generateGreyScale(type == SkinType.SKIN ? DefaultPonySkinHelper.getPonySkin(profile.getId(), slim) : skin, skin, getExclusion()); } @Override