Fixed embedded wearables not using the correct textures in the preview

This commit is contained in:
Sollace 2022-12-10 21:47:34 +00:00
parent 26985b9165
commit 95ebace010
2 changed files with 15 additions and 1 deletions

View file

@ -7,6 +7,8 @@ import com.minelittlepony.client.model.gear.SaddleBags;
import com.minelittlepony.common.util.Color; import com.minelittlepony.common.util.Color;
import java.util.*; import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
public enum Wearable implements TriggerPixelType<Wearable> { public enum Wearable implements TriggerPixelType<Wearable> {
NONE (0x00, null), NONE (0x00, null),
@ -26,6 +28,7 @@ public enum Wearable implements TriggerPixelType<Wearable> {
private final Identifier texture; private final Identifier texture;
public static final List<Wearable> VALUES = Arrays.stream(values()).toList(); public static final List<Wearable> VALUES = Arrays.stream(values()).toList();
public static final Map<Identifier, Wearable> REGISTRY = VALUES.stream().collect(Collectors.toMap(Wearable::getId, Function.identity()));
Wearable(int pixel, Identifier texture) { Wearable(int pixel, Identifier texture) {
triggerValue = pixel; triggerValue = pixel;

View file

@ -1,5 +1,6 @@
package com.minelittlepony.client.hdskins; package com.minelittlepony.client.hdskins;
import com.minelittlepony.api.pony.IPony;
import com.minelittlepony.api.pony.meta.Wearable; import com.minelittlepony.api.pony.meta.Wearable;
import com.minelittlepony.client.MineLittlePony; import com.minelittlepony.client.MineLittlePony;
import com.minelittlepony.client.SkinsProxy; import com.minelittlepony.client.SkinsProxy;
@ -8,6 +9,7 @@ import com.minelittlepony.common.client.gui.element.Button;
import com.minelittlepony.common.event.ClientReadyCallback; import com.minelittlepony.common.event.ClientReadyCallback;
import com.minelittlepony.hdskins.client.*; import com.minelittlepony.hdskins.client.*;
import com.minelittlepony.hdskins.client.dummy.DummyPlayer; import com.minelittlepony.hdskins.client.dummy.DummyPlayer;
import com.minelittlepony.hdskins.client.dummy.PlayerSkins.PlayerSkin;
import com.minelittlepony.hdskins.client.gui.GuiSkins; import com.minelittlepony.hdskins.client.gui.GuiSkins;
import com.minelittlepony.hdskins.profile.SkinType; import com.minelittlepony.hdskins.profile.SkinType;
@ -91,7 +93,16 @@ public class MineLPHDSkins extends SkinsProxy implements ClientModInitializer {
private Optional<Identifier> getSkin(SkinType type, AbstractClientPlayerEntity player) { private Optional<Identifier> getSkin(SkinType type, AbstractClientPlayerEntity player) {
if (player instanceof DummyPlayer dummy) { if (player instanceof DummyPlayer dummy) {
return Optional.of(dummy.getTextures().get(type).getId()); PlayerSkin skin = dummy.getTextures().get(type);
if (skin.isReady()) {
return Optional.of(skin.getId());
}
PlayerSkin main = dummy.getTextures().get(SkinType.SKIN);
if (IPony.getManager().getPony(main.getId()).metadata().isWearing(Wearable.REGISTRY.getOrDefault(type.getId(), Wearable.NONE))) {
return Optional.of(main.getId());
}
} }
return Optional.of(player).map(PlayerSkins::of).map(skins -> skins.getSkin(type)); return Optional.of(player).map(PlayerSkins::of).map(skins -> skins.getSkin(type));