예제 #1
0
        /// <summary>
        /// Generates and saves a single minecraft chunk using current settings.
        /// </summary>
        /// <param name="xi">X coordinate of the chunk.</param>
        /// <param name="zi">Y coordinate of the chunk.</param>
        public void generateSingleChunk(int xi, int zi)
        {
            // This line will create a default empty chunk, and create a
            // backing region file if necessary (which will immediately be
            // written to disk)
            ChunkRef chunk = currentWorld.GetChunkManager().CreateChunk(xi, zi);

            // This will make sure all the necessary things like trees and
            // ores are generated for us.
            chunk.IsTerrainPopulated = false;

            // Auto light recalculation is horrifically bad for creating
            // chunks from scratch, because we're placing thousands
            // of blocks.  Turn it off.
            chunk.Blocks.AutoLight = false;

            // This scales the dimensions based off the blocksPerEmbarkTile [1..8]
            bounds bound = new bounds(xi, zi);

            // Make the terrain
            HeightMapChunk(chunk, bound);

            // Reset and rebuild the lighting for the entire chunk at once
            chunk.Blocks.RebuildHeightMap();
            chunk.Blocks.RebuildBlockLight();
            chunk.Blocks.RebuildSkyLight();

            // Save the chunk to disk so it doesn't hang around in RAM
            currentWorld.GetChunkManager().Save();
        }
예제 #2
0
        void ParseSignInfo(TileEntitySign SignEntity, int X, int Y, int Z, ChunkRef Chunk)
        {
            // *** Try to create a sign from the entity.  NULL will be returned if the sign doesn't map to anything.
            SignBase Sign = CreateSign(SignEntity.Text1);

            if (Sign == null)
            {
                return;
            }

            // *** Pre-set the Location var...
            Sign.Location = new Point(SignEntity.X, SignEntity.Z);

            // *** ...and pass control to the sign's validation/setup function.
            if (!Sign.CreateFrom(SignEntity))
            {
                return;
            }

            // *** Now scan for and process any "rider" signs that might add additional information.
            TileEntity Ent;

            // *** This is kind of ugly but oh well
            do
            {
                Ent = Chunk.Blocks.SafeGetTileEntity(X, --Y, Z);
            } while (Y > 0 && Ent is TileEntitySign && Sign.AddSign((TileEntitySign)Ent));

            if (Sign.IsValid())
            {
                _ExportableSigns.Add(Sign);
            }
        }
예제 #3
0
        /// <summary>
        /// Generates and saves a single minecraft chunk using current settings.
        /// </summary>
        /// <param name="xi">X coordinate of the chunk.</param>
        /// <param name="zi">Y coordinate of the chunk.</param>
        public void generateSingleChunk(int xi, int zi)
        {
            // This line will create a default empty chunk, and create a
            // backing region file if necessary (which will immediately be
            // written to disk)
            ChunkRef chunk = currentWorld.GetChunkManager().CreateChunk(xi, zi);

            // This will make sure all the necessary things like trees and
            // ores are generated for us.
            chunk.IsTerrainPopulated = false;

            // Auto light recalculation is horrifically bad for creating
            // chunks from scratch, because we're placing thousands
            // of blocks.  Turn it off.
            chunk.Blocks.AutoLight = false;

            double xMin = ((xi * 16.0 / (double)Settings.Default.blocksPerEmbarkTile) + Settings.Default.mapCenterX);
            double xMax = (((xi + 1) * 16.0 / (double)Settings.Default.blocksPerEmbarkTile) + Settings.Default.mapCenterX);
            double yMin = ((zi * 16.0 / (double)Settings.Default.blocksPerEmbarkTile) + Settings.Default.mapCenterY);
            double yMax = (((zi + 1) * 16.0 / (double)Settings.Default.blocksPerEmbarkTile) + Settings.Default.mapCenterY);


            // Make the terrain
            HeightMapChunk(chunk, xMin, xMax, yMin, yMax);

            // Reset and rebuild the lighting for the entire chunk at once
            chunk.Blocks.RebuildHeightMap();
            chunk.Blocks.RebuildBlockLight();
            chunk.Blocks.RebuildSkyLight();

            // Save the chunk to disk so it doesn't hang around in RAM
            currentWorld.GetChunkManager().Save();
        }
 public bool CoarseContains(ChunkRef chunk)
 {
     return(chunk.X * 16 + 16 >= MinX &&
            chunk.X * 16 <= MaxX &&
            chunk.Z * 16 + 16 >= MinZ &&
            chunk.Z * 16 <= MaxZ);
 }
