In my voxel engine, right now I am trying to add blocks to the chunk, and it's half-working. It's in Java and OpenGL. Anyways, when I am placing the block I am doing this:
public void placeBlock(int x, int y, int z, Block block)
{
// c = chunk
c.addToChunk(x, y, z, block);
}
After that, in my chunk class I have this method:
public void addToChunk(int x, int y, int z, Block block)
{
glNewList(test, GL_COMPILE);
glBegin(GL_QUADS);
Shape.createCube(x, y, z, Block.getBlockById(block.getId()).getColor(), Block.getBlockById(block.getId()).getTexCoords(), 1);
blocks[x][y][z] = block.getId();
glEnd();
glEndList();
}
(I am rendering it by calling the list) Anyways, it adds the block to the chunk, but when I place a new block it removes the old block! I have no idea why it's doing this, but if anyone can help me that would be great!