Example #1
0
        public static void MakeMineshaft(BetaWorld world, BlockManager bm, Buildings.structPoint spMineshaftEntrance, frmMace frmLogForm)
        {
            _intBlockStartBuildings = City.EdgeLength + 13;
            int intMineshaftSize = (1 + City.MapLength) - (_intBlockStartBuildings * 2);

            if (intMineshaftSize % 5 > 0)
            {
                intMineshaftSize += 5 - (intMineshaftSize % 5);
            }
            _intBlockStartBuildings -= 2;
            for (int intLevel = 1; intLevel <= 7; intLevel++)
            {
                if (Utils.ValueFromXMLElement(Path.Combine("Resources", "Mineshaft.xml"), "active", "level" + intLevel.ToString()).IsAffirmative())
                {
                    MakeLevel(world, bm, intLevel, intMineshaftSize, spMineshaftEntrance, frmLogForm);
                }
            }
            int intBlockToReplace = bm.GetID(spMineshaftEntrance.x, 63, spMineshaftEntrance.z + 1);

            BlockShapes.MakeSolidBox(spMineshaftEntrance.x, spMineshaftEntrance.x,
                                     3, 63, spMineshaftEntrance.z + 1, spMineshaftEntrance.z + 1, BlockInfo.Wood.ID, 0);
            BlockHelper.MakeLadder(spMineshaftEntrance.x, 4, 63, spMineshaftEntrance.z, 0, BlockInfo.Wood.ID);
            BlockShapes.MakeSolidBox(spMineshaftEntrance.x, spMineshaftEntrance.x, 3, 63, spMineshaftEntrance.z + 1,
                                     spMineshaftEntrance.z + 1, BlockInfo.Stone.ID, 0);
            bm.SetID(spMineshaftEntrance.x, 63, spMineshaftEntrance.z + 1, intBlockToReplace);
        }
Example #2
0
 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();
         }
     }
 }
Example #3
0
        public static int[,] MakePaths(BetaWorld world, BlockManager bm, int intFarmSize, int intMapSize)
        {
            intStreet     = 0;
            intBlockStart = intFarmSize + 14;
            int intPlotBlocks = (1 + intMapSize) - (intBlockStart * 2);

            int[,] intArea = new int[intPlotBlocks, intPlotBlocks];
            // make the main roads
            for (int a = 0; a <= intArea.GetUpperBound(0); a++)
            {
                for (int b = -1; b <= 1; b++)
                {
                    intArea[a, (intArea.GetUpperBound(0) / 2) + b] = 1;
                    intArea[(intArea.GetUpperBound(0) / 2) + b, a] = 1;
                }
            }
            // make the districts
            SplitArea(bm, intArea, 0, 0,
                      (intArea.GetUpperBound(0) / 2) - 1, (intArea.GetUpperBound(0) / 2) - 1);
            SplitArea(bm, intArea, (intArea.GetUpperBound(0) / 2) + 1, (intArea.GetUpperBound(0) / 2) + 1,
                      intArea.GetUpperBound(0), intArea.GetUpperBound(0));
            SplitArea(bm, intArea, (intArea.GetUpperBound(0) / 2) + 1, 0,
                      intArea.GetUpperBound(0), (intArea.GetUpperBound(0) / 2) - 1);
            SplitArea(bm, intArea, 0, (intArea.GetUpperBound(0) / 2) + 1,
                      (intArea.GetUpperBound(0) / 2) - 1, intArea.GetUpperBound(0));
            MakePaths(world, bm, intArea);
            MakeStreetLights(bm, intMapSize, intFarmSize);
            return(intArea);
        }
        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();
        }
Example #5
0
        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");
            }
        }
Example #6
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();
        }
Example #7
0
        public static int[,] MakePaths(BetaWorld world, BlockManager bm, int intFarmSize, int intMapSize)
        {
            intStreet     = 0;
            intBlockStart = intFarmSize + 13;
            strStreetsUsed.Clear();
            int intPlotBlocks = (1 + intMapSize) - (intBlockStart * 2);

            int[,] intArea = new int[intPlotBlocks, intPlotBlocks];
            // make the main roads
            for (int a = 0; a <= intArea.GetUpperBound(0); a++)
            {
                for (int b = -1; b <= 1; b++)
                {
                    intArea[a, (intArea.GetUpperBound(0) / 2) + b] = 1;
                    intArea[(intArea.GetUpperBound(0) / 2) + b, a] = 1;
                }
            }
            // make the districts
            // top right
            SplitArea(bm, intArea, 0, 0,
                      (intArea.GetLength(0) / 2) - 2, (intArea.GetLength(0) / 2) - 2);
            // bottom left
            SplitArea(bm, intArea, (intArea.GetLength(0) / 2) + 2, (intArea.GetLength(0) / 2) + 2,
                      intArea.GetUpperBound(0), intArea.GetUpperBound(0));
            // bottom right
            SplitArea(bm, intArea, (intArea.GetLength(0) / 2) + 2, 0,
                      intArea.GetUpperBound(0), (intArea.GetLength(0) / 2) - 2);
            // top left
            SplitArea(bm, intArea, 0, (intArea.GetLength(0) / 2) + 2,
                      (intArea.GetLength(0) / 2) - 2, intArea.GetUpperBound(0));
            MakePaths(world, bm, intArea);
            MakeStreetLights(bm, intMapSize, intFarmSize);
            return(intArea);
        }
Example #8
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;
                        }
                    }
                }
            }
        }
Example #9
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)) == 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();
         }
     }
 }
Example #10
0
        public static void SetupClass()
        {
            intHouseNumber = 0;
            BetaWorld worldSource = BetaWorld.Open("Resources\\Mace");

            bmSource = worldSource.GetBlockManager();
            ReadBuildings();
        }
Example #11
0
        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();
        }
Example #12
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();
        }
Example #13
0
        public static int[,] MakePaths(BetaWorld world, BlockManager bm)
        {
            _intBlockStart = City.EdgeLength + 13;
            _intStreet     = 0;
            _lstDistricts.Clear();
            _lstStreetsUsed.Clear();
            _lstAllBuildings.Clear();
            // if the user doesn't want a mineshaft, we just tell Mace it's already been added
            _booIncludedMineshaft = !City.HasMineshaft;
            int intPlotBlocks = (1 + City.MapLength) - (_intBlockStart * 2);

            int[,] intArea = new int[intPlotBlocks, intPlotBlocks];
            // make the main roads
            for (int a = 0; a <= intArea.GetUpperBound(0); a++)
            {
                for (int c = -City.PathExtends; c <= City.PathExtends; c++)
                {
                    intArea[a, (intArea.GetUpperBound(0) / 2) + c] = 1;
                    intArea[(intArea.GetUpperBound(0) / 2) + c, a] = 1;
                }
            }

            // make the districts
            // top right
            SplitArea(bm, intArea, 0, 0,
                      (intArea.GetLength(0) / 2) - (City.PathExtends + 1), (intArea.GetLength(0) / 2) - (City.PathExtends + 1));

            // bottom left
            SplitArea(bm, intArea, (intArea.GetLength(0) / 2) + (City.PathExtends + 1), (intArea.GetLength(0) / 2) + (City.PathExtends + 1),
                      intArea.GetUpperBound(0), intArea.GetUpperBound(0));
            // bottom right
            SplitArea(bm, intArea, (intArea.GetLength(0) / 2) + (City.PathExtends + 1), 0,
                      intArea.GetUpperBound(0), (intArea.GetLength(0) / 2) - (City.PathExtends + 1));
            // top left
            SplitArea(bm, intArea, 0, (intArea.GetLength(0) / 2) + (City.PathExtends + 1),
                      (intArea.GetLength(0) / 2) - (City.PathExtends + 1), intArea.GetUpperBound(0));

            ShuffleDistricts(_lstDistricts);
            foreach (structDistrict stdCurrent in _lstDistricts)
            {
                int[,] intDistrict = FillArea(intArea, (stdCurrent.x2 - stdCurrent.x1),
                                              (stdCurrent.z2 - stdCurrent.z1), stdCurrent.x1, stdCurrent.z1,
                                              City.CityLength > 5 * 16);
                for (int x = 0; x < intDistrict.GetUpperBound(0) - 1; x++)
                {
                    for (int y = 0; y < intDistrict.GetUpperBound(1) - 1; y++)
                    {
                        intArea[stdCurrent.x1 + x + 1, stdCurrent.z1 + y + 1] = intDistrict[x + 1, y + 1];
                    }
                }
            }

            MakePaths(world, bm, intArea);

            return(intArea);
        }
