HDSkinManager.java 文件源码

java
阅读 28 收藏 0 点赞 0 评论 0

项目:MineLittlePony 作者:
private void loadTexture(GameProfile profile, final Type type, final SkinAvailableCallback callback) {
    if (profile.getId() != null) {
        Map<Type, MinecraftProfileTexture> data = getProfileData(profile);
        final MinecraftProfileTexture texture = data.get(type);

        String skinDir = type.toString().toLowerCase() + "s/";
        final ResourceLocation skin = new ResourceLocation("hdskins", skinDir + texture.getHash());
        File file2 = new File(LiteLoader.getAssetsDirectory(), "hd/" + skinDir + texture.getHash().substring(0, 2) + "/" + texture.getHash());

        final IImageBuffer imagebufferdownload = type == Type.SKIN ? new ImageBufferDownloadHD() : null;

        ITextureObject texObject = new ThreadDownloadImageETag(file2, texture.getUrl(),
                DefaultPlayerSkin.getDefaultSkinLegacy(),
                new IImageBuffer() {
                    @Nonnull
                    @Override
                    public BufferedImage parseUserSkin(@Nonnull BufferedImage image) {
                        BufferedImage image1 = image;
                        if (imagebufferdownload != null) {
                            image1 = imagebufferdownload.parseUserSkin(image);
                        }
                        return image1 == null ? image : image1;
                    }

                    @Override
                    public void skinAvailable() {
                        if (imagebufferdownload != null) {
                            imagebufferdownload.skinAvailable();
                        }
                        callback.skinAvailable(type, skin, texture);
                    }
                });

        // schedule texture loading on the main thread.
        TextureLoader.loadTexture(skin, texObject);
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号