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