コード例 #1
0
        public static void ResetLighting(BetaWorld world, ChunkManager cm, frmMace frmLogForm, int intTotalChunks)
        {
            int intChunksProcessed = 0;

            //this code is based on a substrate example
            //http://code.google.com/p/substrate-minecraft/source/browse/trunk/Substrate/SubstrateCS/Examples/Relight/Program.cs
            //see the <License Substrate.txt> file for copyright information
            foreach (ChunkRef chunk in cm)
            {
                try
                {
                    chunk.Blocks.RebuildHeightMap();
                    chunk.Blocks.ResetBlockLight();
                    chunk.Blocks.ResetSkyLight();
                    chunk.Blocks.RebuildBlockLight();
                    chunk.Blocks.RebuildSkyLight();
                    cm.Save();
                    intChunksProcessed++;
                    if (intChunksProcessed % 10 == 0)
                    {
                        frmLogForm.UpdateProgress(62 + ((intChunksProcessed * (100 - 62)) / intTotalChunks));
                        world.Save();
                    }
                }
                catch (Exception)
                {
                    Debug.WriteLine("Chunk light fail");
                }
            }
            cm.Save();
            world.Save();
        }
コード例 #2
0
        public static void PositionRails(BetaWorld worldDest, BlockManager bm)
        {
            // todo low: different elevations
            int intReplaced = 0;

            for (int x = 0; x < City.MapLength; x++)
            {
                for (int z = -City.FarmLength; z < City.MapLength; z++)
                {
                    for (int y = 0; y < 128; y++)
                    {
                        switch (bm.GetID(x, y, z))
                        {
                        case BlockType.POWERED_RAIL:
                        case BlockType.DETECTOR_RAIL:
                        case BlockType.RAILS:
                            BlockHelper.MakeRail(x, y, z);
                            if (++intReplaced > 100)
                            {
                                worldDest.Save();
                                intReplaced = 0;
                            }
                            break;
                        }
                    }
                }
            }
        }
コード例 #3
0
ファイル: Paths.cs プロジェクト: RavetcoFX/mace-minecraft
 private static void MakePaths(BetaWorld world, BlockManager bm, int[,] intArea)
 {
     for (int x = 0; x < intArea.GetLength(0); x++)
     {
         for (int z = 0; z < intArea.GetLength(1); z++)
         {
             if (intArea[x, z] == 1)
             {
                 if (Math.Abs(x - (intArea.GetLength(0) / 2)) == 2 &&
                     Math.Abs(z - (intArea.GetLength(1) / 2)) == 2)
                 {
                     // don't need these
                 }
                 else if (Math.Abs(x - (intArea.GetLength(0) / 2)) == 2 ||
                          Math.Abs(z - (intArea.GetLength(1) / 2)) == 2)
                 {
                     if (MultipleNeighbouringPaths(intArea, x, z))
                     {
                         bm.SetID(_intBlockStart + x, 63, _intBlockStart + z, City.PathBlockID);
                         bm.SetData(_intBlockStart + x, 63, _intBlockStart + z, City.PathBlockData);
                     }
                 }
                 else
                 {
                     bm.SetID(_intBlockStart + x, 63, _intBlockStart + z, City.PathBlockID);
                     bm.SetData(_intBlockStart + x, 63, _intBlockStart + z, City.PathBlockData);
                 }
             }
         }
         if (x % 20 == 0)
         {
             world.Save();
         }
     }
 }
コード例 #4
0
ファイル: Paths.cs プロジェクト: RavetcoFX/mace-minecraft
 private static void MakePaths(BetaWorld world, BlockManager bm, int[,] intArea, int intMapSize)
 {
     for (int x = 0; x < intArea.GetLength(0); x++)
     {
         for (int z = 0; z < intArea.GetLength(1); z++)
         {
             if (intArea[x, z] == 1)
             {
                 if (Math.Abs(x - (intArea.GetLength(0) / 2)) == 2 &&
                     Math.Abs(z - (intArea.GetLength(1) / 2)) == 2)
                 {
                     // don't need these
                 }
                 else if (Math.Abs(x - (intArea.GetLength(0) / 2)) == 2 ||
                          Math.Abs(z - (intArea.GetLength(1) / 2)) == 2)
                 {
                     if (MultipleNeighbouringPaths(intArea, x, z))
                     {
                         bm.SetID(intBlockStart + x, 63, intBlockStart + z, (int)BlockType.DOUBLE_SLAB);
                     }
                 }
                 else
                 {
                     bm.SetID(intBlockStart + x, 63, intBlockStart + z, (int)BlockType.DOUBLE_SLAB);
                 }
             }
         }
         if (x % 20 == 0)
         {
             world.Save();
         }
     }
 }
