public List<BakedQuad> colorQuads(List<BakedQuad> quads, int color) {
for (int i = 0; i < quads.size(); i++) {
net.minecraftforge.client.model.pipeline.LightUtil.renderQuadColor(Tessellator.getInstance().getBuffer(), quads.get(i), color);
}
return quads;
}
renderQuadColor renders the quad. It doesn't change the properties of said quad. So this would obviously do nothing to the quad.
int colorRGBA = 0;
colorRGBA |= 0x00 << 16;// r
colorRGBA |= 0xFF << 8; // g
colorRGBA |= 0x00 << 0; // b
colorRGBA |= 0xFF << 24;// a
renderQuadsColor(bufferbuilder, quads, colorRGBA);
Or you could simply write
int colorRGBA = 0xFF00FF00;
And have the same effect without the bitshifts and or.
As for the actual question.
Quads are usually stored in the ITEM vertex format which has the color element. So you can absolutely apply color to BakedQuads.
It is pretty straight forward. Each quad contains 4 vertices which each contain the elements of the format in the order specified by that format. In BakedQuads those vertices are unified into a single array:
protected final int[] vertexData;
This doesn't stop you from modifying the vertex data by modifying the array.
So the logical order of operations would be to iterate 4 times(4 vertices per quad), get the color element in the array by multiplying the current vertex's index with the size of each vertex and adding the offset to the color element. All that data is available to you in the format of the quad.
So basically you would need to create a custom BakedQuad wrapper and change what you return in the BakedQuad#getVertexData method.
This might be tough to understand so here is a functional example:
private static class ColoredQuad extends BakedQuad
{
private boolean wasRecolored; // Caching whether the recoloring occured.
private int[] vertexData; // The data of the quad.
// Wrapper constructor
public ColoredQuad(BakedQuad original)
{
super(original.getVertexData(), original.getTintIndex(), original.getFace(), original.getSprite(), original.shouldApplyDiffuseLighting(), original.getFormat());
this.vertexData = original.getVertexData();
}
private void recolor()
{
// First getting the format of the quad.
VertexFormat format = this.format;
// Getting the size of each vertex.
int size = format.getIntegerSize();
// Getting the color offset. Dividing by 4 because the offset is specified in bytes.
int offset = format.getColorOffset() / 4;
// The color you want to recolor the quad to. Note that the format for the color is ABGR!
int newColor = 0xFF0000FF;
// Iterating over the vertices(4 vertices per quad)
for (int i = 0; i < 4; i++)
{
// Modifying the element of the vertex at [i] at [offset] with the new color.
this.vertexData[offset + size * i] = newColor;
}
// Caching that the operation was performed.
this.wasRecolored = true;
}
// The vertex data getter.
@Override
public int[] getVertexData()
{
// Recolor the quad if it wasn't recolored.
if (!this.wasRecolored)
{
this.recolor();
}
return this.vertexData;
}
}
And here is how it looks when I replace the model of the Iron Ingot with the one that colored the quads: