Update hdskins

This commit is contained in:
Sollace 2022-12-10 21:16:37 +00:00
parent e54b29146a
commit de7253594f
2 changed files with 7 additions and 18 deletions

View file

@ -22,5 +22,5 @@ org.gradle.daemon=false
# Dependencies # Dependencies
modmenu_version=5.0.0-alpha.3 modmenu_version=5.0.0-alpha.3
kirin_version=1.13.0-beta.3 kirin_version=1.13.0-beta.3
hd_skins_version=6.7.0-beta.4 hd_skins_version=6.7.0-beta.5
mson_version=1.7.0-beta.1 mson_version=1.7.0-beta.1

View file

@ -7,17 +7,13 @@ import com.minelittlepony.common.client.gui.ScrollContainer;
import com.minelittlepony.common.client.gui.element.Button; 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.ducks.ClientPlayerInfo;
import com.minelittlepony.hdskins.client.dummy.DummyPlayer; import com.minelittlepony.hdskins.client.dummy.DummyPlayer;
import com.minelittlepony.hdskins.client.gui.GuiSkins; import com.minelittlepony.hdskins.client.gui.GuiSkins;
import com.minelittlepony.hdskins.client.resources.LocalPlayerSkins;
import com.minelittlepony.hdskins.mixin.client.MixinClientPlayer;
import com.minelittlepony.hdskins.profile.SkinType; import com.minelittlepony.hdskins.profile.SkinType;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@ -80,21 +76,14 @@ public class MineLPHDSkins extends SkinsProxy implements ClientModInitializer {
public Set<Identifier> getAvailableSkins(Entity entity) { public Set<Identifier> getAvailableSkins(Entity entity) {
if (entity instanceof DummyPlayer dummy) { if (entity instanceof DummyPlayer dummy) {
return SkinType.REGISTRY.stream() return dummy.getTextures().getProvidedSkinTypes();
.filter(type -> {
return dummy.getTextures().get(type).isReady()
|| (dummy.getTextures().getPosture().getActiveSkinType() == type && dummy.getTextures() instanceof LocalPlayerSkins);
})
.map(SkinType::getId)
.collect(Collectors.toSet());
} }
if (entity instanceof AbstractClientPlayerEntity player) { if (entity instanceof AbstractClientPlayerEntity player) {
PlayerSkins skins = ((ClientPlayerInfo)((MixinClientPlayer)player).getBackingClientData()).getSkins(); PlayerSkins skins = PlayerSkins.of(player);
return SkinType.REGISTRY.stream() if (skins != null) {
.filter(type -> skins.getSkin(type) != null) return skins.getProvidedSkinTypes();
.map(SkinType::getId) }
.collect(Collectors.toSet());
} }
return Set.of(); return Set.of();
@ -105,7 +94,7 @@ public class MineLPHDSkins extends SkinsProxy implements ClientModInitializer {
return Optional.of(dummy.getTextures().get(type).getId()); return Optional.of(dummy.getTextures().get(type).getId());
} }
return Optional.ofNullable(((ClientPlayerInfo)((MixinClientPlayer)player).getBackingClientData()).getSkins().getSkin(type)); return Optional.of(player).map(PlayerSkins::of).map(skins -> skins.getSkin(type));
} }
@Override @Override