예제 #5
0
 private static void FlatChunk(ChunkRef chunk)
 {
     for (int x = 0; x < 16; x++)
     {
         for (int z = 0; z < 16; z++)
         {
             for (int y = 0; y < 2; y++)
             {
                 chunk.Blocks.SetID(x, y, z, BlockType.BEDROCK);
             }
             for (int y = 2; y < 59; y++)
             {
                 chunk.Blocks.SetID(x, y, z, BlockType.STONE);
             }
             for (int y = 59; y < 63; y++)
             {
                 chunk.Blocks.SetID(x, y, z, BlockType.DIRT);
             }
             for (int y = 63; y < 64; y++)
             {
                 chunk.Blocks.SetID(x, y, z, BlockType.GRASS);
             }
         }
     }
 }
예제 #6
0
        /// <summary>
        /// Saves all chunks within this region that have been marked as dirty.
        /// </summary>
        /// <returns>The number of chunks that were saved.</returns>
        public int Save()
        {
            _cache.SyncDirty();

            int saved = 0;
            IEnumerator <ChunkRef> en = _cache.GetDirtyEnumerator();

            while (en.MoveNext())
            {
                ChunkRef chunk = en.Current;

                if (!ChunkExists(chunk.LocalX, chunk.LocalZ))
                {
                    throw new MissingChunkException();
                }
                using (Stream chunkOutStream = GetChunkOutStream(chunk.LocalX, chunk.LocalZ))
                {
                    if (chunk.Save(chunkOutStream))
                    {
                        saved++;
                    }
                }
            }

            _cache.ClearDirty();
            return(saved);
        }
예제 #7
0
        // XXX: Consider revising foreign lookup support
        /// <inherits />
        public ChunkRef GetChunkRef(int lcx, int lcz)
        {
            if (!LocalBoundsCheck(lcx, lcz))
            {
                IRegion alt = GetForeignRegion(lcx, lcz);
                return((alt == null) ? null : alt.GetChunkRef(ForeignX(lcx), ForeignZ(lcz)));
            }

            int cx = lcx + _rx * XDIM;
            int cz = lcz + _rz * ZDIM;

            ChunkKey k = new ChunkKey(cx, cz);
            ChunkRef c = _cache.Fetch(k);

            if (c != null)
            {
                return(c);
            }

            c = ChunkRef.Create(this, lcx, lcz);
            if (c != null)
            {
                _cache.Insert(c);
            }

            return(c);
        }
예제 #8
0
        /// <summary>
        /// Saves an existing <see cref="IChunk"/> to the region at the given local coordinates.
        /// </summary>
        /// <param name="lcx">The local X-coordinate of a chunk relative to this region.</param>
        /// <param name="lcz">The local Z-coordinate of a chunk relative to this region.</param>
        /// <param name="chunk">A <see cref="IChunk"/> to save to the given location.</param>
        /// <returns>A <see cref="ChunkRef"/> represneting the <see cref="IChunk"/> at its new location.</returns>
        /// <remarks>If the local coordinates are out of bounds for this region, the action will be forwarded to the correct region
        /// transparently.  The <see cref="IChunk"/>'s internal global coordinates will be updated to reflect the new location.</remarks>
        public ChunkRef SetChunk(int lcx, int lcz, IChunk chunk)
        {
            if (!LocalBoundsCheck(lcx, lcz))
            {
                IRegion alt = GetForeignRegion(lcx, lcz);
                return((alt == null) ? null : alt.CreateChunk(ForeignX(lcx), ForeignZ(lcz)));
            }

            DeleteChunk(lcx, lcz);

            int cx = lcx + _rx * XDIM;
            int cz = lcz + _rz * ZDIM;

            chunk.SetLocation(cx, cz);
            using (Stream chunkOutStream = GetChunkOutStream(lcx, lcz))
            {
                chunk.Save(chunkOutStream);
            }

            ChunkRef cr = ChunkRef.Create(this, lcx, lcz);

            _cache.Insert(cr);

            return(cr);
        }
예제 #9
0
        private static int FixPotions(ChunkRef chunk, int x, int y, int z)
        {
            int        fixedPotions = 0;
            TileEntity te           = chunk.Blocks.GetTileEntity(x, y, z);

            switch (te)
            {
            case TileEntityChest chest:
                fixedPotions = FixPotions(ref chest);
                chunk.Blocks.SetTileEntity(x, y, z, chest);
                return(fixedPotions);

            case TileEntityTrap dispenser:
                fixedPotions = FixPotions(ref dispenser);
                chunk.Blocks.SetTileEntity(x, y, z, dispenser);
                return(fixedPotions);

            case TileEntityBrewingStand brewingStand:
                fixedPotions = FixPotions(ref brewingStand);
                chunk.Blocks.SetTileEntity(x, y, z, brewingStand);
                return(fixedPotions);

            default:
                Console.WriteLine("UNIDENTIFIED TILE ENTITY: {0} at {1},{2},{3}", te.GetType(), te.X, te.Y, te.Z);
                return(0);
            }
        }
예제 #10
0
        static void Main(string[] args)
        {
            string dest = "F:\\Minecraft\\test";
            int    xmin = -20;
            int    xmax = 20;
            int    zmin = -20;
            int    zmaz = 20;

            // This will instantly create any necessary directory structure
            BetaWorld        world = BetaWorld.Create(dest);
            BetaChunkManager cm    = world.GetChunkManager();

            // We can set different world parameters
            world.Level.LevelName = "Flatlands";
            world.Level.Spawn     = new SpawnPoint(20, 20, 70);

            // world.Level.SetDefaultPlayer();
            // We'll let MC create the player for us, but you could use the above
            // line to create the SSP player entry in level.dat.

            // We'll create chunks at chunk coordinates xmin,zmin to xmax,zmax
            for (int xi = xmin; xi < xmax; xi++)
            {
                for (int zi = zmin; zi < zmaz; zi++)
                {
                    // This line will create a default empty chunk, and create a
                    // backing region file if necessary (which will immediately be
                    // written to disk)
                    ChunkRef chunk = cm.CreateChunk(xi, zi);

                    // This will suppress generating caves, ores, and all those
                    // other goodies.
                    chunk.IsTerrainPopulated = true;

                    // Auto light recalculation is horrifically bad for creating
                    // chunks from scratch, because we're placing thousands
                    // of blocks.  Turn it off.
                    chunk.Blocks.AutoLight = false;

                    // Set the blocks
                    FlatChunk(chunk, 64);

                    // Reset and rebuild the lighting for the entire chunk at once
                    chunk.Blocks.RebuildBlockLight();
                    chunk.Blocks.RebuildSkyLight();

                    Console.WriteLine("Built Chunk {0},{1}", chunk.X, chunk.Z);

                    // Save the chunk to disk so it doesn't hang around in RAM
                    cm.Save();
                }
            }

            // Save all remaining data (including a default level.dat)
            // If we didn't save chunks earlier, they would be saved here
            world.Save();
        }
예제 #11
0
        private AlphaBlockRef GetBlockRefUnchecked(int x, int y, int z)
        {
            ChunkRef cache = GetChunk(x, y, z);

            if (cache == null)
            {
                return(new AlphaBlockRef());
            }

            return(cache.Blocks.GetBlockRef(x & chunkXMask, y & chunkYMask, z & chunkZMask));
        }
 public bool CoarseContains(ChunkRef chunk)
 {
     if (!BoundsExist)
     {
         return(true);
     }
     return(chunk.X * 16 + 16 >= MinX &&
            chunk.X * 16 <= MaxX &&
            chunk.Z * 16 + 16 >= MinZ &&
            chunk.Z * 16 <= MaxZ);
 }
예제 #13
0
        public bool Insert(ChunkRef chunk)
        {
            ChunkKey key = new ChunkKey(chunk.X, chunk.Z);

            ChunkRef c;
            if (!_cache.TryGetValue(key, out c)) {
                _cache[key] = chunk;
                return true;
            }

            return false;
        }
예제 #14
0
        private static bool FixChest(ChunkRef chunk, int x, int y, int z)
        {
            int id   = chunk.Blocks.GetID(x, y, z);
            int data = chunk.Blocks.GetData(x, y, z);

            // Check if chest is a valid facing. Chests use the same facing values as ladders.
            if (id == BlockType.CHEST && !Enum.IsDefined(typeof(LadderOrientation), data))
            {
                chunk.Blocks.SetData(x, y, z, (int)LadderOrientation.SOUTH);
                return(true);
            }
            return(false);
        }
예제 #15
0
        static void setBlock(ChunkRef chunk, int x, int y, int z, int color, string text)
        {
            if (color < 16)
            {
                chunk.Blocks.SetBlock(x, y, z, new AlphaBlock((int)BlockType.WOOL, color));
            }
            else if (color == 16)
            {
                chunk.Blocks.SetBlock(x, y, z, new AlphaBlock((int)BlockType.GRASS));
            }
            else if (color == 17)
            {
                chunk.Blocks.SetBlock(x, y, z, new AlphaBlock((int)BlockType.WOOD));
            }
            else if (color == 18)
            {
                chunk.Blocks.SetBlock(x, y, z, new AlphaBlock((int)BlockType.LEAVES));
            }
            else if (color == 19)
            {
                AlphaBlock     block = new AlphaBlock(63);
                TileEntitySign tile  = new TileEntitySign(block.GetTileEntity());
                tile.Text1 = text;
                block.SetTileEntity(tile);
                chunk.Blocks.SetBlock(x, y, z + 1, block);


                block      = new AlphaBlock(63, 8);
                tile       = new TileEntitySign(block.GetTileEntity());
                tile.Text1 = text;
                block.SetTileEntity(tile);
                chunk.Blocks.SetBlock(x, y, z - 1, block);


                block      = new AlphaBlock(63, 4);
                tile       = new TileEntitySign(block.GetTileEntity());
                tile.Text1 = text;
                block.SetTileEntity(tile);
                chunk.Blocks.SetBlock(x - 1, y, z, block);

                block      = new AlphaBlock(63, 12);
                tile       = new TileEntitySign(block.GetTileEntity());
                tile.Text1 = text;
                block.SetTileEntity(tile);
                chunk.Blocks.SetBlock(x + 1, y, z, block);
            }
            else if (color == 20)
            {
                chunk.Blocks.SetBlock(x, y, z, new AlphaBlock((int)BlockType.GLASS));
            }
        }
예제 #16
0
        static void FlatChunk(ChunkRef chunk, int height)
        {
            // Create bedrock
            for (int y = 0; y < 2; y++)
            {
                for (int x = 0; x < 16; x++)
                {
                    for (int z = 0; z < 16; z++)
                    {
                        chunk.Blocks.SetID(x, y, z, (int)BlockType.BEDROCK);
                    }
                }
            }

            // Create stone
            for (int y = 2; y < height - 5; y++)
            {
                for (int x = 0; x < 16; x++)
                {
                    for (int z = 0; z < 16; z++)
                    {
                        chunk.Blocks.SetID(x, y, z, (int)BlockType.STONE);
                    }
                }
            }

            // Create dirt
            for (int y = height - 5; y < height - 1; y++)
            {
                for (int x = 0; x < 16; x++)
                {
                    for (int z = 0; z < 16; z++)
                    {
                        chunk.Blocks.SetID(x, y, z, (int)BlockType.DIRT);
                    }
                }
            }

            // Create grass
            for (int y = height - 1; y < height; y++)
            {
                for (int x = 0; x < 16; x++)
                {
                    for (int z = 0; z < 16; z++)
                    {
                        chunk.Blocks.SetID(x, y, z, (int)BlockType.GRASS);
                    }
                }
            }
        }
        public bool Insert(ChunkRef chunk)
        {
            ChunkKey key = new ChunkKey(chunk.X, chunk.Z);

            ChunkRef c;

            if (!_cache.TryGetValue(key, out c))
            {
                _cache[key] = chunk;
                return(true);
            }

            return(false);
        }