コード例 #5
0
ファイル: Utils.cs プロジェクト: RavetcoFX/mace-minecraft
        public static void CropMaceWorld(frmMace frmLogForm)
        {
            // thank you to Surrogard <*****@*****.**> for providing a linux friendly version of this code:
            Directory.CreateDirectory("macecopy".ToMinecraftSaveDirectory());
            BetaWorld        bwCopy = BetaWorld.Create("macecopy".ToMinecraftSaveDirectory());
            BetaChunkManager cmCopy = bwCopy.GetChunkManager();
            BetaWorld        bwCrop = BetaWorld.Open("macemaster".ToMinecraftSaveDirectory());
            BetaChunkManager cmCrop = bwCrop.GetChunkManager();

            foreach (ChunkRef chunk in cmCrop)
            {
                if (chunk.X >= -7 && chunk.X <= 11 && chunk.Z >= 0 && chunk.Z <= 11)
                {
                    Debug.WriteLine("Copying chunk " + chunk.X + "," + chunk.Z);
                    cmCopy.SetChunk(chunk.X, chunk.Z, chunk.GetChunkRef());
                }
                cmCopy.Save();
            }
            bwCopy.Level.GameType = GameType.CREATIVE;
            cmCopy.Save();
            bwCopy.Save();
            if (Environment.OSVersion.Platform == PlatformID.Win32NT)
            {
                Process.Start("explorer.exe", @"/select," + "macecopy".ToMinecraftSaveDirectory() + "\\level.dat");
            }
        }
コード例 #6
0
        static void Main(string[] args)
        {
            if (args.Length != 4)
            {
                Console.WriteLine("Usage: MoveSpawn <world> <x> <y> <z>");
                return;
            }

            string dest = args[0];
            int    x    = Convert.ToInt32(args[1]);
            int    y    = Convert.ToInt32(args[2]);
            int    z    = Convert.ToInt32(args[3]);

            // Open our world
            BetaWorld world = BetaWorld.Open(dest);

            // Set the level's spawn
            // Note: Players do not have separate spawns by default
            // If you wanted to change a player's spawn, you must set all
            // 3 coordinates for it to stick.  It will not take the level's defaults.
            world.Level.Spawn = new SpawnPoint(x, y, z);

            // Save the changes
            world.Save();
        }
コード例 #7
0
ファイル: Chunks.cs プロジェクト: RavetcoFX/mace-minecraft
        public static void ResetLighting(BetaWorld world, BetaChunkManager cm, frmMace frmLogForm)
        {
            int intChunksChecked   = 0;
            int intChunksProcessed = 0;
            // we process each chunk twice, hence this:
            int intTotalChunks = 0;

            //this code is based on a substrate example
            //http://code.google.com/p/substrate-minecraft/source/browse/trunk/Substrate/SubstrateCS/Examples/Relight/Program.cs
            //see the <License Substrate.txt> file for copyright information
            foreach (ChunkRef chunk in cm)
            {
                intTotalChunks += 2;
            }
            foreach (ChunkRef chunk in cm)
            {
                if (chunk.IsTerrainPopulated)
                {
                    intChunksChecked++;
                    try
                    {
                        chunk.Blocks.RebuildHeightMap();
                        chunk.Blocks.ResetBlockLight();
                        chunk.Blocks.ResetSkyLight();
                    }
                    catch (Exception)
                    {
                        Debug.WriteLine("Chunk reset light fail");
                    }
                }
                if (++intChunksProcessed % 10 == 0)
                {
                    cm.Save();
                    frmLogForm.UpdateProgress(intChunksProcessed * 0.95 / intTotalChunks);
                }
            }
            foreach (ChunkRef chunk in cm)
            {
                if (chunk.IsTerrainPopulated)
                {
                    try
                    {
                        chunk.Blocks.RebuildBlockLight();
                        chunk.Blocks.RebuildSkyLight();
                    }
                    catch (Exception)
                    {
                        Debug.WriteLine("Chunk rebuild light fail");
                    }
                }
                if (++intChunksProcessed % 10 == 0)
                {
                    cm.Save();
                    frmLogForm.UpdateProgress(intChunksProcessed * 0.95 / intTotalChunks);
                }
            }
            world.Save();
        }
