Jump to content

[1.7.2] How to create a world with a custom block instead of air?


Eternaldoom

Recommended Posts

There is no code that explicitly generates air.  In fact air is not an actual block at all, but just an id (0) which is conveniently the default value that the byte array used in terrain generation.  So essentially, any block that is not set to something else is, by default, air.

 

That being said, a short explanation of the terrain generation process.  The generation of the basic terrain is entirely contained in the ChunkProvider class.  First the generateTerrain method creates the basic shape of the chunk by placing stone.  First it randomly calculates the height of each of the 256 columns (16 x 16) in the chunk, and then sets the id of each block in at or below that height to stone.  Then the replaceBlocksForBiome method replaces some of these stone blocks with the biome's (for that column -- each column in a chunk can have a different biome) top and filler blocks.  By default this is dirt and grass, and this method is how the chunks get covered in dirt and grass (or sand in a desert biome).

 

Incidentally, (and this is probably the part you will be most interested in) any air blocks below a certain level  are already being replaced by water in the vanilla chunk generator.  You could create a custom ChunkProvider class with a modified value for this variable (such as 256?) and a modified replaceBlocksForBiome method that places your custom fluid instead of water.  In 1.6.4, this is done in the replaceBlocksForBiome method, but in 1.7.2 (at least the version I downloaded), this appears to be done in the generateTerrain method.  Look for a variable that is set to 63 in the vanilla code.  In 1.6.4, it is a class field, but in 1.7.2 it seems to be local to generateTerrain.

 

One thing that must be said here is that in 1.6.4 any block which you want to be placed by the ChunkProvider class must have an id below 256 since generateTerrain and replaceBlocksForBiome use an array of bytes to hold the block Ids for the chunk (256 is the highest value that can be held by a byte variable).  In 1.7.2 these functions use an array of Block objects to hold this data, so block ID is not an issue.  (Before anyone tells me that there aren't block Ids in 1.7.2, there are.  It's just that modder's don't have to worry about them anymore -- FML handles all that now).

 

So bottom line, look into ChunkProviderGenerate (if you want more than one biome -- ChunkProviderHell otherwise) and create a custom ChunkProvider that sets the sea level (what I've taken to calling that variable) higher and possibly places your custom fluid block.

The best protection for all you meat-related data.

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.