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)
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.)
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.”