コード例 #8
0
ファイル: Buildings.cs プロジェクト: RavetcoFX/mace-minecraft
        private static structPoint MakeBuildings(BlockManager bm, int[,] intArea, int intBlockStart, BetaWorld world)
        {
            structPoint structLocationOfMineshaftEntrance = new structPoint();

            structLocationOfMineshaftEntrance.x = -1;
            structLocationOfMineshaftEntrance.z = -1;
            int intBuildings = 0;

            for (int x = 0; x < intArea.GetLength(0); x++)
            {
                for (int z = 0; z < intArea.GetLength(1); z++)
                {
                    // hack low: this 100 to 500 stuff is all a bit hackish really, need to find a proper solution
                    if (intArea[x, z] >= 100 && intArea[x, z] <= 500)
                    {
                        SourceWorld.Building CurrentBuilding = SourceWorld.GetBuilding(intArea[x, z] - 100);
                        SourceWorld.InsertBuilding(bm, intArea, intBlockStart, x, z,
                                                   CurrentBuilding, 0);

                        if (CurrentBuilding.btThis == SourceWorld.BuildingTypes.MineshaftEntrance)
                        {
                            structLocationOfMineshaftEntrance.x = intBlockStart + x + (int)(CurrentBuilding.intSizeX / 2);
                            structLocationOfMineshaftEntrance.z = intBlockStart + z + (int)(CurrentBuilding.intSizeZ / 2);
                            if (City.HasSkyFeature)
                            {
                                SourceWorld.Building BalloonBuilding = SourceWorld.GetBuilding("Sky Feature");
                                SourceWorld.InsertBuilding(bm, new int[0, 0], intBlockStart,
                                                           x + ((CurrentBuilding.intSizeX - BalloonBuilding.intSizeX) / 2),
                                                           z + ((CurrentBuilding.intSizeZ - BalloonBuilding.intSizeZ) / 2),
                                                           BalloonBuilding, 0);
                            }
                        }

                        intArea[x + CurrentBuilding.intSizeX - 2, z + CurrentBuilding.intSizeZ - 2] = 0;
                        if (++intBuildings == NumberOfBuildingsBetweenSaves)
                        {
                            world.Save();
                            intBuildings = 0;
                        }
                    }
                }
            }
            world.Save();
            return(structLocationOfMineshaftEntrance);
        }
コード例 #9
0
ファイル: Chunks.cs プロジェクト: RavetcoFX/mace-minecraft
 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();
 }
コード例 #10
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();
         }
     }
 }
コード例 #11
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();
        }
コード例 #12
0
ファイル: Chunks.cs プロジェクト: RavetcoFX/mace-minecraft
        public static void ReplaceValuableBlocks(BetaWorld worldDest, BlockManager bm)
        {
            int intReplaced = 0;

            for (int x = 0; x < City.MapLength; x++)
            {
                for (int z = 0; z < City.MapLength; z++)
                {
                    for (int y = 32; y < 128; y++)
                    {
                        if (bm.GetID(x, y, z) != City.WallMaterialID ||
                            bm.GetData(x, y, z) != City.WallMaterialData)
                        {
#pragma warning disable
                            switch ((int)bm.GetID(x, y, z))
                            {
                            case BlockType.GOLD_BLOCK:
                                BlockShapes.MakeBlock(x, y, z, BlockInfo.Wool.ID, (int)WoolColor.YELLOW);
                                intReplaced++;
                                break;

                            case BlockType.IRON_BLOCK:
                                BlockShapes.MakeBlock(x, y, z, BlockInfo.Wool.ID, (int)WoolColor.LIGHT_GRAY);
                                intReplaced++;
                                break;

                            case BlockType.OBSIDIAN:
                                BlockShapes.MakeBlock(x, y, z, BlockInfo.Wool.ID, (int)WoolColor.BLACK);
                                intReplaced++;
                                break;

                            case BlockType.DIAMOND_BLOCK:
                                BlockShapes.MakeBlock(x, y, z, BlockInfo.Wool.ID, (int)WoolColor.LIGHT_BLUE);
                                intReplaced++;
                                break;

                            case BlockType.LAPIS_BLOCK:
                                BlockShapes.MakeBlock(x, y, z, BlockInfo.Wool.ID, (int)WoolColor.BLUE);
                                intReplaced++;
                                break;
                                // no need for a default, because we purposefully want to skip all the other blocks
                            }
#pragma warning restore
                            if (intReplaced > 25)
                            {
                                worldDest.Save();
                                intReplaced = 0;
                            }
                        }
                    }
                }
            }
        }
