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