예제 #18
0
 public static void MakeChunks(ChunkManager cm, int intStart, int intEnd, frmMace frmLogForm)
 {
     for (int xi = intStart; xi < intEnd; xi++)
     {
         for (int zi = intStart; zi < intEnd; zi++)
         {
             ChunkRef chunkOriginal = cm.CreateChunk(xi, zi);
             chunkOriginal.IsTerrainPopulated = true;
             chunkOriginal.Blocks.AutoLight   = false;
             FlatChunk(chunkOriginal);
             cm.Save();
         }
         frmLogForm.UpdateProgress((1 + xi) * 34 / (intEnd - intStart));
     }
 }
예제 #19
0
 public static void MakeChunks(ChunkManager cm, int intStart, int intEnd)
 {
     Console.WriteLine("Making chunks");
     for (int xi = intStart; xi < intEnd; xi++)
     {
         for (int zi = intStart; zi < intEnd; zi++)
         {
             ChunkRef chunkOriginal = cm.CreateChunk(xi, zi);
             chunkOriginal.IsTerrainPopulated = true;
             chunkOriginal.Blocks.AutoLight   = false;
             FlatChunk(chunkOriginal);
             chunkOriginal.Blocks.RebuildBlockLight();
             chunkOriginal.Blocks.RebuildSkyLight();
             cm.Save();
         }
     }
 }
예제 #20
0
 public static void MakeChunks(ChunkManager cm, int intEnd, frmMace frmLogForm)
 {
     int[, ,] intUndergroundTerrain = MakeUndergroundTerrain(intEnd * 16, 64, intEnd * 16);
     for (int xi = 0; xi < intEnd; xi++)
     {
         for (int zi = 0; zi < intEnd; zi++)
         {
             ChunkRef chunkActive = cm.CreateChunk(xi, zi);
             chunkActive.IsTerrainPopulated = true;
             chunkActive.Blocks.AutoLight   = false;
             FlatChunk(chunkActive, intUndergroundTerrain);
             cm.Save();
         }
         frmLogForm.UpdateProgress((1 + xi) * 24 / intEnd);
     }
     cm.Save();
 }
예제 #21
0
 public static void CreateInitialChunks(RegionChunkManager cm, frmMace frmLogForm, string strUndergroundOres)
 {
     int[, ,] intUndergroundTerrain = MakeUndergroundTerrain(64, frmLogForm, strUndergroundOres);
     for (int xi = 0; xi < City.mapLength / 16; xi++)
     {
         for (int zi = -City.farmLength / 16; zi < City.mapLength / 16; zi++)
         {
             ChunkRef chunkActive = cm.CreateChunk(xi, zi);
             chunkActive.IsTerrainPopulated = true;
             chunkActive.Blocks.AutoLight   = false;
             CreateFlatChunk(chunkActive, intUndergroundTerrain);
             cm.Save();
         }
         frmLogForm.UpdateProgress(((1 + xi) * 24 / (City.mapLength / 16)) / 100);
     }
     cm.Save();
 }
예제 #22
0
 public static void MoveChunks(BetaWorld world, BetaChunkManager cm, int CityX, int CityZ)
 {
     cm.Save();
     world.Save();
     for (int x = 0; x < City.MapLength / 16; x++)
     {
         for (int z = 0; z < City.MapLength / 16; z++)
         {
             cm.CopyChunk(x, z, CityX + x + 30, CityZ + z + 30);
             ChunkRef chunkActive = cm.GetChunkRef(CityX + x + 30, CityZ + z + 30);
             chunkActive.IsTerrainPopulated = true;
             cm.DeleteChunk(x, z);
             cm.Save();
             world.Save();
         }
     }
     world.Save();
 }
예제 #23
0
 public static void MoveChunks(BetaWorld world, BetaChunkManager cm, int CityX, int CityZ)
 {
     cm.Save();
     world.Save();
     for (int x = 0; x < City.MapLength / 16; x++)
     {
         for (int z = -City.FarmLength / 16; z < City.MapLength / 16; z++)
         {
             cm.CopyChunk(x, z, CityX + x + CITY_RELOCATION_CHUNKS, CityZ + z + CITY_RELOCATION_CHUNKS);
             ChunkRef chunkActive = cm.GetChunkRef(CityX + x + CITY_RELOCATION_CHUNKS, CityZ + z + CITY_RELOCATION_CHUNKS);
             chunkActive.IsTerrainPopulated = true;
             chunkActive.Blocks.AutoLight   = true;
             cm.DeleteChunk(x, z);
             cm.Save();
             world.Save();
         }
     }
 }
예제 #24
0
 public static void MoveChunks(AnvilWorld world, RegionChunkManager cm, int CityX, int CityZ)
 {
     cm.Save();
     world.Save();
     for (int x = 0; x < City.mapLength / 16; x++)
     {
         for (int z = -City.farmLength / 16; z < City.mapLength / 16; z++)
         {
             cm.CopyChunk(x, z, CityX + x + CITY_RELOCATION_CHUNKS, CityZ + z + CITY_RELOCATION_CHUNKS);
             ChunkRef chunkActive = cm.GetChunkRef(CityX + x + CITY_RELOCATION_CHUNKS, CityZ + z + CITY_RELOCATION_CHUNKS);
             chunkActive.IsTerrainPopulated = true;
             chunkActive.Blocks.AutoLight   = true;
             biomes.Add(chunkActive.X + "." + chunkActive.Z, City.biome);
             cm.DeleteChunk(x, z);
             cm.Save();
             world.Save();
         }
     }
 }
예제 #25
0
        void ProcessChunk(ChunkRef Chunk)
        {
            AlphaBlockCollection Blocks = Chunk.Blocks;

            for (int ChunkX = 0; ChunkX < 16; ChunkX++)
            {
                for (int ChunkZ = 0; ChunkZ < 16; ChunkZ++)
                {
                    for (int ChunkY = 0; ChunkY < 128; ChunkY++)
                    {
                        TileEntity     Entity = Blocks.SafeGetTileEntity(ChunkX, ChunkY, ChunkZ);
                        TileEntitySign Sign   = Entity as TileEntitySign;
                        if (Sign != null)
                        {
                            ParseSignInfo(Sign, ChunkX, ChunkY, ChunkZ, Chunk);
                        }
                    }
                }
            }
        }
예제 #26
0
 private static bool FixSpawner(ChunkRef chunk, int x, int y, int z)
 {
     if (chunk.Blocks.GetTileEntity(x, y, z) is TileEntityMobSpawner spawner && spawner.SpawnData != null)
     {
         if (FixSpawnData(spawner.SpawnData))
         {
             if (spawner.Source.ContainsKey("SpawnPotentials"))
             {
                 spawner.Source.Remove("SpawnPotentials");
             }
             if (spawner.Source.ContainsKey("EntityId"))
             {
                 spawner.Source.Remove("EntityId");
             }
             spawner.EntityID = null;
             chunk.Blocks.SetTileEntity(x, y, z, spawner);
             return(true);
         }
     }
     return(false);
 }
예제 #27
0
 private static void FlatChunk(ChunkRef chunk, int[, ,] intUndergroundTerrain)
 {
     for (int x = 0; x < 16; x++)
     {
         for (int z = 0; z < 16; z++)
         {
             for (int y = 0; y < 2; y++)
             {
                 chunk.Blocks.SetID(x, y, z, BlockType.BEDROCK);
             }
             for (int y = 2; y < 63; y++)
             {
                 chunk.Blocks.SetID(x, y, z, intUndergroundTerrain[(chunk.X * 16) + x, y, (chunk.Z * 16) + z]);
             }
             for (int y = 63; y < 64; y++)
             {
                 chunk.Blocks.SetID(x, y, z, BlockType.GRASS);
             }
         }
     }
 }
