예제 #1
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
            NbtWorld world = NbtWorld.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();
        }
예제 #2
0
        public static void SetBiomeData(string dest)
        {
            NbtWorld      world = NbtWorld.Open(dest);
            IChunkManager cm    = world.GetChunkManager();

            foreach (ChunkRef chunk in cm)
            {
                AnvilChunk       anvil_chunk = chunk.GetChunkRef() as AnvilChunk;
                TagNodeByteArray biomeNode   = anvil_chunk.Tree.Root["Level"].ToTagCompound()["Biomes"].ToTagByteArray();
                ZXByteArray      biomeData   = new ZXByteArray(16, 16, biomeNode.Data);
                for (int x = 0; x <= 15; x++)
                {
                    for (int y = 0; y <= 15; y++)
                    {
                        biomeData[x, y] = biomes[chunk.X + "." + chunk.Z];
                    }
                }
                chunk.SetChunkRef(anvil_chunk);
                cm.Save();
            }
            world.Save();
        }
예제 #3
0
        static void Main(string[] args)
        {
            if (args.Length < 2)
            {
                Console.WriteLine("Usage: eina_to_nbt <source> <dest>");
                return;
            }

            String dest = args[1];

            System.Console.WriteLine("Creating EINA map...");

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


            NbtWorld world = AnvilWorld.Create(dest);

            world.Level.LevelName   = "EINA";
            world.Level.Spawn       = new SpawnPoint(292, 70, 270);
            world.Level.GameType    = GameType.CREATIVE;
            world.Level.Initialized = true;


            Player p = new Player();

            p.Position.X = 292;
            p.Position.Y = 130;
            p.Position.Z = 292;



            IPlayerManager pm = world.GetPlayerManager();

            pm.SetPlayer("Player", p);


            IChunkManager cm = world.GetChunkManager();


            string[] lines = System.IO.File.ReadAllLines(args[0]);

            string[] words;



            ChunkRef chunk;


            words = lines[0].Split(' ');
            int minx = Int32.Parse(words[0]);
            int maxx = Int32.Parse(words[0]);
            int miny = Int32.Parse(words[0]);
            int maxy = Int32.Parse(words[0]);

            for (int i = 0; i < lines.Length; i++)
            {
                words = lines[i].Split(' ');
                //System.Console.WriteLine(lines[i]);
                int x     = Int32.Parse(words[0]);
                int y     = Int32.Parse(words[1]);
                int z     = Int32.Parse(words[2]);
                int color = Int32.Parse(words[3]);

                string text = "";



                if (words.Length > 4)
                {
                    text = words[4];
                    for (int j = 5; j < words.Length; j++)
                    {
                        text += ' ' + words[j];
                    }
                }
                else
                {
                    text = "";
                }


                int xLocal = x / 16;
                int yLocal = y / 16;

                if (xLocal < minx)
                {
                    minx = xLocal;
                }
                if (xLocal > maxx)
                {
                    maxx = xLocal;
                }
                if (yLocal < miny)
                {
                    miny = yLocal;
                }
                if (yLocal > maxy)
                {
                    maxy = yLocal;
                }

                if (!cm.ChunkExists(xLocal, yLocal))
                {
                    //System.Console.WriteLine(xLocal+"  "+yLocal);
                    cm.CreateChunk(xLocal, yLocal);
                }
                chunk = cm.GetChunkRef(xLocal, yLocal);
                //System.Console.WriteLine(x+"  "+y+"   "+z);
                //System.Console.WriteLine(xLocal+"  "+yLocal);

                if (!chunk.IsDirty)
                {
                    chunk.IsTerrainPopulated = true;
                    chunk.Blocks.AutoLight   = false;
                    //FlatChunk(chunk, 64);
                    chunk.Blocks.RebuildHeightMap();
                    chunk.Blocks.RebuildBlockLight();
                    chunk.Blocks.RebuildSkyLight();
                    //System.Console.WriteLine(chunk.IsDirty);

                    for (int i2 = 0; i2 < 16; i2++)
                    {
                        for (int j = 0; j < 16; j++)
                        {
                            setBlock(chunk, i2, 64, j, 16, "");
                        }
                    }
                    if (((xLocal % 8) == 0) & ((yLocal % 8) == 0))
                    {
                        cm.Save();
                    }

                    setBlock(chunk, x % 16, z + 64, y % 16, color, text);
                }
                else
                {
                    setBlock(chunk, x % 16, z + 64, y % 16, color, text);
                    //System.Console.WriteLine("hola");
                }
                if ((i + 1) % 500000 == 0)
                {
                    System.Console.WriteLine("Guardando");
                    world.Save();
                    //System.Console.WriteLine("Hecho");
                }
            }



            world.Save();
        }
예제 #4
0
 public void saveMinecraftWorld()
 {
     // Save all remaining data (including a default level.dat)
     // If we didn't save chunks earlier, they would be saved here
     currentWorld.Save();
 }