Skip to content

Commit

Permalink
Fix #78 (default to the wide arm model if the server fails to specify)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sollace committed Nov 27, 2024
1 parent 2497aec commit 90213f6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.minelittlepony.hdskins.Memoize;
import com.minelittlepony.hdskins.client.HDSkins;
import com.minelittlepony.hdskins.client.SkinCacheClearCallback;
import com.minelittlepony.hdskins.client.VanillaModels;
import com.minelittlepony.hdskins.profile.SkinType;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
Expand Down Expand Up @@ -71,7 +72,7 @@ private CompletableFuture<ProvidedSkins> fetchTextures(Map<SkinType, MinecraftPr

return CompletableFuture.allOf(tasks.values().stream().toArray(CompletableFuture[]::new)).thenApply(nothing -> {
return new ProvidedSkins(
Optional.ofNullable(textures.get(SkinType.SKIN)).map(skin -> skin.getMetadata("model")),
Optional.ofNullable(textures.get(SkinType.SKIN)).map(skin -> VanillaModels.of(skin.getMetadata("model"))),
tasks.keySet().stream().map(SkinType::getId).collect(Collectors.toSet()),
tasks.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, entry -> {
return entry.getValue().join();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import org.jetbrains.annotations.Nullable;

import com.minelittlepony.hdskins.client.VanillaModels;
import com.minelittlepony.hdskins.profile.SkinType;

import net.minecraft.client.MinecraftClient;
Expand Down Expand Up @@ -40,15 +39,13 @@ public boolean isLoaded() {

abstract class UriTexture extends HDPlayerSkinTexture implements Texture {

private final String model;

private final String fileUrl;

private final Identifier id;

public static Texture.UriTexture create(Identifier id, File cacheFile, String url, SkinType type, String model, Identifier fallback, @Nullable Runnable callback) {
boolean[] uploaded = new boolean[1];
return new UriTexture(id, cacheFile, url, type, model, fallback, () -> {
return new UriTexture(id, cacheFile, url, type, fallback, () -> {
uploaded[0] = true;
if (callback != null) {
callback.run();
Expand All @@ -67,10 +64,9 @@ public void clearGlId() {
};
}

UriTexture(Identifier id, File cacheFile, String url, SkinType type, String model, Identifier fallback, Runnable callack) {
UriTexture(Identifier id, File cacheFile, String url, SkinType type, Identifier fallback, Runnable callack) {
super(cacheFile, url, type, fallback, callack);
this.id = id;
this.model = VanillaModels.of(model);
this.fileUrl = url;
}

Expand All @@ -84,14 +80,6 @@ public InputStream openStream() throws IOException {
return new URL(fileUrl).openStream();
}

public boolean hasModel() {
return model != null;
}

public boolean usesThinArms() {
return VanillaModels.isSlim(model);
}

@Override
protected TextureData loadTextureData(ResourceManager resourceManager) {
if (!resourceManager.getResource(location).isPresent()) {
Expand Down

0 comments on commit 90213f6

Please sign in to comment.