Hello everyone! Today I will be showing you how to add a simple skyland to your dimensions!
First off, you will need to look at WorldGenMinable.class. This is where most of the magic happens:
package net.minecraft.src; //this will be different for Minecraft Forge
import java.util.Random;
public class WorldGenMinable extends WorldGenerator
{
/** The block ID of the ore to be placed using this generator. */
private int minableBlockId;
/** The number of blocks to generate. */
private int numberOfBlocks;
public WorldGenMinable(int par1, int par2)
{
this.minableBlockId = par1;
this.numberOfBlocks = par2;
}
public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5)
{
float var6 = par2Random.nextFloat() * (float)Math.PI;
double var7 = (double)((float)(par3 + 8) + MathHelper.sin(var6) * (float)this.numberOfBlocks / 8.0F);
double var9 = (double)((float)(par3 + 8) - MathHelper.sin(var6) * (float)this.numberOfBlocks / 8.0F);
double var11 = (double)((float)(par5 + 8) + MathHelper.cos(var6) * (float)this.numberOfBlocks / 8.0F);
double var13 = (double)((float)(par5 + 8) - MathHelper.cos(var6) * (float)this.numberOfBlocks / 8.0F);
double var15 = (double)(par4 + par2Random.nextInt(3) - 2);
double var17 = (double)(par4 + par2Random.nextInt(3) - 2);
for (int var19 = 0; var19 <= this.numberOfBlocks; ++var19)
{
double var20 = var7 + (var9 - var7) * (double)var19 / (double)this.numberOfBlocks;
double var22 = var15 + (var17 - var15) * (double)var19 / (double)this.numberOfBlocks;
double var24 = var11 + (var13 - var11) * (double)var19 / (double)this.numberOfBlocks;
double var26 = par2Random.nextDouble() * (double)this.numberOfBlocks / 16.0D;
double var28 = (double)(MathHelper.sin((float)var19 * (float)Math.PI / (float)this.numberOfBlocks) + 1.0F) * var26 + 1.0D;
double var30 = (double)(MathHelper.sin((float)var19 * (float)Math.PI / (float)this.numberOfBlocks) + 1.0F) * var26 + 1.0D;
int var32 = MathHelper.floor_double(var20 - var28 / 2.0D);
int var33 = MathHelper.floor_double(var22 - var30 / 2.0D);
int var34 = MathHelper.floor_double(var24 - var28 / 2.0D);
int var35 = MathHelper.floor_double(var20 + var28 / 2.0D);
int var36 = MathHelper.floor_double(var22 + var30 / 2.0D);
int var37 = MathHelper.floor_double(var24 + var28 / 2.0D);
for (int var38 = var32; var38 <= var35; ++var38)
{
double var39 = ((double)var38 + 0.5D - var20) / (var28 / 2.0D);
if (var39 * var39 < 1.0D)
{
for (int var41 = var33; var41 <= var36; ++var41)
{
double var42 = ((double)var41 + 0.5D - var22) / (var30 / 2.0D);
if (var39 * var39 + var42 * var42 < 1.0D)
{
for (int var44 = var34; var44 <= var37; ++var44)
{
double var45 = ((double)var44 + 0.5D - var24) / (var28 / 2.0D);
if (var39 * var39 + var42 * var42 + var45 * var45 < 1.0D && par1World.getBlockId(var38, var41, var44) == Block.stone.blockID)
{
par1World.setBlock(var38, var41, var44, this.minableBlockId);
}
}
}
}
}
}
}
return true;
}
}
Well blow me down if that doesn't look like a bunch of gibberish (well to me it does)! The only IMPORTANT part is the 'Block.stone.blockID'. I think any modder would recognise that as a block (more specifically, the block's variable).
So, what does this file do?
Well, this is the file that tells ores where to generate and, more importantly, what block to do it in. In this case, it's Block.stone.blockID, but we can change that to ANY BLOCK... even AIR.
So, go ahead and change that Block.stone.blockID to a 0. Change the constructor name and save it as a new file, say, WorldGenSkyMinable.java.
Now, assuming you have one, go into your ChunkProvider class for your dimension (eg. Mine is ChunkProviderCreep.java) and scroll down to the 'public void populate()' method.
int x1 = par2 * 16;
int z1 = par3 * 16;
for(int x =0; x < 4; x++)
{
int Xcoord = x1 +this.rand.nextInt(16);
int Ycoord = this.rand.nextInt(180);
int Zcoord = z1 + this.rand.nextInt(16);
(new WorldGenSkyMinable(Block.obsidian.blockID, 80)).generate(worldObj, this.rand, Xcoord, Ycoord, Zcoord);
}
This piece of code might need a bit of tweaking. If you based your ChunkProvider file off the Nether one, this.rand becomes this.hellRNG. worldObj may also be different. Anyway, what this part of the code is telling Minecraft is the limitations of the generator. The '4' is how many times to generate a skyland per chunk (16*16*256 blocks). The 16's are unimportant. The 180 is the maximum height to generate the skylands, and the 80 is how big the islands can be at max (although some may join together).
Basically, this is telling the game to generate 4 floating obsidian islands per chunk at a maximum height of 180 blocks above bedrock and a maximum size of 80 blocks. Feel free to modify these parameters.
Lastly, if you have the know-how, you can place top blocks using par1World.getBlockID(i, j, k);
That's all, happy skylanding!
Rollback Post to RevisionRollBack
The creeper was once the crowning jewel of Minecraft... Until those retarded Endermen... FIGHT FOR CREEPER RIGHTS!!! SUPPORT THE CREEP MOD!
First off, you will need to look at WorldGenMinable.class. This is where most of the magic happens:
Well blow me down if that doesn't look like a bunch of gibberish (well to me it does)! The only IMPORTANT part is the 'Block.stone.blockID'. I think any modder would recognise that as a block (more specifically, the block's variable).
So, what does this file do?
Well, this is the file that tells ores where to generate and, more importantly, what block to do it in. In this case, it's Block.stone.blockID, but we can change that to ANY BLOCK... even AIR.
So, go ahead and change that Block.stone.blockID to a 0. Change the constructor name and save it as a new file, say, WorldGenSkyMinable.java.
Now, assuming you have one, go into your ChunkProvider class for your dimension (eg. Mine is ChunkProviderCreep.java) and scroll down to the 'public void populate()' method.
This piece of code might need a bit of tweaking. If you based your ChunkProvider file off the Nether one, this.rand becomes this.hellRNG. worldObj may also be different. Anyway, what this part of the code is telling Minecraft is the limitations of the generator. The '4' is how many times to generate a skyland per chunk (16*16*256 blocks). The 16's are unimportant. The 180 is the maximum height to generate the skylands, and the 80 is how big the islands can be at max (although some may join together).
Basically, this is telling the game to generate 4 floating obsidian islands per chunk at a maximum height of 180 blocks above bedrock and a maximum size of 80 blocks. Feel free to modify these parameters.
Lastly, if you have the know-how, you can place top blocks using par1World.getBlockID(i, j, k);
That's all, happy skylanding!