Jump to content

[1.15.2] Custom Surface Builder.


Stanlyhalo

Recommended Posts

I have a couple custom biomes with designated custom surface builders, although I don't know how to make the kind of biome surface builder I want. So what I am asking, is a walkthrough to how the default biome surface builder works, and how I can create my own to the type of biome I want, this is the default biome surface builder:

protected void buildSurface(Random random, IChunk chunkIn, Biome biomeIn, int x, int z, int startHeight, double noise, BlockState defaultBlock, BlockState defaultFluid, BlockState top, BlockState middle, BlockState bottom, int sealevel) {
   BlockState blockstate = top;
   BlockState blockstate1 = middle;
   BlockPos.Mutable blockpos$mutable = new BlockPos.Mutable();
   int i = -1;
   int j = (int)(noise / 3.0D + 3.0D + random.nextDouble() * 0.25D);
   int k = x & 15;
   int l = z & 15;

   for(int i1 = startHeight; i1 >= 0; --i1) {
      blockpos$mutable.setPos(k, i1, l);
      BlockState blockstate2 = chunkIn.getBlockState(blockpos$mutable);
      if (blockstate2.isAir()) {
         i = -1;
      } else if (blockstate2.getBlock() == defaultBlock.getBlock()) {
         if (i == -1) {
            if (j <= 0) {
               blockstate = Blocks.AIR.getDefaultState();
               blockstate1 = defaultBlock;
            } else if (i1 >= sealevel - 4 && i1 <= sealevel + 1) {
               blockstate = top;
               blockstate1 = middle;
            }

            if (i1 < sealevel && (blockstate == null || blockstate.isAir())) {
               if (biomeIn.getTemperature(blockpos$mutable.setPos(x, i1, z)) < 0.15F) {
                  blockstate = Blocks.ICE.getDefaultState();
               } else {
                  blockstate = defaultFluid;
               }

               blockpos$mutable.setPos(k, i1, l);
            }

            i = j;
            if (i1 >= sealevel - 1) {
               chunkIn.setBlockState(blockpos$mutable, blockstate, false);
            } else if (i1 < sealevel - 7 - j) {
               blockstate = Blocks.AIR.getDefaultState();
               blockstate1 = defaultBlock;
               chunkIn.setBlockState(blockpos$mutable, bottom, false);
            } else {
               chunkIn.setBlockState(blockpos$mutable, blockstate1, false);
            }
         } else if (i > 0) {
            --i;
            chunkIn.setBlockState(blockpos$mutable, blockstate1, false);
            if (i == 0 && blockstate1.getBlock() == Blocks.SAND && j > 1) {
               i = random.nextInt(4) + Math.max(0, i1 - 63);
               blockstate1 = blockstate1.getBlock() == Blocks.RED_SAND ? Blocks.RED_SANDSTONE.getDefaultState() : Blocks.SANDSTONE.getDefaultState();
            }
         }
      }
   }

}

So if anyone could walk me through how this works, that would be amazing. Also if someone would tell me the math I would have to do to make a sahara surface builder, that would be awesome.

Link to comment
Share on other sites

Well, I see a for loop that starts at a startHeight and if the block at that position is air, it (continues the loop and) goes down.

If the block is the same as defaultBlock, then it does some other stuff to determine what block to place at that position instead. i (but starts at -1, meaning the first block that isn't air does something different than if i > 0--set by j) and j are based on some noise values. i and the seaHeight determine what block is placed.

Edited by Draco18s

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

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.