Example #14
0
        public static int[,] MakePaths(BetaWorld world, BlockManager bm, int intFarmLength, int intMapLength,
                                       string strCitySize, bool booIncludeMineshaftOriginal)
        {
            // if the user doesn't want a mineshaft, we just tell Mace it's already been added
            _booIncludedMineshaft = !booIncludeMineshaftOriginal;
            _lstDistricts.Clear();
            _lstAllBuildings.Clear();
            _lstStreetsUsed.Clear();
            _intStreet     = 0;
            _intBlockStart = intFarmLength + 13;
            _lstStreetsUsed.Clear();
            int intPlotBlocks = (1 + intMapLength) - (_intBlockStart * 2);

            int[,] intArea = new int[intPlotBlocks, intPlotBlocks];
            // make the main roads
            for (int a = 0; a <= intArea.GetUpperBound(0); a++)
            {
                for (int b = -1; b <= 1; b++)
                {
                    intArea[a, (intArea.GetUpperBound(0) / 2) + b] = 1;
                    intArea[(intArea.GetUpperBound(0) / 2) + b, a] = 1;
                }
            }
            // make the districts
            // top right
            SplitArea(bm, intArea, 0, 0,
                      (intArea.GetLength(0) / 2) - 2, (intArea.GetLength(0) / 2) - 2);
            // bottom left
            SplitArea(bm, intArea, (intArea.GetLength(0) / 2) + 2, (intArea.GetLength(0) / 2) + 2,
                      intArea.GetUpperBound(0), intArea.GetUpperBound(0));
            // bottom right
            SplitArea(bm, intArea, (intArea.GetLength(0) / 2) + 2, 0,
                      intArea.GetUpperBound(0), (intArea.GetLength(0) / 2) - 2);
            // top left
            SplitArea(bm, intArea, 0, (intArea.GetLength(0) / 2) + 2,
                      (intArea.GetLength(0) / 2) - 2, intArea.GetUpperBound(0));

            ShuffleDistricts(_lstDistricts);
            foreach (structDistrict stdCurrent in _lstDistricts)
            {
                int[,] intDistrict = FillArea(intArea, (stdCurrent.x2 - stdCurrent.x1),
                                              (stdCurrent.z2 - stdCurrent.z1), stdCurrent.x1, stdCurrent.z1,
                                              strCitySize != "Very small");
                for (int x = 0; x < intDistrict.GetUpperBound(0) - 1; x++)
                {
                    for (int y = 0; y < intDistrict.GetUpperBound(1) - 1; y++)
                    {
                        intArea[stdCurrent.x1 + x + 1, stdCurrent.z1 + y + 1] = intDistrict[x + 1, y + 1];
                    }
                }
            }

            MakePaths(world, bm, intArea, intMapLength);

            return(intArea);
        }
Example #15
0
        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;
                            }
                        }
                    }
                }
            }
        }
