Search in sources :

Example 1 with NativeImageTexture

use of me.ichun.mods.ichunutil.client.render.NativeImageTexture in project iChunUtil by iChun.

the class Project method getNativeImageResourceLocation.

@OnlyIn(Dist.CLIENT)
public ResourceLocation getNativeImageResourceLocation() {
    if (textureBytes != null) {
        if (nativeImageTexture == null) {
            try (NativeImage image = NativeImage.read(new ByteArrayInputStream(textureBytes))) {
                nativeImageTexture = new NativeImageTexture(image);
                Minecraft.getInstance().getTextureManager().loadTexture(nativeImageTexture.getResourceLocation(), nativeImageTexture);
            } catch (IOException e) {
                iChunUtil.LOGGER.error("Failed to read NativeImage for project: " + name);
                e.printStackTrace();
            }
        }
        return nativeImageTexture.getResourceLocation();
    }
    return null;
}
Also used : NativeImageTexture(me.ichun.mods.ichunutil.client.render.NativeImageTexture) NativeImage(net.minecraft.client.renderer.texture.NativeImage) ByteArrayInputStream(java.io.ByteArrayInputStream) IOException(java.io.IOException) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn)

Aggregations

ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 NativeImageTexture (me.ichun.mods.ichunutil.client.render.NativeImageTexture)1 NativeImage (net.minecraft.client.renderer.texture.NativeImage)1 OnlyIn (net.minecraftforge.api.distmarker.OnlyIn)1