001    package net.minecraft.src;
002    
003    import java.util.List;
004    import java.util.Random;
005    
006    public class ComponentStrongholdStraight extends ComponentStronghold
007    {
008        private final EnumDoor doorType;
009        private final boolean expandsX;
010        private final boolean expandsZ;
011    
012        public ComponentStrongholdStraight(int par1, Random par2Random, StructureBoundingBox par3StructureBoundingBox, int par4)
013        {
014            super(par1);
015            this.coordBaseMode = par4;
016            this.doorType = this.getRandomDoor(par2Random);
017            this.boundingBox = par3StructureBoundingBox;
018            this.expandsX = par2Random.nextInt(2) == 0;
019            this.expandsZ = par2Random.nextInt(2) == 0;
020        }
021    
022        /**
023         * Initiates construction of the Structure Component picked, at the current Location of StructGen
024         */
025        public void buildComponent(StructureComponent par1StructureComponent, List par2List, Random par3Random)
026        {
027            this.getNextComponentNormal((ComponentStrongholdStairs2)par1StructureComponent, par2List, par3Random, 1, 1);
028    
029            if (this.expandsX)
030            {
031                this.getNextComponentX((ComponentStrongholdStairs2)par1StructureComponent, par2List, par3Random, 1, 2);
032            }
033    
034            if (this.expandsZ)
035            {
036                this.getNextComponentZ((ComponentStrongholdStairs2)par1StructureComponent, par2List, par3Random, 1, 2);
037            }
038        }
039    
040        public static ComponentStrongholdStraight findValidPlacement(List par0List, Random par1Random, int par2, int par3, int par4, int par5, int par6)
041        {
042            StructureBoundingBox var7 = StructureBoundingBox.getComponentToAddBoundingBox(par2, par3, par4, -1, -1, 0, 5, 5, 7, par5);
043            return canStrongholdGoDeeper(var7) && StructureComponent.findIntersecting(par0List, var7) == null ? new ComponentStrongholdStraight(par6, par1Random, var7, par5) : null;
044        }
045    
046        /**
047         * second Part of Structure generating, this for example places Spiderwebs, Mob Spawners, it closes Mineshafts at
048         * the end, it adds Fences...
049         */
050        public boolean addComponentParts(World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox)
051        {
052            if (this.isLiquidInStructureBoundingBox(par1World, par3StructureBoundingBox))
053            {
054                return false;
055            }
056            else
057            {
058                this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 0, 0, 0, 4, 4, 6, true, par2Random, StructureStrongholdPieces.getStrongholdStones());
059                this.placeDoor(par1World, par2Random, par3StructureBoundingBox, this.doorType, 1, 1, 0);
060                this.placeDoor(par1World, par2Random, par3StructureBoundingBox, EnumDoor.OPENING, 1, 1, 6);
061                this.randomlyPlaceBlock(par1World, par3StructureBoundingBox, par2Random, 0.1F, 1, 2, 1, Block.torchWood.blockID, 0);
062                this.randomlyPlaceBlock(par1World, par3StructureBoundingBox, par2Random, 0.1F, 3, 2, 1, Block.torchWood.blockID, 0);
063                this.randomlyPlaceBlock(par1World, par3StructureBoundingBox, par2Random, 0.1F, 1, 2, 5, Block.torchWood.blockID, 0);
064                this.randomlyPlaceBlock(par1World, par3StructureBoundingBox, par2Random, 0.1F, 3, 2, 5, Block.torchWood.blockID, 0);
065    
066                if (this.expandsX)
067                {
068                    this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 1, 2, 0, 3, 4, 0, 0, false);
069                }
070    
071                if (this.expandsZ)
072                {
073                    this.fillWithBlocks(par1World, par3StructureBoundingBox, 4, 1, 2, 4, 3, 4, 0, 0, false);
074                }
075    
076                return true;
077            }
078        }
079    }