001    package net.minecraft.world.gen.structure;
002    
003    import java.util.List;
004    import java.util.Random;
005    import net.minecraft.world.World;
006    
007    public class ComponentMineshaftStairs extends StructureComponent
008    {
009        public ComponentMineshaftStairs(int par1, Random par2Random, StructureBoundingBox par3StructureBoundingBox, int par4)
010        {
011            super(par1);
012            this.coordBaseMode = par4;
013            this.boundingBox = par3StructureBoundingBox;
014        }
015    
016        /**
017         * Trys to find a valid place to put this component.
018         */
019        public static StructureBoundingBox findValidPlacement(List par0List, Random par1Random, int par2, int par3, int par4, int par5)
020        {
021            StructureBoundingBox var6 = new StructureBoundingBox(par2, par3 - 5, par4, par2, par3 + 2, par4);
022    
023            switch (par5)
024            {
025                case 0:
026                    var6.maxX = par2 + 2;
027                    var6.maxZ = par4 + 8;
028                    break;
029                case 1:
030                    var6.minX = par2 - 8;
031                    var6.maxZ = par4 + 2;
032                    break;
033                case 2:
034                    var6.maxX = par2 + 2;
035                    var6.minZ = par4 - 8;
036                    break;
037                case 3:
038                    var6.maxX = par2 + 8;
039                    var6.maxZ = par4 + 2;
040            }
041    
042            return StructureComponent.findIntersecting(par0List, var6) != null ? null : var6;
043        }
044    
045        /**
046         * Initiates construction of the Structure Component picked, at the current Location of StructGen
047         */
048        public void buildComponent(StructureComponent par1StructureComponent, List par2List, Random par3Random)
049        {
050            int var4 = this.getComponentType();
051    
052            switch (this.coordBaseMode)
053            {
054                case 0:
055                    StructureMineshaftPieces.getNextComponent(par1StructureComponent, par2List, par3Random, this.boundingBox.minX, this.boundingBox.minY, this.boundingBox.maxZ + 1, 0, var4);
056                    break;
057                case 1:
058                    StructureMineshaftPieces.getNextComponent(par1StructureComponent, par2List, par3Random, this.boundingBox.minX - 1, this.boundingBox.minY, this.boundingBox.minZ, 1, var4);
059                    break;
060                case 2:
061                    StructureMineshaftPieces.getNextComponent(par1StructureComponent, par2List, par3Random, this.boundingBox.minX, this.boundingBox.minY, this.boundingBox.minZ - 1, 2, var4);
062                    break;
063                case 3:
064                    StructureMineshaftPieces.getNextComponent(par1StructureComponent, par2List, par3Random, this.boundingBox.maxX + 1, this.boundingBox.minY, this.boundingBox.minZ, 3, var4);
065            }
066        }
067    
068        /**
069         * second Part of Structure generating, this for example places Spiderwebs, Mob Spawners, it closes Mineshafts at
070         * the end, it adds Fences...
071         */
072        public boolean addComponentParts(World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox)
073        {
074            if (this.isLiquidInStructureBoundingBox(par1World, par3StructureBoundingBox))
075            {
076                return false;
077            }
078            else
079            {
080                this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 5, 0, 2, 7, 1, 0, 0, false);
081                this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 0, 7, 2, 2, 8, 0, 0, false);
082    
083                for (int var4 = 0; var4 < 5; ++var4)
084                {
085                    this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 5 - var4 - (var4 < 4 ? 1 : 0), 2 + var4, 2, 7 - var4, 2 + var4, 0, 0, false);
086                }
087    
088                return true;
089            }
090        }
091    }