Jump to content

Recommended Posts

Posted

I've added vanilla ore generation to the Nether (via DecorateBiomeEvent.Post) , but initially I have been getting the cascading worldgen message. So I found out that one has to apply offsets to the passed in block position. I looked at WorldGenMinable#generate, but it is quite obscure. I copied some parts of it and set the amount of blocks generated to 1. Here is what I currently have:

	@SubscribeEvent
	public void generateOresInNether(DecorateBiomeEvent.Post decorateBiomeEvent)
	{
		World world=decorateBiomeEvent.getWorld();
		if(world.provider instanceof WorldProviderHell)
		{
			int numberOfBlocks=7;//FT.defaultGenerationSettings.get;
			Random random=decorateBiomeEvent.getRand();
			BlockPos someposition=decorateBiomeEvent.getPos();
			someposition=someposition.add(random.nextInt(16),random.nextInt(108)+10,random.nextInt(16));
			float f = random.nextFloat() * (float)Math.PI;
			double d0 = (double)((float)(someposition.getX() + 8) + MathHelper.sin(f) * (float)numberOfBlocks / 8.0F);
			double d1 = (double)((float)(someposition.getX() + 8) - MathHelper.sin(f) * (float)numberOfBlocks / 8.0F);
			double d2 = (double)((float)(someposition.getZ() + 8) + MathHelper.cos(f) * (float)numberOfBlocks / 8.0F);
			double d3 = (double)((float)(someposition.getZ() + 8) - MathHelper.cos(f) * (float)numberOfBlocks / 8.0F);
			double d4 = (double)(someposition.getY() + random.nextInt(3) - 2);
			double d5 = (double)(someposition.getY() + random.nextInt(3) - 2);
			float f1 = (float) 6 / (float)numberOfBlocks;
			double d6 = d0 + (d1 - d0) * (double)f1;
			double d7 = d4 + (d5 - d4) * (double)f1;
			double d8 = d2 + (d3 - d2) * (double)f1;
			double d9 = random.nextDouble() * (double)numberOfBlocks / 16.0D;
			double d10 = (double)(MathHelper.sin((float)Math.PI * f1) + 1.0F) * d9 + 1.0D;
			double d11 = (double)(MathHelper.sin((float)Math.PI * f1) + 1.0F) * d9 + 1.0D;
			int j = MathHelper.floor(d6 - d10 / 2.0D);
			int k = MathHelper.floor(d7 - d11 / 2.0D);
			int l = MathHelper.floor(d8 - d10 / 2.0D);
			int i1 = MathHelper.floor(d6 + d10 / 2.0D);
			int j1 = MathHelper.floor(d7 + d11 / 2.0D);
			int k1 = MathHelper.floor(d8 + d10 / 2.0D);

			BlockPos setPosition=new BlockPos(i1,j1,k1);
			IBlockState blockState=world.getBlockState(setPosition);
			while(blockState==Blocks.AIR.getDefaultState() || blockState==Blocks.LAVA)
			{
				setPosition=setPosition.down();
				if(setPosition.getY()<3) break;
			}
			world.setBlockState(setPosition,blocks.get(random.nextInt(blocks.size()-1)).getDefaultState());
		}
	}

 

How should I offset given position to be able to generate ore clusters without triggering unneeded generation?

Posted

WorldGenMinable uses +8x and +8z. What you want to accomplish is moving far enough away from north and west that even the largest ore body never changes a block on or beyond the north or west edge of the given chunk (even staying in the chunk, tickling the edge causes neighbor change in the next chunk).

 

Why can't you use WorldGenMinable itself?

 

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.

Posted
21 hours ago, jeffryfisher said:

WorldGenMinable uses +8x and +8z. What you want to accomplish is moving far enough away from north and west that even the largest ore body never changes a block on or beyond the north or west edge of the given chunk (even staying in the chunk, tickling the edge causes neighbor change in the next chunk).

 

Why can't you use WorldGenMinable itself?

 

So I should add 8 to x and z of provided position?

I could subclass Worldgenminable, but I can only override its #generate() method and still will have to copy original generation code and adapt it.

Posted
2 hours ago, Alexiy said:

So I should add 8 to x and z of provided position?

That should work,  keeping your ores away from the North and West edges of the given chunk (unless you start generating really huge or sprawling ore bodies). If you know enough about the size and shape of your ore bodies, you could use different numbers. Just avoid stepping on or over the NW edges with any of your blockstate changes.

  • Like 1

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.