Example #16
0
        static void Main(string[] args)
        {
            if (args.Length != 3)
            {
                Console.WriteLine("Usage: BlockReplace <world> <before-id> <after-id>");
                return;
            }

            string dest   = args[0];
            int    before = Convert.ToInt32(args[1]);
            int    after  = Convert.ToInt32(args[2]);

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

            // The chunk manager is more efficient than the block manager for
            // this purpose, since we'll inspect every block
            BetaChunkManager cm = world.GetChunkManager();

            foreach (ChunkRef chunk in cm)
            {
                // You could hardcode your dimensions, but maybe some day they
                // won't always be 16.  Also the CLR is a bit stupid and has
                // trouble optimizing repeated calls to Chunk.Blocks.xx, so we
                // cache them in locals
                int xdim = chunk.Blocks.XDim;
                int ydim = chunk.Blocks.YDim;
                int zdim = chunk.Blocks.ZDim;

                chunk.Blocks.AutoFluid = true;

                // x, z, y is the most efficient order to scan blocks (not that
                // you should care about internal detail)
                for (int x = 0; x < xdim; x++)
                {
                    for (int z = 0; z < zdim; z++)
                    {
                        for (int y = 0; y < ydim; y++)
                        {
                            // Replace the block with after if it matches before
                            if (chunk.Blocks.GetID(x, y, z) == before)
                            {
                                chunk.Blocks.SetData(x, y, z, 0);
                                chunk.Blocks.SetID(x, y, z, after);
                            }
                        }
                    }
                }

                // Save the chunk
                cm.Save();
            }
        }
Example #17
0
        public static int[,] MakePaths(BetaWorld world, BlockManager bm, int intFarmSize, int intMapSize)
        {
            lstDistricts.Clear();
            lstAllBuildings.Clear();
            lstStreetsUsed.Clear();
            intStreet     = 0;
            intBlockStart = intFarmSize + 13;
            lstStreetsUsed.Clear();
            int intPlotBlocks = (1 + intMapSize) - (intBlockStart * 2);

            int[,] intArea = new int[intPlotBlocks, intPlotBlocks];
            // make the main roads
            for (int a = 0; a <= intArea.GetUpperBound(0); a++)
            {
                for (int b = -1; b <= 1; b++)
                {
                    intArea[a, (intArea.GetUpperBound(0) / 2) + b] = 1;
                    intArea[(intArea.GetUpperBound(0) / 2) + b, a] = 1;
                }
            }
            // make the districts
            // top right
            SplitArea(bm, intArea, 0, 0,
                      (intArea.GetLength(0) / 2) - 2, (intArea.GetLength(0) / 2) - 2);
            // bottom left
            SplitArea(bm, intArea, (intArea.GetLength(0) / 2) + 2, (intArea.GetLength(0) / 2) + 2,
                      intArea.GetUpperBound(0), intArea.GetUpperBound(0));
            // bottom right
            SplitArea(bm, intArea, (intArea.GetLength(0) / 2) + 2, 0,
                      intArea.GetUpperBound(0), (intArea.GetLength(0) / 2) - 2);
            // top left
            SplitArea(bm, intArea, 0, (intArea.GetLength(0) / 2) + 2,
                      (intArea.GetLength(0) / 2) - 2, intArea.GetUpperBound(0));

            ShuffleDistricts(lstDistricts);
            foreach (structDistrict stdCurrent in lstDistricts)
            {
                int[,] intDistrict = FillArea(intArea, (stdCurrent.x2 - stdCurrent.x1), (stdCurrent.z2 - stdCurrent.z1), stdCurrent.x1, stdCurrent.z1);
                for (int x = 0; x < intDistrict.GetUpperBound(0) - 1; x++)
                {
                    for (int y = 0; y < intDistrict.GetUpperBound(1) - 1; y++)
                    {
                        intArea[stdCurrent.x1 + x + 1, stdCurrent.z1 + y + 1] = intDistrict[x + 1, y + 1];
                    }
                }
            }

            MakePaths(world, bm, intArea, intMapSize);

            MakeStreetLights(bm, intMapSize, intFarmSize);
            return(intArea);
        }
