Search in sources :

Example 11 with ThreadDownloadImageData

use of net.minecraft.client.renderer.ThreadDownloadImageData in project Armourers-Workshop by RiskyKen.

the class SkinHelper method getBufferedImageSkin.

public static BufferedImage getBufferedImageSkin(GameProfile gameProfile) {
    BufferedImage bufferedImage = null;
    ResourceLocation skinloc = AbstractClientPlayer.locationStevePng;
    InputStream inputStream = null;
    Minecraft mc = Minecraft.getMinecraft();
    Map map = mc.func_152342_ad().func_152788_a(gameProfile);
    try {
        if (map.containsKey(MinecraftProfileTexture.Type.SKIN)) {
            skinloc = mc.func_152342_ad().func_152792_a((MinecraftProfileTexture) map.get(Type.SKIN), Type.SKIN);
            ITextureObject skintex = mc.getTextureManager().getTexture(skinloc);
            if (skintex instanceof ThreadDownloadImageData) {
                ThreadDownloadImageData imageData = (ThreadDownloadImageData) skintex;
                bufferedImage = ObfuscationReflectionHelper.getPrivateValue(ThreadDownloadImageData.class, imageData, "bufferedImage", "field_110560_d", "bpr.h");
            } else {
                inputStream = Minecraft.getMinecraft().getResourceManager().getResource(skinloc).getInputStream();
                bufferedImage = ImageIO.read(inputStream);
            }
        } else {
            inputStream = Minecraft.getMinecraft().getResourceManager().getResource(skinloc).getInputStream();
            bufferedImage = ImageIO.read(inputStream);
        }
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        IOUtils.closeQuietly(inputStream);
    }
    return bufferedImage;
}
Also used : ITextureObject(net.minecraft.client.renderer.texture.ITextureObject) InputStream(java.io.InputStream) ResourceLocation(net.minecraft.util.ResourceLocation) IOException(java.io.IOException) MinecraftProfileTexture(com.mojang.authlib.minecraft.MinecraftProfileTexture) Minecraft(net.minecraft.client.Minecraft) Map(java.util.Map) BufferedImage(java.awt.image.BufferedImage) ThreadDownloadImageData(net.minecraft.client.renderer.ThreadDownloadImageData)

Example 12 with ThreadDownloadImageData

use of net.minecraft.client.renderer.ThreadDownloadImageData in project Armourers-Workshop by RiskyKen.

the class SkinHelper method getBuffFromResourceLocation.

private static BufferedImage getBuffFromResourceLocation(ResourceLocation rl) {
    BufferedImage bi = null;
    InputStream inputStream = null;
    try {
        ITextureObject skintex = Minecraft.getMinecraft().getTextureManager().getTexture(rl);
        if (skintex instanceof ThreadDownloadImageData) {
            ThreadDownloadImageData imageData = (ThreadDownloadImageData) skintex;
            bi = ObfuscationReflectionHelper.getPrivateValue(ThreadDownloadImageData.class, imageData, "bufferedImage", "field_110560_d", "bpr.h");
        } else {
            inputStream = Minecraft.getMinecraft().getResourceManager().getResource(rl).getInputStream();
            bi = ImageIO.read(inputStream);
        }
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        IOUtils.closeQuietly(inputStream);
    }
    return bi;
}
Also used : ITextureObject(net.minecraft.client.renderer.texture.ITextureObject) InputStream(java.io.InputStream) IOException(java.io.IOException) BufferedImage(java.awt.image.BufferedImage) ThreadDownloadImageData(net.minecraft.client.renderer.ThreadDownloadImageData)

Example 13 with ThreadDownloadImageData

use of net.minecraft.client.renderer.ThreadDownloadImageData in project Armourers-Workshop by RiskyKen.

the class SkinHelper method getBufferedImageSkin.

public static BufferedImage getBufferedImageSkin(ResourceLocation resourceLocation) {
    Minecraft mc = Minecraft.getMinecraft();
    BufferedImage bufferedImage = null;
    InputStream inputStream = null;
    try {
        ITextureObject skintex = mc.getTextureManager().getTexture(resourceLocation);
        if (skintex instanceof ThreadDownloadImageData) {
            ThreadDownloadImageData imageData = (ThreadDownloadImageData) skintex;
            bufferedImage = ObfuscationReflectionHelper.getPrivateValue(ThreadDownloadImageData.class, imageData, "bufferedImage", "field_110560_d", "bpr.h");
        } else {
            inputStream = Minecraft.getMinecraft().getResourceManager().getResource(resourceLocation).getInputStream();
            bufferedImage = ImageIO.read(inputStream);
        }
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        IOUtils.closeQuietly(inputStream);
    }
    return bufferedImage;
}
Also used : ITextureObject(net.minecraft.client.renderer.texture.ITextureObject) InputStream(java.io.InputStream) IOException(java.io.IOException) Minecraft(net.minecraft.client.Minecraft) BufferedImage(java.awt.image.BufferedImage) ThreadDownloadImageData(net.minecraft.client.renderer.ThreadDownloadImageData)

Aggregations

ThreadDownloadImageData (net.minecraft.client.renderer.ThreadDownloadImageData)13 ITextureObject (net.minecraft.client.renderer.texture.ITextureObject)9 IOException (java.io.IOException)6 ResourceLocation (net.minecraft.util.ResourceLocation)6 BufferedImage (java.awt.image.BufferedImage)5 InputStream (java.io.InputStream)5 TextureManager (net.minecraft.client.renderer.texture.TextureManager)5 Minecraft (net.minecraft.client.Minecraft)3 File (java.io.File)2 Map (java.util.Map)2 InvokeEvent (cc.hyperium.event.InvokeEvent)1 IMixinThreadDownloadImageData (cc.hyperium.mixins.client.renderer.IMixinThreadDownloadImageData)1 IMixinTextureManager (cc.hyperium.mixins.client.renderer.texture.IMixinTextureManager)1 MinecraftProfileTexture (com.mojang.authlib.minecraft.MinecraftProfileTexture)1 Field (java.lang.reflect.Field)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1 ArrayList (java.util.ArrayList)1 ModelPlayer (net.minecraft.client.model.ModelPlayer)1 IImageBuffer (net.minecraft.client.renderer.IImageBuffer)1