Metadata World Gen! Beta 1.7.3
This development is more of an addition rather than a full-fledged mod. The main innovation is the special WorldGenMinableMetadata class, which is an enhanced version of the standard WorldGenMinable. The key feature is the ability to pass block metadata, allowing objects with different variants to be generated during world creation.
Available Versions
The downloads section provides two versions of the implementation - for both client and server. One version is labeled "+ Example Mod" and contains a demonstration modification based on Modloader and ModloaderMP, which adds all possible color variants of wool to the world. This example mod is not required for using the main functionality - it was created solely for illustrative purposes and may be useful for developers wanting to understand the system's operating principles.
Important note: the demonstration mod requires Modloader Beta 1.7.3 and ModloaderMP Unofficial v2. The basic version of Metadata World Gen can function without these components.
WorldGenMinableMetadata Class
package net.minecraft.src;
import java.util.Random;
public class WorldGenMinableMetadata extends WorldGenerator {
private int minableBlockId;
private int numberOfBlocks;
private int blockMetadata;
public WorldGenMinableMetadata(int i1, int i2, int i3) {
this.minableBlockId = i1;
this.blockMetadata = i2;
this.numberOfBlocks = i3;
}
public boolean generate(World world1, Random random2, int i3, int i4, int i5) {
float f6 = random2.nextFloat() (float)Math.PI;
double d7 = (double)((float)(i3 + 8) + MathHelper.sin(f6) (float)this.numberOfBlocks / 8.0F);
double d9 = (double)((float)(i3 + 8) - MathHelper.sin(f6) (float)this.numberOfBlocks / 8.0F);
double d11 = (double)((float)(i5 + 8) + MathHelper.cos(f6) (float)this.numberOfBlocks / 8.0F);
double d13 = (double)((float)(i5 + 8) - MathHelper.cos(f6) (float)this.numberOfBlocks / 8.0F);
double d15 = (double)(i4 + random2.nextInt(3) + 2);
double d17 = (double)(i4 + random2.nextInt(3) + 2);
for(int i19 = 0; i19 <= this.numberOfBlocks; ++i19) {
double d20 = d7 + (d9 - d7) (double)i19 / (double)this.numberOfBlocks;
double d22 = d15 + (d17 - d15) (double)i19 / (double)this.numberOfBlocks;
double d24 = d11 + (d13 - d11) (double)i19 / (double)this.numberOfBlocks;
double d26 = random2.nextDouble() (double)this.numberOfBlocks / 16.0D;
double d28 = (double)(MathHelper.sin((float)i19 (float)Math.PI / (float)this.numberOfBlocks) + 1.0F) d26 + 1.0D;
double d30 = (double)(MathHelper.sin((float)i19 (float)Math.PI / (float)this.numberOfBlocks) + 1.0F) d26 + 1.0D;
int i32 = MathHelper.floor_double(d20 - d28 / 2.0D);
int i33 = MathHelper.floor_double(d22 - d30 / 2.0D);
int i34 = MathHelper.floor_double(d24 - d28 / 2.0D);
int i35 = MathHelper.floor_double(d20 + d28 / 2.0D);
int i36 = MathHelper.floor_double(d22 + d30 / 2.0D);
int i37 = MathHelper.floor_double(d24 + d28 / 2.0D);
for(int i38 = i32; i38 <= i35; ++i38) {
double d39 = ((double)i38 + 0.5D - d20) / (d28 / 2.0D);
if(d39 d39 < 1.0D) {
for(int i41 = i33; i41 <= i36; ++i41) {
double d42 = ((double)i41 + 0.5D - d22) / (d30 / 2.0D);
if(d39 d39 + d42 d42 < 1.0D) {
for(int i44 = i34; i44 <= i37; ++i44) {
double d45 = ((double)i44 + 0.5D - d24) / (d28 / 2.0D);
if(d39 d39 + d42 d42 + d45 d45 < 1.0D && world1.getBlockId(i38, i41, i44) == Block.stone.blockID) {
world1.setBlockAndMetadata(i38, i41, i44, this.minableBlockId, this.blockMetadata);
}
}
}
}
}
}
}
return true;
}
}
Usage Example: mod_WorldGenMetadataExample
package net.minecraft.src;
import java.util.Random;
public class mod_WorldGenMetadataExample extends BaseModMp {
public mod_WorldGenMetadataExample() {
}
public void GenerateSurface(World world, Random random, int chunkX, int chunkZ) {
int posX;
int posY;
int posZ;
int i;
for(i = 0; i < 32; ++i) {
posX = chunkX + random.nextInt(16);
posY = random.nextInt(128);
posZ = chunkZ + random.nextInt(16);
(new WorldGenMinableMetadata(Block.cloth.blockID, 9, 16)).generate(world, random, posX, posY, posZ);
/
new WorldGenMinableMetadata is a modified version of WorldGenMinable that supports metadata.
Unlike the standard call (new WorldGenMinable(Block.cloth.blockID, 16)).generate(world, random, posX, posY, posZ), which creates only white wool,
now you can specify metadata, for example: (new WorldGenMinableMetadata(Block.cloth.blockID, 9, 16)).generate(world, random, posX, posY, posZ);
The number 9 corresponds to a specific metadata value - in this case it's cyan wool instead of white
*/
}
for(i = 0; i < 32; ++i) {
posX = chunkX + random.nextInt(16);
posY = random.nextInt(128);
posZ = chunkZ + random.nextInt(16);
(new WorldGenMinableMetadata(Block.cloth.blockID, 0, 16)).generate(world, random, posX, posY, posZ);
}
for(i = 0; i < 32; ++i) {
posX = chunkX + random.nextInt(16);
posY = random.nextInt(128);
posZ = chunkZ + random.nextInt(16);
(new WorldGenMinableMetadata(Block.cloth.blockID, 1, 16)).generate(world, random, posX, posY, posZ);
}
for(i = 0; i < 32; ++i) {
posX = chunkX + random.nextInt(16);
posY = random.nextInt(128);
posZ = chunkZ + random.nextInt(16);
(new WorldGenMinableMetadata(Block.cloth.blockID, 2, 16)).generate(world, random, posX, posY, posZ);
}
for(i = 0; i < 32; ++i) {
posX = chunkX + random.nextInt(16);
posY = random.nextInt(128);
posZ = chunkZ + random.nextInt(16);
(new WorldGenMinableMetadata(Block.cloth.blockID, 3, 16)).generate(world, random, posX, posY, posZ);
}
for(i = 0; i < 32; ++i) {
posX = chunkX + random.nextInt(16);
posY = random.nextInt(128);
posZ = chunkZ + random.nextInt(16);
(new WorldGenMinableMetadata(Block.cloth.blockID, 4, 16)).generate(world, random, posX, posY, posZ);
}
for(i = 0; i < 32; ++i) {
posX = chunkX + random.nextInt(16);
posY = random.nextInt(128);
posZ = chunkZ + random.nextInt(16);
(new WorldGenMinableMetadata(Block.cloth.blockID, 5, 16)).generate(world, random, posX, posY, posZ);
}
for(i = 0; i < 32; ++i) {
posX = chunkX + random.nextInt(16);
posY = random.nextInt(128);
posZ = chunkZ + random.nextInt(16);
(new WorldGenMinableMetadata(Block.cloth.blockID, 6, 16)).generate(world, random, posX, posY, posZ);
}
for(i = 0; i < 32; ++i) {
posX = chunkX + random.nextInt(16);
posY = random.nextInt(128);
posZ = chunkZ + random.nextInt(16);
(new WorldGenMinableMetadata(Block.cloth.blockID, 7, 16)).generate(world, random, posX, posY, posZ);
}
for(i = 0; i < 32; ++i) {
posX = chunkX + random.nextInt(16);
posY = random.nextInt(128);
posZ = chunkZ + random.nextInt(16);
(new WorldGenMinableMetadata(Block.cloth.blockID, 8, 16)).generate(world, random, posX, posY, posZ);
}
for(i = 0; i < 32; ++i) {
posX = chunkX + random.nextInt(16);
posY = random.nextInt(128);
posZ = chunkZ + random.nextInt(16);
(new WorldGenMinableMetadata(Block.cloth.blockID, 10, 16)).generate(world, random, posX, posY, posZ);
}
for(i = 0; i < 32; ++i) {
posX = chunkX + random.nextInt(16);
posY = random.nextInt(128);
posZ = chunkZ + random.nextInt(16);
(new WorldGenMinableMetadata(Block.cloth.blockID, 11, 16)).generate(world, random, posX, posY, posZ);
}
for(i = 0; i < 32; ++i) {
posX = chunkX + random.nextInt(16);
posY = random.nextInt(128);
posZ = chunkZ + random.nextInt(16);
(new WorldGenMinableMetadata(Block.cloth.blockID, 12, 16)).generate(world, random, posX, posY, posZ);
}
for(i = 0; i < 32; ++i) {
posX = chunkX + random.nextInt(16);
posY = random.nextInt(128);
posZ = chunkZ + random.nextInt(16);
(new WorldGenMinableMetadata(Block.cloth.blockID, 13, 16)).generate(world, random, posX, posY, posZ);
}
for(i = 0; i < 32; ++i) {
posX = chunkX + random.nextInt(16);
posY = random.nextInt(128);
posZ = chunkZ + random.nextInt(16);
(new WorldGenMinableMetadata(Block.cloth.blockID, 14, 16)).generate(world, random, posX, posY, posZ);
}
for(i = 0; i < 32; ++i) {
posX = chunkX + random.nextInt(16);
posY = random.nextInt(128);
posZ = chunkZ + random.nextInt(16);
(new WorldGenMinableMetadata(Block.cloth.blockID, 15, 16)).generate(world, random, posX, posY, posZ);
}
}
public String Version() {
return "v1.0";
}
public String Name() {
return "This is an example of how to use Metadata World Gen.";
}
}