Search in sources :

Example 1 with Texture

use of net.minecraft.client.renderer.texture.Texture in project ChocolateQuestRepoured by TeamChocoQuest.

the class AutoGlowingTexture method load.

@Override
public void load(IResourceManager resourceManager) throws IOException {
    this.releaseId();
    try (IResource iresource = resourceManager.getResource(this.originalTexture)) {
        // Needed to get the GL-texture id
        Texture ito = Minecraft.getInstance().textureManager.getTexture(iresource.getLocation());
        NativeImage bufferedimage = NativeImage.read(TextureUtil.readResource(iresource.getInputStream()));
        NativeImage glowingBI = new NativeImage(bufferedimage.getWidth(), bufferedimage.getHeight(), false);
        boolean flag = false;
        boolean flag1 = false;
        // if (iresource.hasMetadata()) {
        try {
            // DONE: Fix this for the CTS!! Cts for whatever reason tries to load png as mcmeta file...
            TextureMetadataSection texturemetadatasection = iresource.getMetadata(new TextureMetadataSectionSerializer());
            if (texturemetadatasection != null) {
                flag = texturemetadatasection.isBlur();
                flag1 = texturemetadatasection.isClamp();
            }
            GlowingMetadataSection glowInformation = iresource.getMetadata(new GlowingMetadataSectionSerializer());
            if (glowInformation != null) {
                for (Tuple<Tuple<Integer, Integer>, Tuple<Integer, Integer>> area : glowInformation.getGlowingSections()) {
                    for (int ix = area.getA().getA(); ix < area.getB().getA(); ix++) {
                        for (int iy = area.getA().getB(); iy < area.getB().getB(); iy++) {
                            glowingBI.setPixelRGBA(ix, iy, bufferedimage.getPixelRGBA(ix, iy));
                            // Remove it from the original
                            bufferedimage.setPixelRGBA(ix, iy, 0);
                        }
                    }
                }
            }
        /*
					 * String name = this.texture.getPath().replace("/", "-");
					 * File outputFile = new File(CQRMain.CQ_CONFIG_FOLDER, name);
					 * ImageIO.write(glowingBI, "png", outputFile);
					 */
        } catch (RuntimeException runtimeexception) {
            LOGGER.warn("Failed reading metadata of: {}", this.originalTexture, runtimeexception);
        }
        // }
        TextureUtil.uploadTextureImageAllocate(this.getId(), glowingBI, flag, flag1);
        // Also upload the changes to the original texture...
        TextureUtil.uploadTextureImage(ito.getId(), bufferedimage);
    }
}
Also used : NativeImage(net.minecraft.client.renderer.texture.NativeImage) GlowingMetadataSection(team.cqr.cqrepoured.client.resources.data.GlowingMetadataSection) TextureMetadataSection(net.minecraft.client.resources.data.TextureMetadataSection) TextureMetadataSectionSerializer(net.minecraft.client.resources.data.TextureMetadataSectionSerializer) GlowingMetadataSectionSerializer(team.cqr.cqrepoured.client.resources.data.GlowingMetadataSectionSerializer) Texture(net.minecraft.client.renderer.texture.Texture) IResource(net.minecraft.resources.IResource) Tuple(net.minecraft.util.Tuple)

Example 2 with Texture

use of net.minecraft.client.renderer.texture.Texture in project ChocolateQuestRepoured by TeamChocoQuest.

the class SphereRenderer method preDraw.

private static void preDraw(@Nullable ResourceLocation textureLocation) {
    prevProgram = GL11.glGetInteger(GL20.GL_CURRENT_PROGRAM);
    GL20.glUseProgram(shader.getShaderProgram());
    GL11.glGetFloat(GL11.GL_CURRENT_COLOR, BUFFER);
    GL20.glUniform4f(uniformColor, BUFFER.get(0), BUFFER.get(1), BUFFER.get(2), BUFFER.get(3));
    if (textureLocation != null) {
        GL20.glUniform1i(uniformTexture, 1);
        Minecraft mc = Minecraft.getInstance();
        TextureManager textureManager = mc.getTextureManager();
        Texture texture = textureManager.getTexture(CubemapTexture.get(textureLocation));
        GL11.glBindTexture(GL13.GL_TEXTURE_CUBE_MAP, texture.getId());
    } else {
        GL20.glUniform1i(uniformTexture, 0);
    }
}
Also used : TextureManager(net.minecraft.client.renderer.texture.TextureManager) Minecraft(net.minecraft.client.Minecraft) CubemapTexture(team.cqr.cqrepoured.client.render.texture.CubemapTexture) Texture(net.minecraft.client.renderer.texture.Texture)

Aggregations

Texture (net.minecraft.client.renderer.texture.Texture)2 Minecraft (net.minecraft.client.Minecraft)1 NativeImage (net.minecraft.client.renderer.texture.NativeImage)1 TextureManager (net.minecraft.client.renderer.texture.TextureManager)1 TextureMetadataSection (net.minecraft.client.resources.data.TextureMetadataSection)1 TextureMetadataSectionSerializer (net.minecraft.client.resources.data.TextureMetadataSectionSerializer)1 IResource (net.minecraft.resources.IResource)1 Tuple (net.minecraft.util.Tuple)1 CubemapTexture (team.cqr.cqrepoured.client.render.texture.CubemapTexture)1 GlowingMetadataSection (team.cqr.cqrepoured.client.resources.data.GlowingMetadataSection)1 GlowingMetadataSectionSerializer (team.cqr.cqrepoured.client.resources.data.GlowingMetadataSectionSerializer)1