Jump to content

Recommended Posts

Posted (edited)

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

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