/// <summary> /// Returns whether or not the specified creature type can spawn at the specified location. /// </summary> public static bool CanCreatureTypeSpawnAtLocation(CreatureType par0EnumCreatureType, World par1World, int par2, int par3, int par4) { if (par0EnumCreatureType.CreatureMaterial == Material.Water) { return(par1World.GetBlockMaterial(par2, par3, par4).IsLiquid() && !par1World.IsBlockNormalCube(par2, par3 + 1, par4)); } else { int i = par1World.GetBlockId(par2, par3 - 1, par4); return(Block.IsNormalCube(i) && i != Block.Bedrock.BlockID && !par1World.IsBlockNormalCube(par2, par3, par4) && !par1World.GetBlockMaterial(par2, par3, par4).IsLiquid() && !par1World.IsBlockNormalCube(par2, par3 + 1, par4)); } }
///<summary> /// Returns a list of creatures of the specified type that can spawn at the given location. ///</summary> public List <SpawnListEntry> GetPossibleCreatures(CreatureType par1EnumCreatureType, int par2, int par3, int par4) { BiomeGenBase biomegenbase = worldObj.GetBiomeGenForCoords(par2, par4); if (biomegenbase == null) { return(null); } else { return(biomegenbase.GetSpawnableList(par1EnumCreatureType)); } }
///<summary> /// Returns a list of creatures of the specified type that can spawn at the given location. ///</summary> public List <SpawnListEntry> GetPossibleCreatures(CreatureType par1EnumCreatureType, int par2, int par3, int par4) { if (par1EnumCreatureType == CreatureType.Monster && GenNetherBridge.Func_40483_a(par2, par3, par4)) { return(GenNetherBridge.GetSpawnList()); } BiomeGenBase biomegenbase = worldObj.GetBiomeGenForCoords(par2, par4); if (biomegenbase == null) { return(null); } else { return(biomegenbase.GetSpawnableList(par1EnumCreatureType)); } }
/// <summary> /// Returns the correspondent list of the EnumCreatureType informed. /// </summary> public virtual List <SpawnListEntry> GetSpawnableList(CreatureType par1EnumCreatureType) { if (par1EnumCreatureType == CreatureType.Monster) { return(SpawnableMonsterList); } if (par1EnumCreatureType == CreatureType.Creature) { return(SpawnableCreatureList); } if (par1EnumCreatureType == CreatureType.WaterCreature) { return(SpawnableWaterCreatureList); } else { return(null); } }
/// <summary> /// Returns a list of creatures of the specified type that can spawn at the given location. /// </summary> public virtual List <SpawnListEntry> GetPossibleCreatures(CreatureType par1EnumCreatureType, int par2, int par3, int par4) { return(ChunkProvider.GetPossibleCreatures(par1EnumCreatureType, par2, par3, par4)); }
/// <summary> /// The main spawning algorithm, spawns three random creatures of types in the subclass array /// </summary> public static int PerformSpawning(World par0World, bool par1, bool par2) { if (!par1 && !par2) { return(0); } else { EligibleChunksForSpawning.Clear(); int var3; int var6; for (var3 = 0; var3 < par0World.PlayerEntities.Count; ++var3) { EntityPlayer var4 = (EntityPlayer)par0World.PlayerEntities[var3]; int var5 = MathHelper2.Floor_double(var4.PosX / 16.0D); var6 = MathHelper2.Floor_double(var4.PosZ / 16.0D); sbyte var7 = 8; for (int var8 = -var7; var8 <= var7; ++var8) { for (int var9 = -var7; var9 <= var7; ++var9) { bool var10 = var8 == -var7 || var8 == var7 || var9 == -var7 || var9 == var7; ChunkCoordIntPair var11 = new ChunkCoordIntPair(var8 + var5, var9 + var6); if (!var10) { EligibleChunksForSpawning[var11] = false; } else if (!EligibleChunksForSpawning.ContainsKey(var11)) { EligibleChunksForSpawning[var11] = true; } } } } var3 = 0; ChunkCoordinates var31 = par0World.GetSpawnPoint(); CreatureType[] var32 = CreatureType.GetValues(); var6 = var32.Length; for (int var33 = 0; var33 < var6; ++var33) { CreatureType var34 = var32[var33]; if ((!var34.IsPeacefulCreature || par2) && (var34.IsPeacefulCreature || par1) && par0World.CountEntities(var34.CreatureClass) <= var34.MaxNumberOfCreature * EligibleChunksForSpawning.Count / 256) { IEnumerator <ChunkCoordIntPair> var35 = EligibleChunksForSpawning.Keys.GetEnumerator(); label108: while (var35.MoveNext()) { ChunkCoordIntPair var37 = var35.Current; if (!EligibleChunksForSpawning[var37]) { ChunkPosition var36 = GetRandomSpawningPointInChunk(par0World, var37.ChunkXPos, var37.ChunkZPos); int var12 = var36.x; int var13 = var36.y; int var14 = var36.z; if (!par0World.IsBlockNormalCube(var12, var13, var14) && par0World.GetBlockMaterial(var12, var13, var14) == var34.CreatureMaterial) { int var15 = 0; int var16 = 0; while (var16 < 3) { int var17 = var12; int var18 = var13; int var19 = var14; sbyte var20 = 6; SpawnListEntry var21 = null; int var22 = 0; while (true) { if (var22 < 4) { label101: { var17 += par0World.Rand.Next(var20) - par0World.Rand.Next(var20); var18 += par0World.Rand.Next(1) - par0World.Rand.Next(1); var19 += par0World.Rand.Next(var20) - par0World.Rand.Next(var20); if (CanCreatureTypeSpawnAtLocation(var34, par0World, var17, var18, var19)) { float var23 = (float)var17 + 0.5F; float var24 = (float)var18; float var25 = (float)var19 + 0.5F; if (par0World.GetClosestPlayer(var23, var24, var25, 24) == null) { float var26 = var23 - (float)var31.PosX; float var27 = var24 - (float)var31.PosY; float var28 = var25 - (float)var31.PosZ; float var29 = var26 * var26 + var27 * var27 + var28 * var28; if (var29 >= 576.0F) { if (var21 == null) { var21 = par0World.GetRandomMob(var34, var17, var18, var19); if (var21 == null) { goto label101; } } EntityLiving var38; try { var38 = (EntityLiving)Activator.CreateInstance(var21.EntityClass, new object[] { par0World }); } catch (Exception var30) { Console.WriteLine(var30.ToString()); Console.Write(var30.StackTrace); return(var3); } var38.SetLocationAndAngles(var23, var24, var25, (float)par0World.Rand.NextDouble() * 360.0F, 0.0F); if (var38.GetCanSpawnHere()) { ++var15; par0World.SpawnEntityInWorld(var38); CreatureSpecificInit(var38, par0World, var23, var24, var25); if (var15 >= var38.GetMaxSpawnedInChunk()) { goto label108; } } var3 += var15; } } } ++var22; continue; } } ++var16; break; } } } } } } } return(var3); } }
/// <summary> /// Returns a list of creatures of the specified type that can spawn at the given location. /// </summary> public virtual List <SpawnListEntry> GetPossibleCreatures(CreatureType par1EnumCreatureType, int par2, int par3, int i) { return(null); }