    001    package net.minecraft.src;
    002
    003    import java.util.ArrayList;
    004    import java.util.HashMap;
    005    import java.util.Iterator;
    006    import java.util.List;
    007    import java.util.Map;
    008    import java.util.Map.Entry;
    009
    010    public class FlatGeneratorInfo
    011    {
    012        private final List field_82655_a = new ArrayList();
    013        private final Map field_82653_b = new HashMap();
    014        private int field_82654_c = 0;
    015
    016        public int func_82648_a()
    017        {
    018            return this.field_82654_c;
    019        }
    020
    021        public void func_82647_a(int par1)
    022        {
    023            this.field_82654_c = par1;
    024        }
    025
    026        public Map func_82644_b()
    027        {
    028            return this.field_82653_b;
    029        }
    030
    031        public List func_82650_c()
    032        {
    033            return this.field_82655_a;
    034        }
    035
    036        public void func_82645_d()
    037        {
    038            int var1 = 0;
    039            FlatLayerInfo var3;
    040
    041            for (Iterator var2 = this.field_82655_a.iterator(); var2.hasNext(); var1 += var3.func_82657_a())
    042            {
    043                var3 = (FlatLayerInfo)var2.next();
    044                var3.func_82660_d(var1);
    045            }
    046        }
    047
    048        public String toString()
    049        {
    050            StringBuilder var1 = new StringBuilder();
    051            var1.append(2);
    052            var1.append(";");
    053            int var2;
    054
    055            for (var2 = 0; var2 < this.field_82655_a.size(); ++var2)
    056            {
    057                if (var2 > 0)
    058                {
    059                    var1.append(",");
    060                }
    061
    062                var1.append(((FlatLayerInfo)this.field_82655_a.get(var2)).toString());
    063            }
    064
    065            var1.append(";");
    066            var1.append(this.field_82654_c);
    067
    068            if (!this.field_82653_b.isEmpty())
    069            {
    070                var1.append(";");
    071                var2 = 0;
    072                Iterator var3 = this.field_82653_b.entrySet().iterator();
    073
    074                while (var3.hasNext())
    075                {
    076                    Entry var4 = (Entry)var3.next();
    077
    078                    if (var2++ > 0)
    079                    {
    080                        var1.append(",");
    081                    }
    082
    083                    var1.append(((String)var4.getKey()).toLowerCase());
    084                    Map var5 = (Map)var4.getValue();
    085
    086                    if (!var5.isEmpty())
    087                    {
    088                        var1.append("(");
    089                        int var6 = 0;
    090                        Iterator var7 = var5.entrySet().iterator();
    091
    092                        while (var7.hasNext())
    093                        {
    094                            Entry var8 = (Entry)var7.next();
    095
    096                            if (var6++ > 0)
    097                            {
    098                                var1.append(" ");
    099                            }
    100
    101                            var1.append((String)var8.getKey());
    102                            var1.append("=");
    103                            var1.append((String)var8.getValue());
    104                        }
    105
    106                        var1.append(")");
    107                    }
    108                }
    109            }
    110
    111            return var1.toString();
    112        }
    113
    114        private static FlatLayerInfo func_82646_a(String par0Str, int par1)
    115        {
    116            String[] var2 = par0Str.split("x", 2);
    117            int var3 = 1;
    118            int var5 = 0;
    119
    120            if (var2.length == 2)
    121            {
    122                try
    123                {
    124                    var3 = Integer.parseInt(var2[0]);
    125
    126                    if (par1 + var3 >= 256)
    127                    {
    128                        var3 = 256 - par1;
    129                    }
    130
    131                    if (var3 < 0)
    132                    {
    133                        var3 = 0;
    134                    }
    135                }
    136                catch (Throwable var7)
    137                {
    138                    return null;
    139                }
    140            }
    141
    142            int var4;
    143
    144            try
    145            {
    146                String var6 = var2[var2.length - 1];
    147                var2 = var6.split(":", 2);
    148                var4 = Integer.parseInt(var2[0]);
    149
    150                if (var2.length > 1)
    151                {
    152                    var5 = Integer.parseInt(var2[1]);
    153                }
    154
    155                if (Block.blocksList[var4] == null)
    156                {
    157                    var4 = 0;
    158                    var5 = 0;
    159                }
    160
    161                if (var5 < 0 || var5 > 15)
    162                {
    163                    var5 = 0;
    164                }
    165            }
    166            catch (Throwable var8)
    167            {
    168                return null;
    169            }
    170
    171            FlatLayerInfo var9 = new FlatLayerInfo(var3, var4, var5);
    172            var9.func_82660_d(par1);
    173            return var9;
    174        }
    175
    176        private static List func_82652_b(String par0Str)
    177        {
    178            if (par0Str != null && par0Str.length() >= 1)
    179            {
    180                ArrayList var1 = new ArrayList();
    181                String[] var2 = par0Str.split(",");
    182                int var3 = 0;
    183                String[] var4 = var2;
    184                int var5 = var2.length;
    185
    186                for (int var6 = 0; var6 < var5; ++var6)
    187                {
    188                    String var7 = var4[var6];
    189                    FlatLayerInfo var8 = func_82646_a(var7, var3);
    190
    191                    if (var8 == null)
    192                    {
    193                        return null;
    194                    }
    195
    196                    var1.add(var8);
    197                    var3 += var8.func_82657_a();
    198                }
    199
    200                return var1;
    201            }
    202            else
    203            {
    204                return null;
    205            }
    206        }
    207
    208        public static FlatGeneratorInfo func_82651_a(String par0Str)
    209        {
    210            if (par0Str == null)
    211            {
    212                return func_82649_e();
    213            }
    214            else
    215            {
    216                String[] var1 = par0Str.split(";", -1);
    217                int var2 = var1.length == 1 ? 0 : MathHelper.func_82715_a(var1[0], 0);
    218
    219                if (var2 >= 0 && var2 <= 2)
    220                {
    221                    FlatGeneratorInfo var3 = new FlatGeneratorInfo();
    222                    int var4 = var1.length == 1 ? 0 : 1;
    223                    List var5 = func_82652_b(var1[var4++]);
    224
    225                    if (var5 != null && !var5.isEmpty())
    226                    {
    227                        var3.func_82650_c().addAll(var5);
    228                        var3.func_82645_d();
    229                        int var6 = BiomeGenBase.plains.biomeID;
    230
    231                        if (var2 > 0 && var1.length > var4)
    232                        {
    233                            var6 = MathHelper.func_82715_a(var1[var4++], var6);
    234                        }
    235
    236                        var3.func_82647_a(var6);
    237
    238                        if (var2 > 0 && var1.length > var4)
    239                        {
    240                            String[] var7 = var1[var4++].toLowerCase().split(",");
    241                            String[] var8 = var7;
    242                            int var9 = var7.length;
    243
    244                            for (int var10 = 0; var10 < var9; ++var10)
    245                            {
    246                                String var11 = var8[var10];
    247                                String[] var12 = var11.split("\\(", 2);
    248                                HashMap var13 = new HashMap();
    249
    250                                if (var12[0].length() > 0)
    251                                {
    252                                    var3.func_82644_b().put(var12[0], var13);
    253
    254                                    if (var12.length > 1 && var12[1].endsWith(")") && var12[1].length() > 1)
    255                                    {
    256                                        String[] var14 = var12[1].substring(0, var12[1].length() - 1).split(" ");
    257
    258                                        for (int var15 = 0; var15 < var14.length; ++var15)
    259                                        {
    260                                            String[] var16 = var14[var15].split("=", 2);
    261
    262                                            if (var16.length == 2)
    263                                            {
    264                                                var13.put(var16[0], var16[1]);
    265                                            }
    266                                        }
    267                                    }
    268                                }
    269                            }
    270                        }
    271                        else
    272                        {
    273                            var3.func_82644_b().put("village", new HashMap());
    274                        }
    275
    276                        return var3;
    277                    }
    278                    else
    279                    {
    280                        return func_82649_e();
    281                    }
    282                }
    283                else
    284                {
    285                    return func_82649_e();
    286                }
    287            }
    288        }
    289
    290        public static FlatGeneratorInfo func_82649_e()
    291        {
    292            FlatGeneratorInfo var0 = new FlatGeneratorInfo();
    293            var0.func_82647_a(BiomeGenBase.plains.biomeID);
    294            var0.func_82650_c().add(new FlatLayerInfo(1, Block.bedrock.blockID));
    295            var0.func_82650_c().add(new FlatLayerInfo(2, Block.dirt.blockID));
    296            var0.func_82650_c().add(new FlatLayerInfo(1, Block.grass.blockID));
    297            var0.func_82645_d();
    298            var0.func_82644_b().put("village", new HashMap());
    299            return var0;
    300        }
    301    }