コード例 #13
0
 private static void MakePaths(BetaWorld world, BlockManager bm, int[,] intArea)
 {
     for (int x = 0; x < intArea.GetLength(0); x++)
     {
         for (int z = 0; z < intArea.GetLength(1); z++)
         {
             if (intArea[x, z] == 1)
             {
                 if (Math.Abs(x - (intArea.GetLength(0) / 2)) == City.PathExtends + 1 &&
                     Math.Abs(z - (intArea.GetLength(1) / 2)) == City.PathExtends + 1)
                 {
                     // don't need these
                 }
                 else if (Math.Abs(x - (intArea.GetLength(0) / 2)) == (City.PathExtends + 1) ||
                          Math.Abs(z - (intArea.GetLength(1) / 2)) == (City.PathExtends + 1))
                 {
                     if (MultipleNeighbouringPaths(intArea, x, z))
                     {
                         bm.SetID(_intBlockStart + x, 63, _intBlockStart + z, City.PathBlockID);
                         bm.SetData(_intBlockStart + x, 63, _intBlockStart + z, City.PathBlockData);
                     }
                 }
                 else
                 {
                     bm.SetID(_intBlockStart + x, 63, _intBlockStart + z, City.PathBlockID);
                     bm.SetData(_intBlockStart + x, 63, _intBlockStart + z, City.PathBlockData);
                 }
                 if (City.PathAlternativeBlockID > 0)
                 {
                     if (x > 0 && z > 0 && x < intArea.GetUpperBound(0) && z < intArea.GetUpperBound(1))
                     {
                         if (Math.Abs(x - (intArea.GetLength(0) / 2)) == City.PathExtends ||
                             Math.Abs(z - (intArea.GetLength(1) / 2)) == City.PathExtends)
                         {
                             if (Math.Abs(x - (intArea.GetLength(0) / 2)) >= City.PathExtends &&
                                 Math.Abs(z - (intArea.GetLength(1) / 2)) >= City.PathExtends)
                             {
                                 bm.SetID(_intBlockStart + x, 64, _intBlockStart + z, City.PathAlternativeBlockID);
                                 bm.SetData(_intBlockStart + x, 64, _intBlockStart + z, City.PathAlternativeBlockData);
                             }
                         }
                     }
                 }
             }
         }
         if (x % 20 == 0)
         {
             world.Save();
         }
     }
 }
コード例 #14
0
        public static void ReplaceValuableBlocks(BetaWorld worldDest, BlockManager bm, int intCitySize)
        {
            int intReplaced = 0;

            for (int x = 0; x < intCitySize; x++)
            {
                for (int z = 0; z < intCitySize; z++)
                {
                    for (int y = 32; y < 128; y++)
                    {
                        switch ((int)bm.GetID(x, y, z))
                        {
                        case (int)BlockType.GOLD_BLOCK:
                            bm.SetID(x, y, z, (int)BlockType.WOOL);
                            bm.SetData(x, y, z, (int)WoolColor.YELLOW);
                            intReplaced++;
                            break;

                        case (int)BlockType.IRON_BLOCK:
                            bm.SetID(x, y, z, (int)BlockType.WOOL);
                            bm.SetData(x, y, z, (int)WoolColor.LIGHT_GRAY);
                            intReplaced++;
                            break;

                        case (int)BlockType.OBSIDIAN:
                            bm.SetID(x, y, z, (int)BlockType.WOOL);
                            bm.SetData(x, y, z, (int)WoolColor.BLACK);
                            intReplaced++;
                            break;

                        case (int)BlockType.DIAMOND_BLOCK:
                            bm.SetID(x, y, z, (int)BlockType.WOOL);
                            bm.SetData(x, y, z, (int)WoolColor.LIGHT_BLUE);
                            intReplaced++;
                            break;

                        case (int)BlockType.LAPIS_BLOCK:
                            bm.SetID(x, y, z, (int)BlockType.WOOL);
                            bm.SetData(x, y, z, (int)WoolColor.BLUE);
                            intReplaced++;
                            break;
                        }
                        if (intReplaced > 25)
                        {
                            worldDest.Save();
                            intReplaced = 0;
                        }
                    }
                }
            }
        }
コード例 #15
0
ファイル: Chunks.cs プロジェクト: RavetcoFX/mace-minecraft
        public static void ReplaceValuableBlocks(BetaWorld worldDest, BlockManager bm, int intCitySize,
                                                 int intWallMaterial)
        {
            int intReplaced = 0;

            for (int x = 0; x < intCitySize; x++)
            {
                for (int z = 0; z < intCitySize; z++)
                {
                    for (int y = 32; y < 128; y++)
                    {
                        if ((int)bm.GetID(x, y, z) != intWallMaterial)
                        {
                            switch ((int)bm.GetID(x, y, z))
                            {
                            case BlockType.GOLD_BLOCK:
                                BlockShapes.MakeBlock(x, y, z, BlockType.WOOL, (int)WoolColor.YELLOW);
                                intReplaced++;
                                break;

                            case BlockType.IRON_BLOCK:
                                BlockShapes.MakeBlock(x, y, z, BlockType.WOOL, (int)WoolColor.LIGHT_GRAY);
                                intReplaced++;
                                break;

                            case BlockType.OBSIDIAN:
                                BlockShapes.MakeBlock(x, y, z, BlockType.WOOL, (int)WoolColor.BLACK);
                                intReplaced++;
                                break;

                            case BlockType.DIAMOND_BLOCK:
                                BlockShapes.MakeBlock(x, y, z, BlockType.WOOL, (int)WoolColor.LIGHT_BLUE);
                                intReplaced++;
                                break;

                            case BlockType.LAPIS_BLOCK:
                                BlockShapes.MakeBlock(x, y, z, BlockType.WOOL, (int)WoolColor.BLUE);
                                intReplaced++;
                                break;
                                // no need for a default, because we purposefully want to skip all the other blocks
                            }
                            if (intReplaced > 25)
                            {
                                worldDest.Save();
                                intReplaced = 0;
                            }
                        }
                    }
                }
            }
        }
