Jump to content

Recommended Posts

Posted

I'm using an IWorldGenerator to generate veins of my custom ores, and it works just fine in the Overworld, but when I use the same code in the Nether it blows up with OutOfMemory errors.

 

Is there anything in particular to be aware of when generating in areas other than the surface?

Posted

I set it to 32 veins per chunk to make sure I could find the ore when mining; that's not the final values.

 

I had no problem running without the nether-generating code with 1GB, but even with 2GB I ran out of heap when I enabled the nether code.

Posted

A chunk is 16x16 blocks, so if you multiply the chunk coordinates by 32 before passing them to your generate[dimensionName] methods, you'll actually be generating very far away from the intended chunks.

 

Consider the following line-by-line walkthrough:

 

At L17 your method has been called; suppose it receives chunk coordinates (2,2). On L21 the method multiplies these values by 32 and pass them to the individual dimension methods. The values are now (64,64). At L56 the method then adds a random integer between 0 and 32 to each of them. Worst case scenario, the values are now (96,96). This is somewhat far away from the coordinates of Chunk (2,2), which should have coordinates between 32 and 48 for the X and Z (I can't recall whether they're positive or negative, sorry).

 

You can imagine how this issue is magnified the farther out from chunk (0,0) you travel - very soon you'll be generating in chunks that are a massive distance away, which is a significant resource demand. If you didn't travel to the Nether from or near chunk coordinates (0,0) you will immediately be generating in distant chunks, which is what causes the memory issue.

 

TL;DR - Change those 32s to 16s, a chunk is 16x16 blocks and not 32x32.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.