Ejemplo n.º 1
0
 private static bool Func_21167_a(net.minecraft.src.EnumCreatureType enumcreaturetype
                                  , net.minecraft.src.World world, int i, int j, int k)
 {
     if (enumcreaturetype.GetCreatureMaterial() == net.minecraft.src.Material.water)
     {
         return(world.GetBlockMaterial(i, j, k).GetIsLiquid() && !world.IsBlockNormalCube(
                    i, j + 1, k));
     }
     else
     {
         return(world.IsBlockNormalCube(i, j - 1, k) && !world.IsBlockNormalCube(i, j, k) &&
                !world.GetBlockMaterial(i, j, k).GetIsLiquid() && !world.IsBlockNormalCube(i,
                                                                                           j + 1, k));
     }
 }
Ejemplo n.º 2
0
 public virtual List <SpawnListEntry> GetSpawnableList(net.minecraft.src.EnumCreatureType enumcreaturetype)
 {
     if (enumcreaturetype == net.minecraft.src.EnumCreatureType.monster)
     {
         return(spawnableMonsterList);
     }
     if (enumcreaturetype == net.minecraft.src.EnumCreatureType.creature)
     {
         return(spawnableCreatureList);
     }
     if (enumcreaturetype == net.minecraft.src.EnumCreatureType.waterCreature)
     {
         return(spawnableWaterCreatureList);
     }
     else
     {
         return(null);
     }
 }
Ejemplo n.º 3
0
 public static int PerformSpawning(net.minecraft.src.World var0, bool var1, bool var2
                                   )
 {
     if (!var1 && !var2)
     {
         return(0);
     }
     else
     {
         eligibleChunksForSpawning.Clear();
         int var3;
         int var6;
         for (var3 = 0; var3 < var0.playerEntities.Count; ++var3)
         {
             net.minecraft.src.EntityPlayer var4 = (net.minecraft.src.EntityPlayer)var0.playerEntities
                                                   [var3];
             int var5 = net.minecraft.src.MathHelper.Floor_double(var4.posX / 16.0D);
             var6 = net.minecraft.src.MathHelper.Floor_double(var4.posZ / 16.0D);
             byte var7 = 8;
             for (int var8 = -var7; var8 <= var7; ++var8)
             {
                 for (int var9 = -var7; var9 <= var7; ++var9)
                 {
                     eligibleChunksForSpawning.Add(new net.minecraft.src.ChunkCoordIntPair(var8 + var5, var9 + var6));
                 }
             }
         }
         var3 = 0;
         net.minecraft.src.ChunkCoordinates   var35 = var0.GetSpawnPoint();
         net.minecraft.src.EnumCreatureType[] var36 = net.minecraft.src.EnumCreatureType.Values();
         var6 = var36.Length;
         for (int var37 = 0; var37 < var6; ++var37)
         {
             net.minecraft.src.EnumCreatureType var38 = var36[var37];
             if ((!var38.Func_21103_d() || var2) && (var38.Func_21103_d() || var1) && var0.CountEntities
                     (var38.GetCreatureClass()) <= var38.GetMaxNumberOfCreature() * eligibleChunksForSpawning
                 .Count / 256)
             {
                 System.Collections.IEnumerator var39 = eligibleChunksForSpawning.GetEnumerator();
                 while (var39.MoveNext())
                 {
                     net.minecraft.src.ChunkCoordIntPair var10 = (net.minecraft.src.ChunkCoordIntPair)
                                                                 var39.Current;
                     net.minecraft.src.BiomeGenBase var11 = var0.GetWorldChunkManager().Func_4066_a(var10
                                                                                                    );
                     System.Collections.IList var12 = var11.GetSpawnableList(var38);
                     if (var12 != null && var12.Count > 0)
                     {
                         int var13 = 0;
                         net.minecraft.src.SpawnListEntry var15;
                         for (System.Collections.IEnumerator var14 = var12.GetEnumerator(); var14.MoveNext
                                  (); var13 += var15.spawnRarityRate)
                         {
                             var15 = (net.minecraft.src.SpawnListEntry)var14.Current;
                         }
                         int var40 = var0.rand.Next(var13);
                         var15 = (net.minecraft.src.SpawnListEntry)var12[0];
                         System.Collections.IEnumerator var16 = var12.GetEnumerator();
                         while (var16.MoveNext())
                         {
                             net.minecraft.src.SpawnListEntry var17 = (net.minecraft.src.SpawnListEntry)var16.
                                                                      Current;
                             var40 -= var17.spawnRarityRate;
                             if (var40 < 0)
                             {
                                 var15 = var17;
                                 break;
                             }
                         }
                         net.minecraft.src.ChunkPosition var41 = GetRandomSpawningPointInChunk(var0, var10
                                                                                               .X * 16, var10.Z * 16);
                         int var42 = var41.x;
                         int var18 = var41.y;
                         int var19 = var41.z;
                         if (!var0.IsBlockNormalCube(var42, var18, var19) && var0.GetBlockMaterial(var42,
                                                                                                   var18, var19) == var38.GetCreatureMaterial())
                         {
                             int var20 = 0;
                             for (int var21 = 0; var21 < 3; ++var21)
                             {
                                 int  var22 = var42;
                                 int  var23 = var18;
                                 int  var24 = var19;
                                 byte var25 = 6;
                                 for (int var26 = 0; var26 < 4; ++var26)
                                 {
                                     var22 += var0.rand.Next(var25) - var0.rand.Next(var25);
                                     var23 += var0.rand.Next(1) - var0.rand.Next(1);
                                     var24 += var0.rand.Next(var25) - var0.rand.Next(var25);
                                     if (Func_21167_a(var38, var0, var22, var23, var24))
                                     {
                                         float var27 = (float)var22 + 0.5F;
                                         float var28 = (float)var23;
                                         float var29 = (float)var24 + 0.5F;
                                         if (var0.GetClosestPlayer((double)var27, (double)var28, (double)var29, 24.0D) ==
                                             null)
                                         {
                                             float var30 = var27 - (float)var35.posX;
                                             float var31 = var28 - (float)var35.posY;
                                             float var32 = var29 - (float)var35.posZ;
                                             float var33 = var30 * var30 + var31 * var31 + var32 * var32;
                                             if (var33 >= 576.0F)
                                             {
                                                 net.minecraft.src.EntityLiving var43;
                                                 try
                                                 {
                                                     var43 = (net.minecraft.src.EntityLiving)(var15.entityClass.GetConstructor(new System.Type[] { typeof(net.minecraft.src.World) }).Invoke(new object[] { var0 }));
                                                 }
                                                 catch (System.Exception var34)
                                                 {
                                                     Sharpen.Runtime.PrintStackTrace(var34);
                                                     return(var3);
                                                 }
                                                 var43.SetLocationAndAngles((double)var27, (double)var28, (double)var29, var0.rand
                                                                            .NextFloat() * 360.0F, 0.0F);
                                                 if (var43.GetCanSpawnHere())
                                                 {
                                                     ++var20;
                                                     var0.AddEntity(var43);
                                                     Func_21166_a(var43, var0, var27, var28, var29);
                                                     if (var20 >= var43.GetMaxSpawnedInChunk())
                                                     {
                                                         goto label113_continue;
                                                     }
                                                 }
                                                 var3 += var20;
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                     label113_continue :;
                 }
                 label113_break :;
             }
         }
         return(var3);
     }
 }