mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-22 12:37:59 +01:00
parent
cae2de5185
commit
08860dd13e
2 changed files with 26 additions and 20 deletions
|
@ -32,6 +32,7 @@ import net.minecraft.util.ResourceLocation;
|
||||||
import org.apache.commons.codec.binary.Base64;
|
import org.apache.commons.codec.binary.Base64;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
|
@ -118,7 +119,7 @@ public final class HDSkinManager implements IResourceManagerReloadListener {
|
||||||
|
|
||||||
private void loadTexture(GameProfile profile, final Type type, final SkinAvailableCallback callback) {
|
private void loadTexture(GameProfile profile, final Type type, final SkinAvailableCallback callback) {
|
||||||
if (profile != null && profile.getId() != null) {
|
if (profile != null && profile.getId() != null) {
|
||||||
Map<Type, MinecraftProfileTexture> data = getProfileData(profile);
|
Map<Type, MinecraftProfileTexture> data = loadProfileData(profile);
|
||||||
final MinecraftProfileTexture texture = data.get(type);
|
final MinecraftProfileTexture texture = data.get(type);
|
||||||
if (texture == null) {
|
if (texture == null) {
|
||||||
return;
|
return;
|
||||||
|
@ -131,8 +132,9 @@ public final class HDSkinManager implements IResourceManagerReloadListener {
|
||||||
ThreadDownloadImageData threaddownloadimagedata = new ThreadDownloadImageData(file2, texture.getUrl(),
|
ThreadDownloadImageData threaddownloadimagedata = new ThreadDownloadImageData(file2, texture.getUrl(),
|
||||||
DefaultPlayerSkin.getDefaultSkinLegacy(),
|
DefaultPlayerSkin.getDefaultSkinLegacy(),
|
||||||
new IImageBuffer() {
|
new IImageBuffer() {
|
||||||
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public BufferedImage parseUserSkin(BufferedImage image) {
|
public BufferedImage parseUserSkin(@Nonnull BufferedImage image) {
|
||||||
if (imagebufferdownload != null)
|
if (imagebufferdownload != null)
|
||||||
return imagebufferdownload.parseUserSkin(image);
|
return imagebufferdownload.parseUserSkin(image);
|
||||||
return image;
|
return image;
|
||||||
|
@ -154,11 +156,15 @@ public final class HDSkinManager implements IResourceManagerReloadListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<Type, MinecraftProfileTexture> getProfileData(GameProfile profile) {
|
public Optional<Map<Type, MinecraftProfileTexture>> getProfileData(GameProfile profile) {
|
||||||
if (!enabled)
|
if (!enabled)
|
||||||
return ImmutableMap.of();
|
return Optional.of(ImmutableMap.of());
|
||||||
Map<Type, MinecraftProfileTexture> textures = this.profileTextures.get(profile.getId());
|
return Optional.ofNullable(this.profileTextures.get(profile.getId()));
|
||||||
if (textures == null) {
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<Type, MinecraftProfileTexture> loadProfileData(final GameProfile profile) {
|
||||||
|
return getProfileData(profile).orElseGet(() -> {
|
||||||
|
|
||||||
String uuid = UUIDTypeAdapter.fromUUID(profile.getId());
|
String uuid = UUIDTypeAdapter.fromUUID(profile.getId());
|
||||||
|
|
||||||
|
@ -170,10 +176,10 @@ public final class HDSkinManager implements IResourceManagerReloadListener {
|
||||||
builder.put(type, new HDProfileTexture(url, hash, null));
|
builder.put(type, new HDProfileTexture(url, hash, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
textures = builder.build();
|
Map<Type, MinecraftProfileTexture> textures = builder.build();
|
||||||
this.profileTextures.put(profile.getId(), textures);
|
this.profileTextures.put(profile.getId(), textures);
|
||||||
}
|
return textures;
|
||||||
return textures;
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Map<Type, MinecraftProfileTexture> getTexturesForProfile(GameProfile profile) {
|
private static Map<Type, MinecraftProfileTexture> getTexturesForProfile(GameProfile profile) {
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package com.voxelmodpack.hdskins.mixin;
|
package com.voxelmodpack.hdskins.mixin;
|
||||||
|
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
|
||||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
|
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
|
||||||
import com.voxelmodpack.hdskins.HDSkinManager;
|
import com.voxelmodpack.hdskins.HDSkinManager;
|
||||||
import net.minecraft.client.network.NetworkPlayerInfo;
|
import net.minecraft.client.network.NetworkPlayerInfo;
|
||||||
|
@ -54,15 +53,16 @@ public abstract class MixinPlayerInfo {
|
||||||
cancellable = true,
|
cancellable = true,
|
||||||
at = @At("RETURN"))
|
at = @At("RETURN"))
|
||||||
private void getSkinType(CallbackInfoReturnable<String> ci) {
|
private void getSkinType(CallbackInfoReturnable<String> ci) {
|
||||||
MinecraftProfileTexture data = HDSkinManager.INSTANCE.getProfileData(getGameProfile()).get(Type.SKIN);
|
HDSkinManager.INSTANCE.getProfileData(getGameProfile())
|
||||||
if (data != null) {
|
.map(m -> m.get(Type.SKIN))
|
||||||
String type = data.getMetadata("model");
|
.ifPresent(data -> {
|
||||||
if (type == null)
|
String type = data.getMetadata("model");
|
||||||
type = "default";
|
if (type == null)
|
||||||
String type1 = type;
|
type = "default";
|
||||||
Optional<ResourceLocation> texture = HDSkinManager.INSTANCE.getSkinLocation(getGameProfile(), Type.SKIN, false);
|
String type1 = type;
|
||||||
|
Optional<ResourceLocation> texture = HDSkinManager.INSTANCE.getSkinLocation(getGameProfile(), Type.SKIN, false);
|
||||||
|
|
||||||
texture.ifPresent((res) -> ci.setReturnValue(type1));
|
texture.ifPresent((res) -> ci.setReturnValue(type1));
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue