Search in sources :

Example 6 with ThreadDownloadImageData

use of net.minecraft.client.renderer.ThreadDownloadImageData in project Bookshelf by Darkhax-Minecraft.

the class RenderUtils method downloadResource.

/**
     * Attempts to download a resource from the web and load it into the game. If the resource
     * can not be downloaded successfully.
     *
     * @param url The URL to download the resource from. This should be the raw/source url.
     * @param outputResource The ResourceLocation to use for the newly downloaded resource.
     * @param defaultResource The default texture to use, on the chance that it fails to
     *        download a texture. This must be a valid texture, or else you will get a missing
     *        texture.
     * @param buffer A special buffer to use when downloading the image. It is okay to pass
     *        null for this if you don't want anything fancy.
     * @return The downloaded image data.
     */
public static ThreadDownloadImageData downloadResource(String url, ResourceLocation outputResource, ResourceLocation defaultResource, IImageBuffer buffer) {
    final TextureManager manager = Minecraft.getMinecraft().getTextureManager();
    ThreadDownloadImageData imageData = (ThreadDownloadImageData) manager.getTexture(outputResource);
    if (imageData == null) {
        imageData = new ThreadDownloadImageData(null, url, defaultResource, buffer);
        manager.loadTexture(outputResource, imageData);
    }
    return imageData;
}
Also used : TextureManager(net.minecraft.client.renderer.texture.TextureManager) ThreadDownloadImageData(net.minecraft.client.renderer.ThreadDownloadImageData)

Example 7 with ThreadDownloadImageData

use of net.minecraft.client.renderer.ThreadDownloadImageData in project Wurst-MC-1.12 by Wurst-Imperium.

the class AltRenderer method bindSkinTexture.

private static void bindSkinTexture(String name) {
    ResourceLocation location = AbstractClientPlayer.getLocationSkin(name);
    if (loadedSkins.contains(name)) {
        mc.getTextureManager().bindTexture(location);
        return;
    }
    try {
        ThreadDownloadImageData img = AbstractClientPlayer.getDownloadImageSkin(location, name);
        img.loadTexture(mc.getResourceManager());
    } catch (IOException e) {
        e.printStackTrace();
    }
    mc.getTextureManager().bindTexture(location);
    loadedSkins.add(name);
}
Also used : ResourceLocation(net.minecraft.util.ResourceLocation) IOException(java.io.IOException) ThreadDownloadImageData(net.minecraft.client.renderer.ThreadDownloadImageData)

Example 8 with ThreadDownloadImageData

use of net.minecraft.client.renderer.ThreadDownloadImageData in project ArsMagica2 by Mithion.

the class CloakUtils method renderCloakModel.

public static void renderCloakModel(EntityPlayer player, ModelBiped mainModel, float partialRenderTick) {
    if (!AMCore.proxy.playerTracker.hasCLDM(player.getUniqueID().toString()))
        return;
    // cloaks obey the inverse of show cape
    if (!player.getHideCape())
        return;
    int dm = AMCore.proxy.playerTracker.getCLDM(player.getUniqueID().toString());
    ResourceLocation capeLoc = getCapeLocation(player.getUniqueID().toString());
    ThreadDownloadImageData capeImg = downloadCapeTexture(capeLoc, player.getUniqueID().toString());
    EntityPlayer localPlayer = Minecraft.getMinecraft().thePlayer;
    GL11.glPushMatrix();
    double dx = (player.prevPosX + (player.posX - player.prevPosX) * partialRenderTick) - (localPlayer.prevPosX + (localPlayer.posX - localPlayer.prevPosX) * partialRenderTick);
    double dy = (player.prevPosY + (player.posY - player.prevPosY) * partialRenderTick) - (localPlayer.prevPosY + (localPlayer.posY - localPlayer.prevPosY) * partialRenderTick);
    if (player != localPlayer)
        dy += player.height - player.yOffset - 0.125f;
    double dz = (player.prevPosZ + (player.posZ - player.prevPosZ) * partialRenderTick) - (localPlayer.prevPosZ + (localPlayer.posZ - localPlayer.prevPosZ) * partialRenderTick);
    GL11.glTranslated(dx, dy, dz);
    cloak.render(player, mainModel, 0.0625f, partialRenderTick, capeLoc, dm);
    GL11.glPopMatrix();
}
Also used : ResourceLocation(net.minecraft.util.ResourceLocation) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ThreadDownloadImageData(net.minecraft.client.renderer.ThreadDownloadImageData)

Example 9 with ThreadDownloadImageData

use of net.minecraft.client.renderer.ThreadDownloadImageData in project ArsMagica2 by Mithion.

the class ShadowSkinHelper method getDownloadImage.

private static ThreadDownloadImageData getDownloadImage(ResourceLocation par0ResourceLocation, String par1Str, ResourceLocation par2ResourceLocation, IImageBuffer par3IImageBuffer) {
    TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
    Object object = texturemanager.getTexture(par0ResourceLocation);
    if (object == null) {
        object = new ThreadDownloadImageData((File) null, par1Str, par2ResourceLocation, par3IImageBuffer);
        texturemanager.loadTexture(par0ResourceLocation, (ITextureObject) object);
    }
    return (ThreadDownloadImageData) object;
}
Also used : TextureManager(net.minecraft.client.renderer.texture.TextureManager) ITextureObject(net.minecraft.client.renderer.texture.ITextureObject) File(java.io.File) ThreadDownloadImageData(net.minecraft.client.renderer.ThreadDownloadImageData)

Example 10 with ThreadDownloadImageData

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

the class SkinTexture method updateForResourceLocation.

public void updateForResourceLocation(ResourceLocation resourceLocation) {
    if (lastProfileHash == resourceLocation.hashCode() & bufferedPlayerImage != null) {
        return;
    }
    BufferedImage bi = null;
    InputStream inputStream = null;
    try {
        ITextureObject skintex = mc.getTextureManager().getTexture(resourceLocation);
        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(resourceLocation).getInputStream();
            bi = ImageIO.read(inputStream);
        }
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        IOUtils.closeQuietly(inputStream);
    }
    if (bi == null) {
        return;
    }
    bufferedPlayerImage = SkinHelper.deepCopyBufferedImage(bi);
    lastProfileHash = resourceLocation.hashCode();
    needsUpdate = true;
}
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)

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