Example #18
0
        public static void MakeInsideCity(BlockManager bmDestOriginal, BetaWorld worldDest,
                                          int[,] intArea, int intFarmSize, int intMapSize, bool booIncludePaths)
        {
            bmDest = bmDestOriginal;
            int intBlockStart = intFarmSize + 14;

            MakeBuildings(intArea, intBlockStart, worldDest, intFarmSize);
            MakeFlowers(intFarmSize, intMapSize);
            if (!booIncludePaths)
            {
                RemovePaths(intArea, intBlockStart);
            }
        }
Example #19
0
        public static void SetupClass(BetaWorld worldDest)
        {
            AllBuildings   = new Building[0];
            intHouseNumber = 0;
            BetaWorld worldSource = BetaWorld.Open("Resources\\Mace");

            bmSource = worldSource.GetBlockManager();
            cmSource = worldSource.GetChunkManager();
            cmDest   = worldDest.GetChunkManager();
            lstCitySigns.Clear();
            lstInstanceSigns.Clear();
            ReadBuildings();
        }
Example #20
0
        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;
                            }
                        }
                    }
                }
            }
        }
Example #21
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;
                        }
                    }
                }
            }
        }
Example #22
0
        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);
        }
Example #23
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();
         }
     }
 }
Example #24
0
        static void Main(string[] args)
        {
            if (args.Length != 2)
            {
                Console.WriteLine("Usage: GoodyChest <world> <prob>");
                return;
            }

            string dest = args[0];
            double p    = Convert.ToDouble(args[1]);

            rand = new Random();

            // Open our world
            BetaWorld        world = BetaWorld.Open(dest);
            BetaChunkManager cm    = world.GetChunkManager();

            int added = 0;

            // Iterate through every chunk in the world
            // With proability p, pick a random location
            // inside the chunk to place a chest, above the
            // first solid block
            foreach (ChunkRef chunk in cm)
            {
                if (rand.NextDouble() < p)
                {
                    int x = rand.Next(chunk.Blocks.XDim);
                    int z = rand.Next(chunk.Blocks.ZDim);
                    int y = chunk.Blocks.GetHeight(x, z);

                    // Can't build this high (-2 to account for new MC 1.6 height limitation)
                    if (y >= chunk.Blocks.YDim - 2)
                    {
                        continue;
                    }

                    // Get a block object, then assign it to the chunk
                    AlphaBlock block = BuildChest();
                    chunk.Blocks.SetBlock(x, y + 1, z, block);

                    // Save the chunk
                    cm.Save();

                    added++;
                }
            }

            // And we're done
            Console.WriteLine("Added {0} goody chests to world", added);
        }
Example #25
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();
        }
Example #26
0
        public static bool SetupClass(BetaWorld worldDest)
        {
            _AllEntityPainting = new EntityPainting[0];
            _AllBuildings      = new Building[0];
            _intHouseNumber    = 0;
            BetaWorld worldSource = BetaWorld.Open(Path.Combine("Resources", "Mace"));

            _bmSource = worldSource.GetBlockManager();
            _cmSource = worldSource.GetChunkManager();
            _cmDest   = worldDest.GetChunkManager();
            _lstCitySigns.Clear();
            _lstInstanceSigns.Clear();
            return(ReadBuildings());
        }
Example #27
0
        public static bool SetupClass(BetaWorld worldDest, bool booIncludeItemsInChestsOriginal)
        {
            AllBuildings   = new Building[0];
            intHouseNumber = 0;
            BetaWorld worldSource = BetaWorld.Open(Path.Combine("Resources", "Mace"));

            bmSource = worldSource.GetBlockManager();
            cmSource = worldSource.GetChunkManager();
            cmDest   = worldDest.GetChunkManager();
            lstCitySigns.Clear();
            lstInstanceSigns.Clear();
            booIncludeItemsInChests = booIncludeItemsInChestsOriginal;
            return(ReadBuildings());
        }
