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'm trying to make a generic method to more easily add a vein of ore to generation.

But for some reason it's totally ignoring the block it's supposed to replace and filling the above-ground air with tons of randomly placed ores.

 

From my understanding, using BlockStateMatcher.forBlock(block) as the last parameter in WorldGenMineable() is supposed to make it only generate in that block, instead of the default Stone, right?

Well that's not working at all. So why is this happening?

 

@Override
	public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator,
			IChunkProvider chunkProvider)
	{
		switch (world.provider.getDimension())
		{
			case 0:
				generateSurface(world, random, chunkX * 16, chunkZ * 16);
				break;
		}
	}

	private void generateSurface(World world, Random random, int blockX, int blockZ)
	{
		generateOre(world, random, blockX, blockZ, Registry.quickSilverOre, Blocks.STONE, 5, 60, 5, 4);
		generateOre(world, random, blockX, blockZ, Registry.bloodstoneOre, Blocks.GRAVEL, 5, 128, 12, 1);
	}

	private void generateOre(World world, Random random, int chunkX, int chunkY, Block oreToGenerate, Block blockToReplace,
			int minHeight, int maxHeight, int amountPerChunk, int veinSize)
	{
		for (int i = 0; i < amountPerChunk; i++)
		{
			int x = chunkX + random.nextInt(16);
			int y = minHeight + random.nextInt(maxHeight - minHeight);
			int z = chunkY + random.nextInt(16);

			world.setBlockState(new BlockPos(x, y, z), Registry.quickSilverOre.getDefaultState());
                                           
			WorldGenMinable wg = new WorldGenMinable(oreToGenerate.getDefaultState(), veinSize,
					BlockStateMatcher.forBlock(blockToReplace));
			wg.generate(world, random, new BlockPos(x, y, z));
		}
	}

 

Edited by SapphireSky

  • Author
Just now, diesieben07 said:

Why?

 

And unless you need property matching you want to use BlockMatcher, not BlockStateMatcher, it's faster.

Wow, I didn't even realise I had put that there. Now I feel like an idiot.

But thanks.

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.