Jump to content

Recommended Posts

Posted

I have an ore I wish to generate less than once per chunk. This is what I came up with to do that. I'm wondering if this will have the intended effect and whether this might break anything else by changing the chunkX and chunkZ 16's to larger numbers. Thanks in advance! :)

 

for(int i=0; i < 1; i++)
{
	int chunkX = x + random.nextInt(32);
	int chunkY = random.nextInt(40);
	int chunkZ = z + random.nextInt(32);

	(new WorldGenMinable(SudokuuMain.rarite, 5)).generate(world, random, chunkX, chunkY, chunkZ);
}

Posted

Hi

 

If this loop is called once per chunk, you will get on average one ore per chunk regardless of how much randomness you add to x and z.  And if you use this in the wrong place it will probably cause unintended problems.

 

I think ShieldBug1's idea is the right one. Something like

 

1) generate a random number from 0 - 100

2) if the random number is less than your PERCENTAGE_OF_CHUNKS_WITH_ONE_ORE, eg 35, then place an ore.  Otherwise, don't place it.

 

On average you will then wind up with one ore in 35% of the chunks.

 

-TGG

 

 

Posted

Something else that's random is what type of block you're about to replace at a randomly chosen coordinate within a chunk. If your rarite ore is only allowed to replace a certain material (like rock), then it won't generate where it hits air or water or dirt etc. It could be really really rare if it were only allowed to replace iron ore (or even coal).

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

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.