Hello,
I want to create a mod where textures are generated at the start of Minecraft from bufferedImage create in code. ?
For example, if I want to create a stone with custom color, it will take the stone resource, color it and link it to a ResourceLocation.
But I don't know how to do this step.
I try to use DynamicTexture ? :
public static ResourceLocation addTexture(BufferedImage img, ResourceLocation loc) {
TextureManager textureManager = Minecraft.getInstance().getTextureManager();
NativeImage n = new NativeImage(img.getWidth(), img.getHeight(), true);
for (int i = 0; i < img.getWidth; i++) {
for (int j = 0; j < img.getHeight(); j++) {
double[] c = img.getRaster().getPixel(i, j, new double[0]);
color = (((((c[3] >> 8) + c[2]) >> 8) + c[1]) >> 8) + c[0];
n.setPixelRGBA(i, j, color);
}
}
DynamicTexture dyn = new DynamicTexture(n);
textureManager.loadTexture(loc, dyn);
return loc;
}
But I have errors like that ? :
FATAL ERROR in native method: Thread[Server-Worker-3,5,main]: No context is current or a function that is not available in the current context was called. The JVM will abort execution.
at org.lwjgl.opengl.GL11C.nglGenTextures(Native Method)
at org.lwjgl.opengl.GL11C.glGenTextures(GL11C.java:664)
at org.lwjgl.opengl.GL11.glGenTextures(GL11.java:2492)
at com.mojang.blaze3d.platform.GlStateManager.genTexture(GlStateManager.java:419)
at com.mojang.blaze3d.platform.TextureUtil.generateTextureId(TextureUtil.java:27)
at net.minecraft.client.renderer.texture.Texture.getGlTextureId(Texture.java:45)
at net.minecraft.client.renderer.texture.DynamicTexture.<init>(DynamicTexture.java:16)
at fr.ptlc.randomdimensions.CustomTexture.add(CustomTexture.java:28)
And I don't know why...
I've made many searches and find nothing working
I hope you can help me. ?