    001    package net.minecraft.src;
    002
    003    import java.util.List;
    004    import java.util.Random;
    005
    006    public class ComponentVillagePathGen extends ComponentVillageRoadPiece
    007    {
    008        private int averageGroundLevel;
    009
    010        public ComponentVillagePathGen(ComponentVillageStartPiece par1ComponentVillageStartPiece, int par2, Random par3Random, StructureBoundingBox par4StructureBoundingBox, int par5)
    011        {
    012            super(par1ComponentVillageStartPiece, par2);
    013            this.coordBaseMode = par5;
    014            this.boundingBox = par4StructureBoundingBox;
    015            this.averageGroundLevel = Math.max(par4StructureBoundingBox.getXSize(), par4StructureBoundingBox.getZSize());
    016        }
    017
    018        /**
    019         * Initiates construction of the Structure Component picked, at the current Location of StructGen
    020         */
    021        public void buildComponent(StructureComponent par1StructureComponent, List par2List, Random par3Random)
    022        {
    023            boolean var4 = false;
    024            int var5;
    025            StructureComponent var6;
    026
    027            for (var5 = par3Random.nextInt(5); var5 < this.averageGroundLevel - 8; var5 += 2 + par3Random.nextInt(5))
    028            {
    029                var6 = this.getNextComponentNN((ComponentVillageStartPiece)par1StructureComponent, par2List, par3Random, 0, var5);
    030
    031                if (var6 != null)
    032                {
    033                    var5 += Math.max(var6.boundingBox.getXSize(), var6.boundingBox.getZSize());
    034                    var4 = true;
    035                }
    036            }
    037
    038            for (var5 = par3Random.nextInt(5); var5 < this.averageGroundLevel - 8; var5 += 2 + par3Random.nextInt(5))
    039            {
    040                var6 = this.getNextComponentPP((ComponentVillageStartPiece)par1StructureComponent, par2List, par3Random, 0, var5);
    041
    042                if (var6 != null)
    043                {
    044                    var5 += Math.max(var6.boundingBox.getXSize(), var6.boundingBox.getZSize());
    045                    var4 = true;
    046                }
    047            }
    048
    049            if (var4 && par3Random.nextInt(3) > 0)
    050            {
    051                switch (this.coordBaseMode)
    052                {
    053                    case 0:
    054                        StructureVillagePieces.getNextStructureComponentVillagePath((ComponentVillageStartPiece)par1StructureComponent, par2List, par3Random, this.boundingBox.minX - 1, this.boundingBox.minY, this.boundingBox.maxZ - 2, 1, this.getComponentType());
    055                        break;
    056                    case 1:
    057                        StructureVillagePieces.getNextStructureComponentVillagePath((ComponentVillageStartPiece)par1StructureComponent, par2List, par3Random, this.boundingBox.minX, this.boundingBox.minY, this.boundingBox.minZ - 1, 2, this.getComponentType());
    058                        break;
    059                    case 2:
    060                        StructureVillagePieces.getNextStructureComponentVillagePath((ComponentVillageStartPiece)par1StructureComponent, par2List, par3Random, this.boundingBox.minX - 1, this.boundingBox.minY, this.boundingBox.minZ, 1, this.getComponentType());
    061                        break;
    062                    case 3:
    063                        StructureVillagePieces.getNextStructureComponentVillagePath((ComponentVillageStartPiece)par1StructureComponent, par2List, par3Random, this.boundingBox.maxX - 2, this.boundingBox.minY, this.boundingBox.minZ - 1, 2, this.getComponentType());
    064                }
    065            }
    066
    067            if (var4 && par3Random.nextInt(3) > 0)
    068            {
    069                switch (this.coordBaseMode)
    070                {
    071                    case 0:
    072                        StructureVillagePieces.getNextStructureComponentVillagePath((ComponentVillageStartPiece)par1StructureComponent, par2List, par3Random, this.boundingBox.maxX + 1, this.boundingBox.minY, this.boundingBox.maxZ - 2, 3, this.getComponentType());
    073                        break;
    074                    case 1:
    075                        StructureVillagePieces.getNextStructureComponentVillagePath((ComponentVillageStartPiece)par1StructureComponent, par2List, par3Random, this.boundingBox.minX, this.boundingBox.minY, this.boundingBox.maxZ + 1, 0, this.getComponentType());
    076                        break;
    077                    case 2:
    078                        StructureVillagePieces.getNextStructureComponentVillagePath((ComponentVillageStartPiece)par1StructureComponent, par2List, par3Random, this.boundingBox.maxX + 1, this.boundingBox.minY, this.boundingBox.minZ, 3, this.getComponentType());
    079                        break;
    080                    case 3:
    081                        StructureVillagePieces.getNextStructureComponentVillagePath((ComponentVillageStartPiece)par1StructureComponent, par2List, par3Random, this.boundingBox.maxX - 2, this.boundingBox.minY, this.boundingBox.maxZ + 1, 0, this.getComponentType());
    082                }
    083            }
    084        }
    085
    086        public static StructureBoundingBox func_74933_a(ComponentVillageStartPiece par0ComponentVillageStartPiece, List par1List, Random par2Random, int par3, int par4, int par5, int par6)
    087        {
    088            for (int var7 = 7 * MathHelper.getRandomIntegerInRange(par2Random, 3, 5); var7 >= 7; var7 -= 7)
    089            {
    090                StructureBoundingBox var8 = StructureBoundingBox.getComponentToAddBoundingBox(par3, par4, par5, 0, 0, 0, 3, 3, var7, par6);
    091
    092                if (StructureComponent.findIntersecting(par1List, var8) == null)
    093                {
    094                    return var8;
    095                }
    096            }
    097
    098            return null;
    099        }
    100
    101        /**
    102         * second Part of Structure generating, this for example places Spiderwebs, Mob Spawners, it closes Mineshafts at
    103         * the end, it adds Fences...
    104         */
    105        public boolean addComponentParts(World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox)
    106        {
    107            int var4 = this.getBiomeSpecificBlock(Block.gravel.blockID, 0);
    108
    109            for (int var5 = this.boundingBox.minX; var5 <= this.boundingBox.maxX; ++var5)
    110            {
    111                for (int var6 = this.boundingBox.minZ; var6 <= this.boundingBox.maxZ; ++var6)
    112                {
    113                    if (par3StructureBoundingBox.isVecInside(var5, 64, var6))
    114                    {
    115                        int var7 = par1World.getTopSolidOrLiquidBlock(var5, var6) - 1;
    116                        par1World.setBlock(var5, var7, var6, var4);
    117                    }
    118                }
    119            }
    120
    121            return true;
    122        }
    123    }