001package net.minecraft.world.gen.feature; 002 003import java.util.Random; 004import net.minecraft.block.Block; 005import net.minecraft.block.material.Material; 006import net.minecraft.world.World; 007 008public class WorldGenClay extends WorldGenerator 009{ 010 /** The block ID for clay. */ 011 private int clayBlockId; 012 013 /** The number of blocks to generate. */ 014 private int numberOfBlocks; 015 016 public WorldGenClay(int par1) 017 { 018 this.clayBlockId = Block.blockClay.blockID; 019 this.numberOfBlocks = par1; 020 } 021 022 public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) 023 { 024 if (par1World.getBlockMaterial(par3, par4, par5) != Material.water) 025 { 026 return false; 027 } 028 else 029 { 030 int l = par2Random.nextInt(this.numberOfBlocks - 2) + 2; 031 byte b0 = 1; 032 033 for (int i1 = par3 - l; i1 <= par3 + l; ++i1) 034 { 035 for (int j1 = par5 - l; j1 <= par5 + l; ++j1) 036 { 037 int k1 = i1 - par3; 038 int l1 = j1 - par5; 039 040 if (k1 * k1 + l1 * l1 <= l * l) 041 { 042 for (int i2 = par4 - b0; i2 <= par4 + b0; ++i2) 043 { 044 int j2 = par1World.getBlockId(i1, i2, j1); 045 046 if (j2 == Block.dirt.blockID || j2 == Block.blockClay.blockID) 047 { 048 par1World.setBlockAndMetadataWithNotify(i1, i2, j1, this.clayBlockId, 0, 2); 049 } 050 } 051 } 052 } 053 } 054 055 return true; 056 } 057 } 058}