コード例 #16
0
ファイル: Farms.cs プロジェクト: RavetcoFX/mace-minecraft
        private static void MakeMiniPondsAndHills(BetaWorld world, BlockManager bm)
        {
            int intFail  = 0;
            int intAdded = 0;

            do
            {
                int xlen = RandomHelper.Next(4, 12);
                int x1   = RandomHelper.Next(1, City.MapLength - (1 + xlen));
                int zlen = RandomHelper.Next(4, 12);
                int z1   = RandomHelper.Next(1, City.MapLength - (1 + zlen));
                if (!(x1 >= City.FarmLength && z1 >= City.FarmLength &&
                      x1 <= City.MapLength - City.FarmLength && z1 <= City.MapLength - City.FarmLength))
                {
                    bool booValid = true;
                    for (int x = x1 - 1; x <= x1 + xlen + 1 && booValid; x++)
                    {
                        for (int z = z1 - 1; z <= z1 + zlen + 1 && booValid; z++)
                        {
                            // make sure it doesn't overlap with the spawn point or another farm
                            if ((x == City.MapLength / 2 && z == SpawnZ) ||
                                bm.GetID(x, 63, z) != City.GroundBlockID ||
                                bm.GetID(x, 64, z) != BlockInfo.Air.ID)
                            {
                                booValid = false;
                            }
                        }
                    }
                    if (booValid)
                    {
                        if (RandomHelper.NextDouble() > 0.5)
                        {
                            MakePond(bm, x1, xlen, z1, zlen, true);
                        }
                        else
                        {
                            MakeHill(bm, x1, xlen, z1, zlen, true);
                        }
                        intFail = 0;
                        if (++intAdded % 25 == 0)
                        {
                            world.Save();
                        }
                    }
                    else
                    {
                        intFail++;
                    }
                }
            } while (intFail < 500);
        }
コード例 #17
0
ファイル: Buildings.cs プロジェクト: RavetcoFX/mace-minecraft
        private static void MakeBuildings(int[,] intArea, int intBlockStart, BetaWorld world, int intFarmSize)
        {
            int intBuildings = 0;

            for (int x = 0; x < intArea.GetLength(0); x++)
            {
                for (int z = 0; z < intArea.GetLength(1); z++)
                {
                    if (intArea[x, z] >= 100 && intArea[x, z] <= 500)
                    {
                        SourceWorld.Building CurrentBuilding = SourceWorld.GetBuilding(intArea[x, z] - 100);
                        SourceWorld.InsertBuilding(bmDest, intArea, intBlockStart, x, z, CurrentBuilding);
                        intArea[x + CurrentBuilding.intSize - 2, z + CurrentBuilding.intSize - 2] = 0;
                        if (++intBuildings == 20)
                        {
                            world.Save();
                            intBuildings = 0;
                        }
                    }
                }
            }
            world.Save();
        }
コード例 #18
0
        static void Main(string[] args)
        {
            BetaWorld    world = BetaWorld.Open("F:\\Minecraft\\test");
            BlockManager bm    = world.GetBlockManager();

            bm.AutoLight = false;

            Grid grid = new Grid();

            grid.BuildInit(bm);

            Generator             gen   = new Generator();
            List <Generator.Edge> edges = gen.Generate();

            foreach (Generator.Edge e in edges)
            {
                int x1;
                int y1;
                int z1;
                gen.UnIndex(e.node1, out x1, out y1, out z1);

                int x2;
                int y2;
                int z2;
                gen.UnIndex(e.node2, out x2, out y2, out z2);

                grid.LinkRooms(bm, x1, y1, z1, x2, y2, z2);
            }

            // Entrance Room
            grid.BuildRoom(bm, 2, 5, 2);
            grid.LinkRooms(bm, 2, 5, 2, 1, 5, 2);
            grid.LinkRooms(bm, 2, 5, 2, 3, 5, 2);
            grid.LinkRooms(bm, 2, 5, 2, 2, 5, 1);
            grid.LinkRooms(bm, 2, 5, 2, 2, 5, 3);
            grid.LinkRooms(bm, 2, 4, 2, 2, 5, 2);

            // Exit Room
            grid.BuildRoom(bm, 2, -1, 2);
            grid.LinkRooms(bm, 2, -1, 2, 2, 0, 2);
            grid.AddPrize(bm, 2, -1, 2);

            Console.WriteLine("Relight Chunks");

            BetaChunkManager cm = world.GetChunkManager();

            cm.RelightDirtyChunks();

            world.Save();
        }
