    001    package net.minecraft.src;
    002
    003    import java.util.ArrayList;
    004    import java.util.Arrays;
    005    import java.util.Iterator;
    006    import java.util.List;
    007    import java.util.Map;
    008    import java.util.Random;
    009    import java.util.Map.Entry;
    010
    011    public class MapGenScatteredFeature extends MapGenStructure
    012    {
    013        private static List biomelist = Arrays.asList(new BiomeGenBase[] {BiomeGenBase.desert, BiomeGenBase.desertHills, BiomeGenBase.jungle, BiomeGenBase.jungleHills, BiomeGenBase.swampland});
    014        private List field_82668_f;
    015        private int field_82669_g;
    016        private int field_82670_h;
    017
    018        public MapGenScatteredFeature()
    019        {
    020            this.field_82668_f = new ArrayList();
    021            this.field_82669_g = 32;
    022            this.field_82670_h = 8;
    023            this.field_82668_f.add(new SpawnListEntry(EntityWitch.class, 1, 1, 1));
    024        }
    025
    026        public MapGenScatteredFeature(Map par1Map)
    027        {
    028            this();
    029            Iterator var2 = par1Map.entrySet().iterator();
    030
    031            while (var2.hasNext())
    032            {
    033                Entry var3 = (Entry)var2.next();
    034
    035                if (((String)var3.getKey()).equals("distance"))
    036                {
    037                    this.field_82669_g = MathHelper.func_82714_a((String)var3.getValue(), this.field_82669_g, this.field_82670_h + 1);
    038                }
    039            }
    040        }
    041
    042        protected boolean canSpawnStructureAtCoords(int par1, int par2)
    043        {
    044            int var3 = par1;
    045            int var4 = par2;
    046
    047            if (par1 < 0)
    048            {
    049                par1 -= this.field_82669_g - 1;
    050            }
    051
    052            if (par2 < 0)
    053            {
    054                par2 -= this.field_82669_g - 1;
    055            }
    056
    057            int var5 = par1 / this.field_82669_g;
    058            int var6 = par2 / this.field_82669_g;
    059            Random var7 = this.worldObj.setRandomSeed(var5, var6, 14357617);
    060            var5 *= this.field_82669_g;
    061            var6 *= this.field_82669_g;
    062            var5 += var7.nextInt(this.field_82669_g - this.field_82670_h);
    063            var6 += var7.nextInt(this.field_82669_g - this.field_82670_h);
    064
    065            if (var3 == var5 && var4 == var6)
    066            {
    067                boolean var8 = this.worldObj.getWorldChunkManager().areBiomesViable(var3 * 16 + 8, var4 * 16 + 8, 0, biomelist);
    068
    069                if (var8)
    070                {
    071                    return true;
    072                }
    073            }
    074
    075            return false;
    076        }
    077
    078        protected StructureStart getStructureStart(int par1, int par2)
    079        {
    080            return new StructureScatteredFeatureStart(this.worldObj, this.rand, par1, par2);
    081        }
    082
    083        public List func_82667_a()
    084        {
    085            return this.field_82668_f;
    086        }
    087    }