# Generating Less than one Ore vein per chunk.

## Recommended Posts

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);
}
```

##### Share on other sites

Look carefully at your for 'loop'.

Also if you don't want it to generate in every chunk, just do something like if(random.nexInt(whatever) == 0) somewhere, or something like that.

BEFORE ASKING FOR HELP READ THE EAQ!

I'll help if I can. Apologies if I do something obviously stupid.

If you don't know basic Java yet, go and follow these tutorials.

##### Share on other sites

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

##### Share on other sites

Thank you both.  This worked quite nicely.

##### Share on other sites

No worries, you're welcome

-TGG

##### Share on other sites

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.

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 previous content has been restored.   Clear editor

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

• ### Recently Browsing

• No registered users viewing this page.
• ### Posts

• Hi all! Love the Custom npc mod, it is my favorite mod! That said, I have been using this mod since finding it a few years ago (I only play on 1.12.2) and instantly loved that I caould reskin all of the npc's I created. That worked great until recently. I got locked out of my outlook account, which is what I was logged into windows with at the time, and they locked me out of Windows 10. So, I had to reinstall, and since I have digital entitlements to Windows 10 ( I am part of the insider program) on all three of my outlook accounts, I ust swapped to the one I bought Minecraft for. Reinstalled everything, started MC, crerated my favorite fighter (set to kill everything) to clear an area) set up the stats, went back to the main screen, clicked skin so I can give him the grim reaper skin and crash . . . wtf? Thought it was another mod, so, over the course of the last 2 days, I removed every single mod, reinstalled forge 2860 and then 2859, replaced optifine G5 with G6 and vice versa, all with the same result. So, I created a new world, with only the two mods, and same thing. https://pastebin.com/8raJVHq1 That is the log, I have been through the visual settings and all sorts of stuff and can not figure this out, and being that I only just started a bachelors in software engineer / computer programming, I have no idea what I am looking at, so please, and thank you!  If any one of you know what is causing this, I will be forever grateful for the help! Mor9heus
• I think I figured out what the issue was. Decoration Delight Refurbished was updated last night, which I think broke it, because they had another update today and now it's fixed. Why/How it broke it I have no idea, but they figured it out. Thank you for your help!!
• Hello, my minecraft server won't start when i have mods in the mods folder, can someone help please? (Its SCP: Lockdown by the way.) Heres the error messages from when it starts to go wrong.   https://mclo.gs/pu2cWpZ
• So basically, I have this item called Seed Satchel, and I want it to be able to have seeds in it, only seeds. When the player has a Seed Satchel, he can press a key, that will open a GUI, then the player can put seeds or take out seeds, then it closes. Thanks!
• Haven't tested it yet, will do, however, if necessary. Would be a shame, tho, as I would really love to use the Eureka Ship mod Crashes don't happen too often but like twice in 3 hours so far, so still annoying

• ### Who's Online (See full list)

×

• #### Activity

×
• Create New...

## Important Information

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