/// <summary>
        /// loads or generates the chunk at the chunk location specified
        /// </summary>
        public virtual Chunk LoadChunk(int par1, int par2)
        {
            Chunk chunk = new Chunk(WorldObj, par1, par2);

            ChunkMapping.Add(ChunkCoordIntPair.ChunkXZ2Int(par1, par2), chunk);
            chunk.IsChunkLoaded = true;
            return(chunk);
        }
Пример #2
0
        protected override bool CanSpawnStructureAtCoords(int par1, int par2)
        {
            if (!RanBiomeCheck)
            {
                Random random = new Random();
                random.SetSeed((int)WorldObj.GetSeed());
                double d = random.NextDouble() * Math.PI * 2D;

                for (int k = 0; k < StructureCoords.Length; k++)
                {
                    double d1 = (1.25D + random.NextDouble()) * 32D;
                    int    l  = (int)Math.Round(Math.Cos(d) * d1);
                    int    i1 = (int)Math.Round(Math.Sin(d) * d1);
                    List <BiomeGenBase> arraylist     = new List <BiomeGenBase>();
                    BiomeGenBase[]      abiomegenbase = AllowedBiomeGenBases;
                    int j1 = abiomegenbase.Length;

                    for (int k1 = 0; k1 < j1; k1++)
                    {
                        BiomeGenBase biomegenbase = abiomegenbase[k1];
                        arraylist.Add(biomegenbase);
                    }

                    ChunkPosition chunkposition = WorldObj.GetWorldChunkManager().FindBiomePosition((l << 4) + 8, (i1 << 4) + 8, 112, arraylist, random);

                    if (chunkposition != null)
                    {
                        l  = chunkposition.x >> 4;
                        i1 = chunkposition.z >> 4;
                    }
                    else
                    {
                        Console.WriteLine((new StringBuilder()).Append("Placed stronghold in INVALID biome at (").Append(l).Append(", ").Append(i1).Append(")").ToString());
                    }

                    StructureCoords[k] = new ChunkCoordIntPair(l, i1);
                    d += (Math.PI * 2D) / (double)StructureCoords.Length;
                }

                RanBiomeCheck = true;
            }

            ChunkCoordIntPair[] achunkcoordintpair = StructureCoords;
            int i = achunkcoordintpair.Length;

            for (int j = 0; j < i; j++)
            {
                ChunkCoordIntPair chunkcoordintpair = achunkcoordintpair[j];

                if (par1 == chunkcoordintpair.ChunkXPos && par2 == chunkcoordintpair.ChunkZPos)
                {
                    Console.WriteLine((new StringBuilder()).Append(par1).Append(", ").Append(par2).ToString());
                    return(true);
                }
            }

            return(false);
        }
Пример #3
0
        /// <summary>
        /// Drops the specified chunk.
        /// </summary>
        public virtual void DropChunk(int par1, int par2)
        {
            ChunkCoordinates chunkcoordinates = worldObj.GetSpawnPoint();
            int i = (par1 * 16 + 8) - chunkcoordinates.PosX;
            int j = (par2 * 16 + 8) - chunkcoordinates.PosZ;
            int c = 200;

            if (i < -c || i > c || j < -c || j > c)
            {
                droppedChunksSet.Add(ChunkCoordIntPair.ChunkXZ2Int(par1, par2));
            }
        }
        public virtual void Func_539_c(int par1, int par2)
        {
            Chunk chunk = ProvideChunk(par1, par2);

            if (!chunk.IsEmpty())
            {
                chunk.OnChunkUnload();
            }

            ChunkMapping.Remove(ChunkCoordIntPair.ChunkXZ2Int(par1, par2));
            Field_889_c.Remove(chunk);
        }
Пример #5
0
        ///<summary>
        /// Will return back a chunk, if it doesn't exist and its not a MP client it will generates all the blocks for the
        /// specified chunk from the map seed and chunk seed
        ///</summary>
        public Chunk ProvideChunk(int par1, int par2)
        {
            Chunk chunk = (Chunk)chunkMap.GetValueByKey(ChunkCoordIntPair.ChunkXZ2Int(par1, par2));

            if (chunk == null)
            {
                return(LoadChunk(par1, par2));
            }
            else
            {
                return(chunk);
            }
        }
        /// <summary>
        /// Will return back a chunk, if it doesn't exist and its not a MP client it will generates all the blocks for the
        /// specified chunk from the map seed and chunk seed
        /// </summary>
        public virtual Chunk ProvideChunk(int par1, int par2)
        {
            Chunk chunk = (Chunk)ChunkMapping.GetValueByKey(ChunkCoordIntPair.ChunkXZ2Int(par1, par2));

            if (chunk == null)
            {
                return(BlankChunk);
            }
            else
            {
                return(chunk);
            }
        }
        /// <summary>
        /// plays random cave ambient sounds and runs updateTick on random blocks within each chunk in the vacinity of a
        /// player
        /// </summary>
        protected override void TickBlocksAndAmbiance()
        {
            Func_48461_r();

            for (IEnumerator <ChunkCoordIntPair> iterator = ActiveChunkSet.GetEnumerator(); iterator.MoveNext(); Profiler.EndSection())
            {
                ChunkCoordIntPair chunkcoordintpair = iterator.Current;
                int i = chunkcoordintpair.ChunkXPos * 16;
                int j = chunkcoordintpair.ChunkZPos * 16;
                Profiler.StartSection("getChunk");
                Chunk chunk = GetChunkFromChunkCoords(chunkcoordintpair.ChunkXPos, chunkcoordintpair.ChunkZPos);
                Func_48458_a(i, j, chunk);
            }
        }
        /// <summary>
        /// Recursively called by generate() (generate) and optionally by itself.
        /// </summary>
        protected override void RecursiveGenerate(World par1World, int par2, int par3, int par4, int par5, byte[] par6ArrayOfByte)
        {
            if (CoordMap.ContainsKey(ChunkCoordIntPair.ChunkXZ2Int(par2, par3)))
            {
                return;
            }

            Rand.Next();

            if (CanSpawnStructureAtCoords(par2, par3))
            {
                StructureStart structurestart = GetStructureStart(par2, par3);
                CoordMap[ChunkCoordIntPair.ChunkXZ2Int(par2, par3)] = structurestart;
            }
        }
