001package net.minecraft.world.gen.structure;
002
003import java.util.List;
004import java.util.Random;
005import net.minecraft.world.World;
006
007public 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 structureboundingbox = new StructureBoundingBox(par2, par3 - 5, par4, par2, par3 + 2, par4);
022
023        switch (par5)
024        {
025            case 0:
026                structureboundingbox.maxX = par2 + 2;
027                structureboundingbox.maxZ = par4 + 8;
028                break;
029            case 1:
030                structureboundingbox.minX = par2 - 8;
031                structureboundingbox.maxZ = par4 + 2;
032                break;
033            case 2:
034                structureboundingbox.maxX = par2 + 2;
035                structureboundingbox.minZ = par4 - 8;
036                break;
037            case 3:
038                structureboundingbox.maxX = par2 + 8;
039                structureboundingbox.maxZ = par4 + 2;
040        }
041
042        return StructureComponent.findIntersecting(par0List, structureboundingbox) != null ? null : structureboundingbox;
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 i = 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, i);
056                break;
057            case 1:
058                StructureMineshaftPieces.getNextComponent(par1StructureComponent, par2List, par3Random, this.boundingBox.minX - 1, this.boundingBox.minY, this.boundingBox.minZ, 1, i);
059                break;
060            case 2:
061                StructureMineshaftPieces.getNextComponent(par1StructureComponent, par2List, par3Random, this.boundingBox.minX, this.boundingBox.minY, this.boundingBox.minZ - 1, 2, i);
062                break;
063            case 3:
064                StructureMineshaftPieces.getNextComponent(par1StructureComponent, par2List, par3Random, this.boundingBox.maxX + 1, this.boundingBox.minY, this.boundingBox.minZ, 3, i);
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 i = 0; i < 5; ++i)
084            {
085                this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 5 - i - (i < 4 ? 1 : 0), 2 + i, 2, 7 - i, 2 + i, 0, 0, false);
086            }
087
088            return true;
089        }
090    }
091}