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);
}
}
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);
}
}
Aggregations