NewSkinManager.java 文件源码

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

项目:Et-Futurum 作者:
@Override
public ResourceLocation func_152789_a(final MinecraftProfileTexture texture, final Type type, final SkinManager.SkinAvailableCallback callBack) {
    if (type != Type.SKIN)
        return super.func_152789_a(texture, type, callBack);

    final boolean isSpecialCallBack = callBack instanceof ISkinDownloadCallback;
    final ResourceLocation resLocationOld = new ResourceLocation("skins/" + texture.getHash());
    final ResourceLocation resLocation = new ResourceLocation(Reference.MOD_ID, resLocationOld.getResourcePath());
    ITextureObject itextureobject = textureManager.getTexture(resLocation);

    if (itextureobject != null) {
        if (callBack != null)
            callBack.func_152121_a(type, resLocation);
    } else {
        File file1 = new File(skinFolder, texture.getHash().substring(0, 2));
        File file2 = new File(file1, texture.getHash());
        final NewImageBufferDownload imgDownload = new NewImageBufferDownload();
        ITextureObject imgData = new NewThreadDownloadImageData(file2, texture.getUrl(), field_152793_a, imgDownload, resLocationOld, new IImageBuffer() {

            @Override
            public BufferedImage parseUserSkin(BufferedImage buffImg) {
                if (buffImg != null)
                    PlayerModelManager.analyseTexture(buffImg, resLocation);
                return imgDownload.parseUserSkin(buffImg);
            }

            @Override
            public void func_152634_a() {
                imgDownload.func_152634_a();
                if (callBack != null)
                    callBack.func_152121_a(type, isSpecialCallBack ? resLocation : resLocationOld);
            }
        });
        textureManager.loadTexture(resLocation, imgData);
        textureManager.loadTexture(resLocationOld, imgData); // Avoid thrown exception if the image is requested before the download is done
    }

    return isSpecialCallBack ? resLocation : resLocationOld;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号