Пример #9
0
        /// <summary>
        /// Loads the specified(XZ) chunk into the specified world.
        /// </summary>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public Chunk loadChunk(World par1World, int par2, int par3) throws IOException
        public virtual Chunk LoadChunk(World par1World, int par2, int par3)
        {
            NBTTagCompound    nbttagcompound    = null;
            ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(par2, par3);

            lock (Field_48450_c)
            {
                if (Field_48449_b.Contains(chunkcoordintpair))
                {
                    int i = 0;

                    do
                    {
                        if (i >= Field_48451_a.Count)
                        {
                            break;
                        }

                        if (Field_48451_a[i].Field_48427_a.Equals(chunkcoordintpair))
                        {
                            nbttagcompound = Field_48451_a[i].Field_48426_b;
                            break;
                        }

                        i++;
                    }while (true);
                }
            }

            if (nbttagcompound == null)
            {
                Stream datainputstream = RegionFileCache.GetChunkFileStream(ChunkSaveLocation, par2, par3);

                if (datainputstream != null)
                {
                    nbttagcompound = CompressedStreamTools.Read(new BinaryReader(datainputstream));
                }
                else
                {
                    return(null);
                }
            }

            return(Func_48443_a(par1World, par2, par3, nbttagcompound));
        }
Пример #10
0
        ///<summary>
        /// loads or generates the chunk at the chunk location specified
        ///</summary>
        public Chunk LoadChunk(int par1, int par2)
        {
            long l = ChunkCoordIntPair.ChunkXZ2Int(par1, par2);

            droppedChunksSet.Remove(l);
            Chunk chunk = (Chunk)chunkMap.GetValueByKey(l);

            if (chunk == null)
            {
                int i = 0x1c9c3c;

                if (par1 < -i || par2 < -i || par1 >= i || par2 >= i)
                {
                    return(emptyChunk);
                }

                chunk = LoadChunkFromFile(par1, par2);

                if (chunk == null)
                {
                    if (chunkProvider == null)
                    {
                        chunk = emptyChunk;
                    }
                    else
                    {
                        chunk = chunkProvider.ProvideChunk(par1, par2);
                    }
                }

                chunkMap.Add(l, chunk);
                chunkList.Add(chunk);

                if (chunk != null)
                {
                    chunk.Func_4143_d();
                    chunk.OnChunkLoad();
                }

                chunk.PopulateChunk(this, this, par1, par2);
            }

            return(chunk);
        }
Пример #11
0
        protected override List <ChunkPosition> Func_40482_a()
        {
            List <ChunkPosition> arraylist = new List <ChunkPosition>();

            ChunkCoordIntPair[] achunkcoordintpair = StructureCoords;
            int i = achunkcoordintpair.Length;

            for (int j = 0; j < i; j++)
            {
                ChunkCoordIntPair chunkcoordintpair = achunkcoordintpair[j];

                if (chunkcoordintpair != null)
                {
                    arraylist.Add(chunkcoordintpair.GetChunkPosition(64));
                }
            }

            return(arraylist);
        }
Пример #12
0
        protected virtual void Func_48446_a(ChunkCoordIntPair par1ChunkCoordIntPair, NBTTagCompound par2NBTTagCompound)
        {
            lock (Field_48450_c)
            {
                if (Field_48449_b.Contains(par1ChunkCoordIntPair))
                {
                    for (int i = 0; i < Field_48451_a.Count; i++)
                    {
                        if (Field_48451_a[i].Field_48427_a.Equals(par1ChunkCoordIntPair))
                        {
                            Field_48451_a[i] = new AnvilChunkLoaderPending(par1ChunkCoordIntPair, par2NBTTagCompound);
                            return;
                        }
                    }
                }

                Field_48451_a.Add(new AnvilChunkLoaderPending(par1ChunkCoordIntPair, par2NBTTagCompound));
                Field_48449_b.Add(par1ChunkCoordIntPair);
                ThreadedFileIOBase.ThreadedIOInstance.QueueIO(this);
                return;
            }
        }
Пример #13
0
        public virtual bool Equals(object par1Obj)
        {
            ChunkCoordIntPair chunkcoordintpair = (ChunkCoordIntPair)par1Obj;

            return(chunkcoordintpair.ChunkXPos == ChunkXPos && chunkcoordintpair.ChunkZPos == ChunkZPos);
        }
Пример #14
0
 /// <summary>
 /// Checks to see if a chunk exists at x, y
 /// </summary>
 public virtual bool ChunkExists(int par1, int par2)
 {
     return(chunkMap.ContainsItem(ChunkCoordIntPair.ChunkXZ2Int(par1, par2)));
 }
Пример #15
0
        /// <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);
            }
        }