Example #28
0
        static void Main(string[] args)
        {
            if (args.Length != 3)
            {
                Console.WriteLine("Usage: Convert <world> <dest> <a|b>");
                return;
            }

            string src     = args[0];
            string dst     = args[1];
            string srctype = args[2];

            // Open source and destrination worlds depending on conversion type
            NbtWorld srcWorld;
            NbtWorld dstWorld;

            if (srctype == "a")
            {
                srcWorld = AlphaWorld.Open(src);
                dstWorld = BetaWorld.Create(dst);
            }
            else
            {
                srcWorld = BetaWorld.Open(src);
                dstWorld = AlphaWorld.Create(dst);
            }

            // Grab chunk managers to copy chunks
            IChunkManager cmsrc = srcWorld.GetChunkManager();
            IChunkManager cmdst = dstWorld.GetChunkManager();

            // Copy each chunk from source to dest
            foreach (ChunkRef chunk in cmsrc)
            {
                cmdst.SetChunk(chunk.X, chunk.Z, chunk.GetChunkRef());
            }

            // Copy level data from source to dest
            dstWorld.Level.LoadTreeSafe(srcWorld.Level.BuildTree());

            // If we're creating an alpha world, get rid of the version field
            if (srctype == "b")
            {
                dstWorld.Level.Version = 0;
            }

            // Save level.dat
            dstWorld.Level.Save();
        }
Example #29
0
        static void Main(string[] args)
        {
            if (args.Length != 3)
            {
                Console.WriteLine("Usage: Convert <world> <dest> <alpha|beta|anvil>");
                return;
            }

            string src     = args[0];
            string dst     = args[1];
            string srctype = args[2];

            if (!Directory.Exists(dst))
            {
                Directory.CreateDirectory(dst);
            }

            // Open source and destrination worlds depending on conversion type
            NbtWorld srcWorld = NbtWorld.Open(src);
            NbtWorld dstWorld;

            switch (srctype)
            {
            case "alpha": dstWorld = AlphaWorld.Create(dst); break;

            case "beta": dstWorld = BetaWorld.Create(dst); break;

            case "anvil": dstWorld = AnvilWorld.Create(dst); break;

            default: throw new Exception("Invalid conversion type");
            }

            // Grab chunk managers to copy chunks
            IChunkManager cmsrc = srcWorld.GetChunkManager();
            IChunkManager cmdst = dstWorld.GetChunkManager();

            // Copy each chunk from source to dest
            foreach (ChunkRef chunk in cmsrc)
            {
                cmdst.SetChunk(chunk.X, chunk.Z, chunk.GetChunkRef());
                Console.WriteLine("Copying chunk: {0}, {1}", chunk.X, chunk.Z);
            }

            // Copy level data from source to dest
            dstWorld.Level.LoadTreeSafe(srcWorld.Level.BuildTree());

            // Save level.dat
            dstWorld.Level.Save();
        }
Example #30
0
        public static void MakeMineshaft(BetaWorld world, BlockManager bm, int intFarmSize, int intMapSize)
        {
            intBlockStart = intFarmSize + 13;
            int intMineshaftSize = (1 + intMapSize) - (intBlockStart * 2);

            intBlockStart -= 2;
            for (int intLevel = 1; intLevel <= 7; intLevel++)
            {
                MakeLevel(world, bm, intLevel, intMineshaftSize);
            }
            BlockShapes.MakeSolidBox(intMapSize / 2, intMapSize / 2, 3, 64, (intMapSize / 2) + 1, (intMapSize / 2) + 1, (int)BlockType.WOOD, 0);
            BlockHelper.MakeLadder(intMapSize / 2, 4, 63, intMapSize / 2, 0, (int)BlockType.WOOD);
            //BlockShapes.MakeSolidBox(intMapSize / 2, intMapSize / 2, 4, 63, intMapSize / 2, intMapSize / 2, (int)BlockType.AIR, 0);
            bm.SetID(intMapSize / 2, 64, intMapSize / 2, (int)BlockType.TRAPDOOR);
        }