    001    package net.minecraft.src;
    002
    003    import java.util.Arrays;
    004    import java.util.List;
    005    import java.util.Random;
    006
    007    public class MapGenVillage extends MapGenStructure
    008    {
    009        /** A list of all the biomes villages can spawn in. */
    010        public static List villageSpawnBiomes = Arrays.asList(new BiomeGenBase[] {BiomeGenBase.plains, BiomeGenBase.desert});
    011
    012        /** World terrain type, 0 for normal, 1 for flat map */
    013        private final int terrainType;
    014
    015        public MapGenVillage(int par1)
    016        {
    017            this.terrainType = par1;
    018        }
    019
    020        protected boolean canSpawnStructureAtCoords(int par1, int par2)
    021        {
    022            byte var3 = 32;
    023            byte var4 = 8;
    024            int var5 = par1;
    025            int var6 = par2;
    026
    027            if (par1 < 0)
    028            {
    029                par1 -= var3 - 1;
    030            }
    031
    032            if (par2 < 0)
    033            {
    034                par2 -= var3 - 1;
    035            }
    036
    037            int var7 = par1 / var3;
    038            int var8 = par2 / var3;
    039            Random var9 = this.worldObj.setRandomSeed(var7, var8, 10387312);
    040            var7 *= var3;
    041            var8 *= var3;
    042            var7 += var9.nextInt(var3 - var4);
    043            var8 += var9.nextInt(var3 - var4);
    044
    045            if (var5 == var7 && var6 == var8)
    046            {
    047                boolean var10 = this.worldObj.getWorldChunkManager().areBiomesViable(var5 * 16 + 8, var6 * 16 + 8, 0, villageSpawnBiomes);
    048
    049                if (var10)
    050                {
    051                    return true;
    052                }
    053            }
    054
    055            return false;
    056        }
    057
    058        protected StructureStart getStructureStart(int par1, int par2)
    059        {
    060            return new StructureVillageStart(this.worldObj, this.rand, par1, par2, this.terrainType);
    061        }
    062    }