コード例 #19
0
        private static void MakeMiniPondsAndHills(BetaWorld world, BlockManager bm, int intFarmSize, int intMapSize)
        {
            int intFail  = 0;
            int intAdded = 0;

            while (intFail <= 250)
            {
                int xlen = rand.Next(6, 10);
                int x1   = rand.Next(1, intMapSize - (1 + xlen));
                int zlen = rand.Next(6, 10);
                int z1   = rand.Next(1, intMapSize - (1 + zlen));
                if (!(x1 >= intFarmSize && z1 >= intFarmSize &&
                      x1 <= intMapSize - intFarmSize && z1 <= intMapSize - intFarmSize))
                {
                    bool booValid = true;
                    for (int x = x1 - 1; x <= x1 + xlen + 1 && booValid; x++)
                    {
                        for (int z = z1 - 1; z <= z1 + zlen + 1 && booValid; z++)
                        {
                            // make sure it doesn't overlap with the spawn point or another farm
                            if ((x == intMapSize / 2 && z == intMapSize - (intFarmSize - 10)) ||
                                bm.GetID(x, 63, z) != (int)BlockType.GRASS || bm.GetID(x, 64, z) != (int)BlockType.AIR)
                            {
                                booValid = false;
                                intFail++;
                            }
                        }
                    }
                    if (booValid)
                    {
                        if (rand.NextDouble() > 0.5)
                        {
                            MakePond(bm, x1, xlen, z1, zlen, true);
                        }
                        else
                        {
                            MakeHill(bm, x1, xlen, z1, zlen, true);
                        }
                        intFail = 0;
                        intAdded++;
                        if (intAdded % 25 == 0)
                        {
                            world.Save();
                        }
                    }
                }
            }
        }
コード例 #20
0
ファイル: Paths.cs プロジェクト: RavetcoFX/mace-minecraft
 private static void MakePaths(BetaWorld world, BlockManager bm, int[,] intArea)
 {
     for (int x = 0; x < intArea.GetLength(0); x++)
     {
         for (int z = 0; z < intArea.GetLength(1); z++)
         {
             if (intArea[x, z] == 1)
             {
                 bm.SetID(intBlockStart + x, 63, intBlockStart + z, (int)BlockType.DOUBLE_SLAB);
             }
         }
         if (x % 20 == 0)
         {
             world.Save();
         }
     }
 }
コード例 #21
0
        public void CropMaceWorld(frmMace frmLogForm)
        {
            Directory.CreateDirectory(Environment.GetEnvironmentVariable("APPDATA") + "\\.minecraft\\saves\\macecopy");
            BetaWorld    bwCopy = BetaWorld.Create(Environment.GetEnvironmentVariable("APPDATA") + "\\.minecraft\\saves\\macecopy");
            ChunkManager cmCopy = bwCopy.GetChunkManager();

            BetaWorld    bwCrop = BetaWorld.Open(Environment.GetEnvironmentVariable("APPDATA") + "\\.minecraft\\saves\\mace");
            ChunkManager cmCrop = bwCrop.GetChunkManager();

            foreach (ChunkRef chunk in cmCrop)
            {
                Debug.WriteLine("Copying chunk " + chunk.X + "," + chunk.Z);
                cmCopy.SetChunk(chunk.X, chunk.Z, chunk.GetChunkRef());
            }
            cmCopy.Save();
            bwCopy.Save();
        }
コード例 #22
0
ファイル: Buildings.cs プロジェクト: RavetcoFX/mace-minecraft
        public static structPoint MakeInsideCity(BlockManager bm, BetaWorld worldDest, int[,] intArea, frmMace frmLogForm)
        {
            int         intBlockStart       = City.EdgeLength + 13;
            structPoint spMineshaftEntrance = MakeBuildings(bm, intArea, intBlockStart, worldDest);

            worldDest.Save();
            if (City.HasPaths)
            {
                JoinPathsToRoad(bm);
            }
            else
            {
                RemovePaths(bm, intArea, intBlockStart);
            }
            frmLogForm.UpdateLog("Creating street lights: " + City.StreetLightType, true, true);
            MakeStreetLights(bm);
            return(spMineshaftEntrance);
        }
