Generating worlds of Minecraft "infinite" with Cubes framework

Hello everyone, I was always fascinated by programming and always liked games, my favorite has always been the Minecraft. I am creating a small clone of Minecraft with jME and Cubes framework http://wiki.jmonkeyengine.org/doku.php/jme3:contributions:cubes which is great. The problem is when generating random worlds, Cubes has a “Noise” that generates random chunks, so I put him generate 100 chunks (insignificant next Minecraft) and get a memory loss mistake! Why does it happen?

Code for generating 100 chunks random:

BlockTerrainControl blockTerrain = new BlockTerrainControl(new Vector3Int(100, 1, 100)); //100 CHUNKS HERE

blockTerrain.setBlocksFromNoise(new Vector3Int(0, 0, 0), new Vector3Int(64, 50, 64), 0.3f, CubesTestAssets.BLOCK_GRASS);

Node terrainNode = new Node();
terrainNode.addControl(blockTerrain);
rootNode.attachChild(terrainNode);

I don’t know the Cubes framework and I haven’t tested your code, but your first line of code looks to me as if you do not generate 100 chunks, but 100 x 100 = 10000 chunks (which can be quite a lot if they are all kept in memory at the same time)

Nop, even though 10,000 chunks was not going to happen this, Minecraft carries over 14 billion of chunks and runs at average of 60 fps

No. This is 100000% untrue. Minecraft may have worlds that big but it only loads a tiny fraction of that at time.

You need to read about paging and stuff.

Is there any reason that you are trying to start learning to program games at the absolutely hardest point? (Block worlds are the hardest games to write, not the easiest.)

1 Like

This sentence. :laughing: Something tells me you’re also running your VM with the default 64MB of memory.

I never said that Minecraft run 14 billion of chunks in primary memory. But you will answer my question or not?

I mean, what answer do you want other than “It only reads the data in that it needs”

Do you want me to write a whole paging library for you? (I actually already have.)

But I suspect you don’t get have the skills to utilize the information I’d give you… or you wouldn’t have asked the question. Thus I encourage you to start at a shallower end of the pool until you have a sufficient base set of skills to go to the next level.

Or if your question is specifically about the cubes framework then the answer is “it doesn’t do that for you. You must implement paging yourself.”

1 Like

I did not ask favors, asked for help

Because you did it all in memory and minecraft generates the data only as needed.

Ok

I would appreciate if you could give me a sample code, even if you think I will not understand.

The paging library I wrote is used by that demo.

Lots of thanks man!