Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

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

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. :D

 

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

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

 

 

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.