001    package net.minecraft.src;
002    
003    import java.util.List;
004    import java.util.Random;
005    
006    public class ComponentStrongholdChestCorridor extends ComponentStronghold
007    {
008        private static final WeightedRandomChestContent[] field_75003_a = new WeightedRandomChestContent[] {new WeightedRandomChestContent(Item.enderPearl.shiftedIndex, 0, 1, 1, 10), new WeightedRandomChestContent(Item.diamond.shiftedIndex, 0, 1, 3, 3), new WeightedRandomChestContent(Item.ingotIron.shiftedIndex, 0, 1, 5, 10), new WeightedRandomChestContent(Item.ingotGold.shiftedIndex, 0, 1, 3, 5), new WeightedRandomChestContent(Item.redstone.shiftedIndex, 0, 4, 9, 5), new WeightedRandomChestContent(Item.bread.shiftedIndex, 0, 1, 3, 15), new WeightedRandomChestContent(Item.appleRed.shiftedIndex, 0, 1, 3, 15), new WeightedRandomChestContent(Item.pickaxeSteel.shiftedIndex, 0, 1, 1, 5), new WeightedRandomChestContent(Item.swordSteel.shiftedIndex, 0, 1, 1, 5), new WeightedRandomChestContent(Item.plateSteel.shiftedIndex, 0, 1, 1, 5), new WeightedRandomChestContent(Item.helmetSteel.shiftedIndex, 0, 1, 1, 5), new WeightedRandomChestContent(Item.legsSteel.shiftedIndex, 0, 1, 1, 5), new WeightedRandomChestContent(Item.bootsSteel.shiftedIndex, 0, 1, 1, 5), new WeightedRandomChestContent(Item.appleGold.shiftedIndex, 0, 1, 1, 1)};
009        private final EnumDoor doorType;
010        private boolean hasMadeChest;
011    
012        public ComponentStrongholdChestCorridor(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        }
019    
020        /**
021         * Initiates construction of the Structure Component picked, at the current Location of StructGen
022         */
023        public void buildComponent(StructureComponent par1StructureComponent, List par2List, Random par3Random)
024        {
025            this.getNextComponentNormal((ComponentStrongholdStairs2)par1StructureComponent, par2List, par3Random, 1, 1);
026        }
027    
028        public static ComponentStrongholdChestCorridor findValidPlacement(List par0List, Random par1Random, int par2, int par3, int par4, int par5, int par6)
029        {
030            StructureBoundingBox var7 = StructureBoundingBox.getComponentToAddBoundingBox(par2, par3, par4, -1, -1, 0, 5, 5, 7, par5);
031            return canStrongholdGoDeeper(var7) && StructureComponent.findIntersecting(par0List, var7) == null ? new ComponentStrongholdChestCorridor(par6, par1Random, var7, par5) : null;
032        }
033    
034        /**
035         * second Part of Structure generating, this for example places Spiderwebs, Mob Spawners, it closes Mineshafts at
036         * the end, it adds Fences...
037         */
038        public boolean addComponentParts(World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox)
039        {
040            if (this.isLiquidInStructureBoundingBox(par1World, par3StructureBoundingBox))
041            {
042                return false;
043            }
044            else
045            {
046                this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 0, 0, 0, 4, 4, 6, true, par2Random, StructureStrongholdPieces.getStrongholdStones());
047                this.placeDoor(par1World, par2Random, par3StructureBoundingBox, this.doorType, 1, 1, 0);
048                this.placeDoor(par1World, par2Random, par3StructureBoundingBox, EnumDoor.OPENING, 1, 1, 6);
049                this.fillWithBlocks(par1World, par3StructureBoundingBox, 3, 1, 2, 3, 1, 4, Block.stoneBrick.blockID, Block.stoneBrick.blockID, false);
050                this.placeBlockAtCurrentPosition(par1World, Block.stoneSingleSlab.blockID, 5, 3, 1, 1, par3StructureBoundingBox);
051                this.placeBlockAtCurrentPosition(par1World, Block.stoneSingleSlab.blockID, 5, 3, 1, 5, par3StructureBoundingBox);
052                this.placeBlockAtCurrentPosition(par1World, Block.stoneSingleSlab.blockID, 5, 3, 2, 2, par3StructureBoundingBox);
053                this.placeBlockAtCurrentPosition(par1World, Block.stoneSingleSlab.blockID, 5, 3, 2, 4, par3StructureBoundingBox);
054                int var4;
055    
056                for (var4 = 2; var4 <= 4; ++var4)
057                {
058                    this.placeBlockAtCurrentPosition(par1World, Block.stoneSingleSlab.blockID, 5, 2, 1, var4, par3StructureBoundingBox);
059                }
060    
061                if (!this.hasMadeChest)
062                {
063                    var4 = this.getYWithOffset(2);
064                    int var5 = this.getXWithOffset(3, 3);
065                    int var6 = this.getZWithOffset(3, 3);
066    
067                    if (par3StructureBoundingBox.isVecInside(var5, var4, var6))
068                    {
069                        this.hasMadeChest = true;
070                        this.func_74879_a(par1World, par3StructureBoundingBox, par2Random, 3, 2, 3, field_75003_a, 2 + par2Random.nextInt(2));
071                    }
072                }
073    
074                return true;
075            }
076        }
077    }