001 package net.minecraft.src; 002 003 import java.util.List; 004 import java.util.Random; 005 006 public class ComponentVillageField2 extends ComponentVillage 007 { 008 private int averageGroundLevel = -1; 009 private int field_82675_b; 010 private int field_82676_c; 011 012 public ComponentVillageField2(ComponentVillageStartPiece par1ComponentVillageStartPiece, int par2, Random par3Random, StructureBoundingBox par4StructureBoundingBox, int par5) 013 { 014 super(par1ComponentVillageStartPiece, par2); 015 this.coordBaseMode = par5; 016 this.boundingBox = par4StructureBoundingBox; 017 this.field_82675_b = this.func_82674_a(par3Random); 018 this.field_82676_c = this.func_82674_a(par3Random); 019 } 020 021 private int func_82674_a(Random par1Random) 022 { 023 switch (par1Random.nextInt(5)) 024 { 025 case 0: 026 return Block.field_82513_cg.blockID; 027 case 1: 028 return Block.field_82514_ch.blockID; 029 default: 030 return Block.crops.blockID; 031 } 032 } 033 034 public static ComponentVillageField2 func_74902_a(ComponentVillageStartPiece par0ComponentVillageStartPiece, List par1List, Random par2Random, int par3, int par4, int par5, int par6, int par7) 035 { 036 StructureBoundingBox var8 = StructureBoundingBox.getComponentToAddBoundingBox(par3, par4, par5, 0, 0, 0, 7, 4, 9, par6); 037 return canVillageGoDeeper(var8) && StructureComponent.findIntersecting(par1List, var8) == null ? new ComponentVillageField2(par0ComponentVillageStartPiece, par7, par2Random, var8, par6) : null; 038 } 039 040 /** 041 * second Part of Structure generating, this for example places Spiderwebs, Mob Spawners, it closes Mineshafts at 042 * the end, it adds Fences... 043 */ 044 public boolean addComponentParts(World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox) 045 { 046 if (this.averageGroundLevel < 0) 047 { 048 this.averageGroundLevel = this.getAverageGroundLevel(par1World, par3StructureBoundingBox); 049 050 if (this.averageGroundLevel < 0) 051 { 052 return true; 053 } 054 055 this.boundingBox.offset(0, this.averageGroundLevel - this.boundingBox.maxY + 4 - 1, 0); 056 } 057 058 this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 1, 0, 6, 4, 8, 0, 0, false); 059 this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 0, 1, 2, 0, 7, Block.tilledField.blockID, Block.tilledField.blockID, false); 060 this.fillWithBlocks(par1World, par3StructureBoundingBox, 4, 0, 1, 5, 0, 7, Block.tilledField.blockID, Block.tilledField.blockID, false); 061 this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 0, 0, 0, 0, 8, Block.wood.blockID, Block.wood.blockID, false); 062 this.fillWithBlocks(par1World, par3StructureBoundingBox, 6, 0, 0, 6, 0, 8, Block.wood.blockID, Block.wood.blockID, false); 063 this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 0, 0, 5, 0, 0, Block.wood.blockID, Block.wood.blockID, false); 064 this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 0, 8, 5, 0, 8, Block.wood.blockID, Block.wood.blockID, false); 065 this.fillWithBlocks(par1World, par3StructureBoundingBox, 3, 0, 1, 3, 0, 7, Block.waterMoving.blockID, Block.waterMoving.blockID, false); 066 int var4; 067 068 for (var4 = 1; var4 <= 7; ++var4) 069 { 070 this.placeBlockAtCurrentPosition(par1World, this.field_82675_b, MathHelper.getRandomIntegerInRange(par2Random, 2, 7), 1, 1, var4, par3StructureBoundingBox); 071 this.placeBlockAtCurrentPosition(par1World, this.field_82675_b, MathHelper.getRandomIntegerInRange(par2Random, 2, 7), 2, 1, var4, par3StructureBoundingBox); 072 this.placeBlockAtCurrentPosition(par1World, this.field_82676_c, MathHelper.getRandomIntegerInRange(par2Random, 2, 7), 4, 1, var4, par3StructureBoundingBox); 073 this.placeBlockAtCurrentPosition(par1World, this.field_82676_c, MathHelper.getRandomIntegerInRange(par2Random, 2, 7), 5, 1, var4, par3StructureBoundingBox); 074 } 075 076 for (var4 = 0; var4 < 9; ++var4) 077 { 078 for (int var5 = 0; var5 < 7; ++var5) 079 { 080 this.clearCurrentPositionBlocksUpwards(par1World, var5, 4, var4, par3StructureBoundingBox); 081 this.fillCurrentPositionBlocksDownwards(par1World, Block.dirt.blockID, 0, var5, -1, var4, par3StructureBoundingBox); 082 } 083 } 084 085 return true; 086 } 087 }