コード例 #23
0
ファイル: Buildings.cs プロジェクト: RavetcoFX/mace-minecraft
        public static structPoint MakeInsideCity(BlockManager bm, BetaWorld worldDest, int[,] intArea,
                                                 int intFarmLength, int intMapLength, bool booIncludePaths)
        {
            int         intBlockStart       = intFarmLength + 13;
            structPoint spMineshaftEntrance = MakeBuildings(bm, intArea, intBlockStart, worldDest, intFarmLength);

            worldDest.Save();
            if (!booIncludePaths)
            {
                RemovePaths(bm, intArea, intBlockStart);
            }
            else
            {
                JoinPathsToRoad(bm, intMapLength, intFarmLength);
            }
            MakeStreetLights(bm, intMapLength, intFarmLength);
            MakeFlowers(bm, worldDest, intFarmLength, intMapLength);
            return(spMineshaftEntrance);
        }
コード例 #24
0
        public static void CropMaceWorld(frmMace frmLogForm)
        {
            // thank you to Surrogard <*****@*****.**> for providing a linux friendly version of this code:
            Directory.CreateDirectory(Utils.GetMinecraftSavesDirectory("macecopy"));
            BetaWorld        bwCopy = BetaWorld.Create(Utils.GetMinecraftSavesDirectory("macecopy"));
            BetaChunkManager cmCopy = bwCopy.GetChunkManager();
            BetaWorld        bwCrop = BetaWorld.Open(Utils.GetMinecraftSavesDirectory("mace"));
            BetaChunkManager cmCrop = bwCrop.GetChunkManager();

            foreach (ChunkRef chunk in cmCrop)
            {
                if (chunk.X >= 0 && chunk.X <= 7 && chunk.Z >= 0 && chunk.Z <= 10)
                {
                    Debug.WriteLine("Copying chunk " + chunk.X + "," + chunk.Z);
                    cmCopy.SetChunk(chunk.X, chunk.Z, chunk.GetChunkRef());
                }
            }
            cmCopy.Save();
            bwCopy.Save();
        }
コード例 #25
0
        // this is a simplified version of the MakeBuildings method from Buildings.cs
        private static void MakeBuildings(BlockManager bm, int[,] intArea, BetaWorld world)
        {
            int intBuildings = 0;

            for (int x = 0; x < intArea.GetLength(0); x++)
            {
                for (int z = 0; z < intArea.GetLength(1); z++)
                {
                    // hack low: this 100 to 500 stuff is all a bit hackish really, need to find a proper solution
                    if (intArea[x, z] >= 100 && intArea[x, z] <= 500)
                    {
                        SourceWorld.Building CurrentBuilding = SourceWorld.GetBuilding(intArea[x, z] - 100);

                        if (CurrentBuilding.intSizeX >= 10 && RNG.NextDouble() > 0.8)
                        {
                            if (RNG.NextDouble() > 0.5)
                            {
                                MakePond(bm, 6 + x, CurrentBuilding.intSizeX, (6 - City.FarmLength) + z, CurrentBuilding.intSizeZ);
                            }
                            else
                            {
                                MakeHill(bm, 6 + x, CurrentBuilding.intSizeX, (6 - City.FarmLength) + z, CurrentBuilding.intSizeZ);
                            }
                        }
                        else
                        {
                            SourceWorld.InsertBuilding(bm, intArea, 0, 6 + x, (6 - City.FarmLength) + z, CurrentBuilding, 0, -1);
                        }

                        intArea[x + CurrentBuilding.intSizeX - 2, z + CurrentBuilding.intSizeZ - 2] = 0;
                        if (++intBuildings == NumberOfBuildingsBetweenSaves)
                        {
                            world.Save();
                            intBuildings = 0;
                        }
                    }
                }
            }
        }
コード例 #26
0
ファイル: Buildings.cs プロジェクト: RavetcoFX/mace-minecraft
        private static void MakeFlowers(BlockManager bmDest, BetaWorld worldDest, int intFarmLength, int intMapLength)
        {
            int intFlowers = 0;

            for (int x = intFarmLength + 11; x <= intMapLength - (intFarmLength + 11); x++)
            {
                for (int z = intFarmLength + 11; z <= intMapLength - (intFarmLength + 11); z++)
                {
                    if (bmDest.GetID(x, 63, z) == BlockType.GRASS &&
                        bmDest.GetID(x, 64, z) == BlockType.AIR)
                    {
                        bool booFree = true;
                        int  intFree = 0;
                        for (int xCheck = x - 1; xCheck <= x + 1 && booFree; xCheck++)
                        {
                            for (int zCheck = z - 1; zCheck <= z + 1 && booFree; zCheck++)
                            {
                                if (bmDest.GetID(xCheck, 63, zCheck) == BlockType.GRASS &&
                                    bmDest.GetID(xCheck, 64, zCheck) == BlockType.AIR)
                                {
                                    intFree++;
                                }
                            }
                        }
                        if (intFree >= MinimumFreeNeighboursNeededForFlowers &&
                            RandomHelper.NextDouble() <= FlowerChance)
                        {
                            AddFlowersToBlock(bmDest, x, z);
                            if (++intFlowers >= NumberOfFlowersBetweenSaves)
                            {
                                worldDest.Save();
                                intFlowers = 0;
                            }
                        }
                    }
                }
            }
        }
コード例 #27
0
ファイル: Chunks.cs プロジェクト: RavetcoFX/mace-minecraft
        public static void PositionRails(BetaWorld worldDest, BlockManager bm, int intCitySize)
        {
            int intReplaced = 0;

            for (int x = 0; x < intCitySize; x++)
            {
                for (int z = 0; z < intCitySize; z++)
                {
                    for (int y = 0; y < 128; y++)
                    {
                        if (bm.GetID(x, y, z) == BlockType.RAILS)
                        {
                            BlockHelper.MakeRail(x, y, z);
                            if (++intReplaced > 100)
                            {
                                worldDest.Save();
                                intReplaced = 0;
                            }
                        }
                    }
                }
            }
        }
コード例 #28
0
ファイル: Chunks.cs プロジェクト: RavetcoFX/mace-minecraft
        public static void PositionRails(BetaWorld worldDest, BlockManager bm)
        {
            int intReplaced = 0;

            for (int x = 0; x < City.MapLength; x++)
            {
                for (int z = 0; z < City.MapLength; z++)
                {
                    for (int y = 0; y < 128; y++)
                    {
                        if (bm.GetID(x, y, z) == BlockInfo.Rails.ID)
                        {
                            BlockHelper.MakeRail(x, y, z);
                            if (++intReplaced > 100)
                            {
                                worldDest.Save();
                                intReplaced = 0;
                            }
                        }
                    }
                }
            }
        }
コード例 #29
0
        public static void MakeFlowers(BetaWorld worldDest, BlockManager bm)
        {
            string[] strFlowers  = Utils.ArrayFromXMLElement(Path.Combine("Resources", "Themes", City.ThemeName + ".xml"), "options", "flowers");
            int      FlowerCount = 0;

            for (int x = 0; x <= City.MapLength; x++)
            {
                for (int z = -City.FarmLength; z <= City.MapLength; z++)
                {
                    if (bm.GetID(x, 63, z) == City.GroundBlockID &&
                        bm.GetID(x, 64, z) == BlockInfo.Air.ID)
                    {
                        int FreeNeighbours = 0;
                        for (int xCheck = x - 1; xCheck <= x + 1; xCheck++)
                        {
                            for (int zCheck = z - 1; zCheck <= z + 1; zCheck++)
                            {
                                if (bm.GetID(xCheck, 63, zCheck) == City.GroundBlockID &&
                                    bm.GetID(xCheck, 64, zCheck) == BlockInfo.Air.ID)
                                {
                                    FreeNeighbours++;
                                }
                            }
                        }
                        if (FreeNeighbours >= MinimumFreeNeighboursNeededForFlowers && RNG.NextDouble() * 100 <= City.FlowerSpawnPercent)
                        {
                            AddFlowersToBlock(bm, x, z, FreeNeighbours, RNG.RandomItemFromArray(strFlowers));
                            if (++FlowerCount >= NumberOfFlowersBetweenSaves)
                            {
                                worldDest.Save();
                                FlowerCount = 0;
                            }
                        }
                    }
                }
            }
        }
コード例 #30
0
ファイル: Buildings.cs プロジェクト: RavetcoFX/mace-minecraft
        private static void MakeFlowers(BlockManager bm, BetaWorld worldDest)
        {
            int intFlowers = 0;

            for (int x = City.FarmLength + 11; x <= City.MapLength - (City.FarmLength + 11); x++)
            {
                for (int z = City.FarmLength + 11; z <= City.MapLength - (City.FarmLength + 11); z++)
                {
                    if (bm.GetID(x, 63, z) == City.GroundBlockID &&
                        bm.GetID(x, 64, z) == BlockInfo.Air.ID)
                    {
                        int intFree = 0;
                        for (int xCheck = x - 1; xCheck <= x + 1; xCheck++)
                        {
                            for (int zCheck = z - 1; zCheck <= z + 1; zCheck++)
                            {
                                if (bm.GetID(xCheck, 63, zCheck) == City.GroundBlockID &&
                                    bm.GetID(xCheck, 64, zCheck) == BlockInfo.Air.ID)
                                {
                                    intFree++;
                                }
                            }
                        }
                        if (intFree >= MinimumFreeNeighboursNeededForFlowers &&
                            RandomHelper.NextDouble() * 100 <= City.FlowerSpawnPercent)
                        {
                            AddFlowersToBlock(bm, x, z, intFree);
                            if (++intFlowers >= NumberOfFlowersBetweenSaves)
                            {
                                worldDest.Save();
                                intFlowers = 0;
                            }
                        }
                    }
                }
            }
        }