# How can I reduce CPU cost of blocks in my Minecraft clone?

Hi, so I’m making a game like Minecraft because blocks are easy to work with, but the physical part of the block seems to take up way too much CPU. What I mean by physical is empty gameObject containing six quads and a box collider, rather than the type I made called 'Block" which can’t be seen. I’m going to make it so that only exposed blocks are active, but there could easily be tens of thousands of exposed blocks active at a time, and my game starts to lag with only 5,000 of them. I don’t know how Minecraft allows so many blocks onscreen at once without lagging, but I’d like to accomplish the same.

EDIT: Okay so I’ve found an even bigger problem. When I run a check Update for every block to see if I can disable it for better performance, it actually seems to be using even more of the CPU than if I didn’t run the check and just left it active, which is not looking good. What I’m doing is checking every side of a block for an empty space, and then set the block active once it finds an empty space, or set it inactive if it doesn’t find one. How does every other block-based game accomplish updating all the blocks without lagging due to the potential of millions of blocks?

``````//This code will run for every block.
if (blocks [x, y, z] != null)
{
if (x + 1 < width) {
if (blocks [x + 1, y, z] == null) {
Enable (physicalBlocks [x, y, z]);
break;
}
}
if (x - 1 >= 0) {
if (blocks [x - 1, y, z] == null) {
Enable (physicalBlocks [x, y, z]);
break;
}
}
if (y + 1 < height) {
if (blocks [x, y + 1, z] == null) {
Enable (physicalBlocks [x, y, z]);
break;
}
}
if (y - 1 >= 0) {
if (blocks [x, y - 1, z] == null) {
Enable (physicalBlocks [x, y, z]);
break;
}
}
if (z + 1 < length) {
if (blocks [x, y, z + 1] == null) {
Enable (physicalBlocks [x, y, z]);
break;
}
}
if (z - 1 >= 0) {
if (blocks [x, y, z - 1] == null) {
Enable (physicalBlocks [x, y, z]);
break;
}
}
if (physicalBlocks [x, y, z].activeSelf) {
Disable (physicalBlocks [x, y, z]);
}
}
``````

Sorry but there are already way too many minecraft related questions here on UnityAnswers

There are also many forum posts on that topic:

And also other resources

People got already so bored with that subject they already done minecraft in one day challanges.

Minecraft is not an easy made game. Minecraft requires several advanced techniques you have to master. It looks like you don’t really have done much research for your project.

ps: In Minecraft you don’t see several 10k blocks at once but millions. Without chunking the world this is impossible to handle.