    001    package net.minecraft.src;
    002
    003    import java.util.Iterator;
    004    import java.util.LinkedList;
    005    import java.util.List;
    006    import java.util.Random;
    007
    008    public class ComponentMineshaftRoom extends StructureComponent
    009    {
    010        /** List of other Mineshaft components linked to this room. */
    011        private List roomsLinkedToTheRoom = new LinkedList();
    012
    013        public ComponentMineshaftRoom(int par1, Random par2Random, int par3, int par4)
    014        {
    015            super(par1);
    016            this.boundingBox = new StructureBoundingBox(par3, 50, par4, par3 + 7 + par2Random.nextInt(6), 54 + par2Random.nextInt(6), par4 + 7 + par2Random.nextInt(6));
    017        }
    018
    019        /**
    020         * Initiates construction of the Structure Component picked, at the current Location of StructGen
    021         */
    022        public void buildComponent(StructureComponent par1StructureComponent, List par2List, Random par3Random)
    023        {
    024            int var4 = this.getComponentType();
    025            int var6 = this.boundingBox.getYSize() - 3 - 1;
    026
    027            if (var6 <= 0)
    028            {
    029                var6 = 1;
    030            }
    031
    032            int var5;
    033            StructureComponent var7;
    034            StructureBoundingBox var8;
    035
    036            for (var5 = 0; var5 < this.boundingBox.getXSize(); var5 += 4)
    037            {
    038                var5 += par3Random.nextInt(this.boundingBox.getXSize());
    039
    040                if (var5 + 3 > this.boundingBox.getXSize())
    041                {
    042                    break;
    043                }
    044
    045                var7 = StructureMineshaftPieces.getNextComponent(par1StructureComponent, par2List, par3Random, this.boundingBox.minX + var5, this.boundingBox.minY + par3Random.nextInt(var6) + 1, this.boundingBox.minZ - 1, 2, var4);
    046
    047                if (var7 != null)
    048                {
    049                    var8 = var7.getBoundingBox();
    050                    this.roomsLinkedToTheRoom.add(new StructureBoundingBox(var8.minX, var8.minY, this.boundingBox.minZ, var8.maxX, var8.maxY, this.boundingBox.minZ + 1));
    051                }
    052            }
    053
    054            for (var5 = 0; var5 < this.boundingBox.getXSize(); var5 += 4)
    055            {
    056                var5 += par3Random.nextInt(this.boundingBox.getXSize());
    057
    058                if (var5 + 3 > this.boundingBox.getXSize())
    059                {
    060                    break;
    061                }
    062
    063                var7 = StructureMineshaftPieces.getNextComponent(par1StructureComponent, par2List, par3Random, this.boundingBox.minX + var5, this.boundingBox.minY + par3Random.nextInt(var6) + 1, this.boundingBox.maxZ + 1, 0, var4);
    064
    065                if (var7 != null)
    066                {
    067                    var8 = var7.getBoundingBox();
    068                    this.roomsLinkedToTheRoom.add(new StructureBoundingBox(var8.minX, var8.minY, this.boundingBox.maxZ - 1, var8.maxX, var8.maxY, this.boundingBox.maxZ));
    069                }
    070            }
    071
    072            for (var5 = 0; var5 < this.boundingBox.getZSize(); var5 += 4)
    073            {
    074                var5 += par3Random.nextInt(this.boundingBox.getZSize());
    075
    076                if (var5 + 3 > this.boundingBox.getZSize())
    077                {
    078                    break;
    079                }
    080
    081                var7 = StructureMineshaftPieces.getNextComponent(par1StructureComponent, par2List, par3Random, this.boundingBox.minX - 1, this.boundingBox.minY + par3Random.nextInt(var6) + 1, this.boundingBox.minZ + var5, 1, var4);
    082
    083                if (var7 != null)
    084                {
    085                    var8 = var7.getBoundingBox();
    086                    this.roomsLinkedToTheRoom.add(new StructureBoundingBox(this.boundingBox.minX, var8.minY, var8.minZ, this.boundingBox.minX + 1, var8.maxY, var8.maxZ));
    087                }
    088            }
    089
    090            for (var5 = 0; var5 < this.boundingBox.getZSize(); var5 += 4)
    091            {
    092                var5 += par3Random.nextInt(this.boundingBox.getZSize());
    093
    094                if (var5 + 3 > this.boundingBox.getZSize())
    095                {
    096                    break;
    097                }
    098
    099                var7 = StructureMineshaftPieces.getNextComponent(par1StructureComponent, par2List, par3Random, this.boundingBox.maxX + 1, this.boundingBox.minY + par3Random.nextInt(var6) + 1, this.boundingBox.minZ + var5, 3, var4);
    100
    101                if (var7 != null)
    102                {
    103                    var8 = var7.getBoundingBox();
    104                    this.roomsLinkedToTheRoom.add(new StructureBoundingBox(this.boundingBox.maxX - 1, var8.minY, var8.minZ, this.boundingBox.maxX, var8.maxY, var8.maxZ));
    105                }
    106            }
    107        }
    108
    109        /**
    110         * second Part of Structure generating, this for example places Spiderwebs, Mob Spawners, it closes Mineshafts at
    111         * the end, it adds Fences...
    112         */
    113        public boolean addComponentParts(World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox)
    114        {
    115            if (this.isLiquidInStructureBoundingBox(par1World, par3StructureBoundingBox))
    116            {
    117                return false;
    118            }
    119            else
    120            {
    121                this.fillWithBlocks(par1World, par3StructureBoundingBox, this.boundingBox.minX, this.boundingBox.minY, this.boundingBox.minZ, this.boundingBox.maxX, this.boundingBox.minY, this.boundingBox.maxZ, Block.dirt.blockID, 0, true);
    122                this.fillWithBlocks(par1World, par3StructureBoundingBox, this.boundingBox.minX, this.boundingBox.minY + 1, this.boundingBox.minZ, this.boundingBox.maxX, Math.min(this.boundingBox.minY + 3, this.boundingBox.maxY), this.boundingBox.maxZ, 0, 0, false);
    123                Iterator var4 = this.roomsLinkedToTheRoom.iterator();
    124
    125                while (var4.hasNext())
    126                {
    127                    StructureBoundingBox var5 = (StructureBoundingBox)var4.next();
    128                    this.fillWithBlocks(par1World, par3StructureBoundingBox, var5.minX, var5.maxY - 2, var5.minZ, var5.maxX, var5.maxY, var5.maxZ, 0, 0, false);
    129                }
    130
    131                this.randomlyRareFillWithBlocks(par1World, par3StructureBoundingBox, this.boundingBox.minX, this.boundingBox.minY + 4, this.boundingBox.minZ, this.boundingBox.maxX, this.boundingBox.maxY, this.boundingBox.maxZ, 0, false);
    132                return true;
    133            }
    134        }
    135    }