예제 #28
0
        public static void MakeEntity(int x, int y, int z, TypedEntity entity, int intMirror)
        {
            entity.Position.X = x;
            entity.Position.Y = y;
            entity.Position.Z = z;

            ChunkRef chunkBuilding = _cmDest.GetChunkRef(x / 16, z / 16);

            chunkBuilding.Entities.Add(entity);
            _cmDest.Save();

            if (intMirror >= 1)
            {
                MakeEntity(City.mapLength - x, y, z, entity, 0);
                MakeEntity(x, y, City.mapLength - z, entity, 0);
                MakeEntity(City.mapLength - x, y, City.mapLength - z, entity, 0);
                if (intMirror == 2)
                {
                    MakeEntity(z, y, x, entity, 1);
                }
            }
        }
예제 #29
0
 private static void CreateFlatChunk(ChunkRef chunk, int[, ,] intUndergroundTerrain)
 {
     for (int x = 0; x < 16; x++)
     {
         for (int z = 0; z < 16; z++)
         {
             for (int y = 0; y < 2; y++)
             {
                 chunk.Blocks.SetID(x, y, z, BlockInfo.Bedrock.ID);
             }
             for (int y = 2; y < 63; y++)
             {
                 chunk.Blocks.SetID(x, y, z, intUndergroundTerrain[(chunk.X * 16) + x, y, City.farmLength + (chunk.Z * 16) + z]);
             }
             for (int y = 63; y < 64; y++)
             {
                 chunk.Blocks.SetID(x, y, z, City.groundBlockID);
                 chunk.Blocks.SetData(x, y, z, City.groundBlockData);
             }
         }
     }
 }
예제 #30
0
        public void ApplyChunk(NbtWorld world, ChunkRef chunk)
        {
            if (opt.OPT_V)
            {
                Console.WriteLine("Generating {0} size {1} deposits of {2} between {3} and {4}",
                                  opt.OPT_ROUNDS, opt.OPT_SIZE, opt.OPT_ID, opt.OPT_MIN, opt.OPT_MAX);
            }

            IGenerator generator;

            if (opt.OPT_DATA == null)
            {
                generator = new NativeGenOre((int)opt.OPT_ID, (int)opt.OPT_SIZE);
                ((NativeGenOre)generator).MathFix = opt.OPT_MATHFIX;
            }
            else
            {
                generator = new NativeGenOre((int)opt.OPT_ID, (int)opt.OPT_DATA, (int)opt.OPT_SIZE);
                ((NativeGenOre)generator).MathFix = opt.OPT_MATHFIX;
            }

            IChunkManager cm = world.GetChunkManager(opt.OPT_DIM);
            IBlockManager bm = new GenOreBlockManager(cm, opt);

            for (int i = 0; i < opt.OPT_ROUNDS; i++)
            {
                if (opt.OPT_VV)
                {
                    Console.WriteLine("Generating round {0}...", i);
                }

                int x = chunk.X * chunk.Blocks.XDim + rand.Next(chunk.Blocks.XDim);
                int y = (int)opt.OPT_MIN + rand.Next((int)opt.OPT_MAX - (int)opt.OPT_MIN);
                int z = chunk.Z * chunk.Blocks.ZDim + rand.Next(chunk.Blocks.ZDim);

                generator.Generate(bm, rand, x, y, z);
            }
        }
예제 #31
0
        /// <inherits />
        public ChunkRef CreateChunk(int lcx, int lcz)
        {
            if (!LocalBoundsCheck(lcx, lcz))
            {
                IRegion alt = GetForeignRegion(lcx, lcz);
                return((alt == null) ? null : alt.CreateChunk(ForeignX(lcx), ForeignZ(lcz)));
            }

            DeleteChunk(lcx, lcz);

            int cx = lcx + _rx * XDIM;
            int cz = lcz + _rz * ZDIM;

            IChunk c = CreateChunkCore(cx, cz);

            c.Save(GetChunkOutStream(lcx, lcz));

            ChunkRef cr = ChunkRef.Create(this, lcx, lcz);

            _cache.Insert(cr);

            return(cr);
        }