SetDimension() public method

public SetDimension ( int ID ) : void
ID int
return void
Beispiel #1
0
        public void TEST002_SaveMap()
        {
            if (Directory.Exists("002"))
                Directory.Delete("002", true);
            Directory.CreateDirectory("002"); // Saves map here.

            InfdevHandler mh = new InfdevHandler();
            mh.Save("002/level.dat");
            mh.SetDimension(0);

            Chunk cnkA = mh.NewChunk(0, 0);
            cnkA.Blocks[0, 0, 0] = 0x01;
            cnkA.Blocks[0, 0, 1] = 0x02;
            cnkA.Blocks[0, 0, 2] = 0x03;
            cnkA.Blocks[0, 0, 3] = 0x04;
            cnkA.Save();

            FileInfo fA = new FileInfo(cnkA.Filename);

            Assert.Greater(fA.Length, 0, "System writing zero-length chunks.");

            Chunk cnkB = mh.GetChunk(0, 0);
            Assert.AreEqual(cnkB.Blocks[0, 0, 0], 0x01);
            Assert.AreEqual(cnkB.Blocks[0, 0, 1], 0x02);
            Assert.AreEqual(cnkB.Blocks[0, 0, 2], 0x03);
            Assert.AreEqual(cnkB.Blocks[0, 0, 3], 0x04);

            Directory.Delete("002", true);
        }
Beispiel #2
0
        public void TEST001_ReadMap()
        {
            if (Directory.Exists("001"))
                Directory.Delete("001", true);
            Directory.CreateDirectory("001"); // Copies map here.
            Utils.CopyRecursive("001_PRISTINE", "001");

            InfdevHandler mh = new InfdevHandler();
            mh.Load("001/level.dat");
            mh.SetDimension(0);

            //Loading 3 entities in chunk 14,8 (C:\Users\Rob\AppData\Roaming\.minecraft\saves\World5\e\8\c.e.8.dat):
            Chunk a = mh.GetChunk(14, 8);
            Assert.AreEqual(3, a.Entities.Count);

            Directory.Delete("001", true);
        }
Beispiel #3
0
        public void TEST002_SaveMap()
        {
            if (Directory.Exists("002"))
                Directory.Delete("002", true);
            Directory.CreateDirectory("002"); // Saves map here.

            InfdevHandler mh = new InfdevHandler();
            mh.Save("002/level.dat");
            mh.SetDimension(0);

            Chunk cnkA = mh.NewChunk(0, 0);
            cnkA.Blocks[0, 0, 0] = 0x01;
            cnkA.Blocks[0, 0, 1] = 0x02;
            cnkA.Blocks[0, 0, 2] = 0x03;
            cnkA.Blocks[0, 0, 3] = 0x04;
            cnkA.Save();

            FileInfo fA = new FileInfo(cnkA.Filename);

            Assert.Greater(fA.Length, 0, "System writing zero-length chunks.");

            Chunk cnkB = mh.GetChunk(0, 0);
            Assert.AreEqual(cnkB.Blocks[0, 0, 0], 0x01);
            Assert.AreEqual(cnkB.Blocks[0, 0, 1], 0x02);
            Assert.AreEqual(cnkB.Blocks[0, 0, 2], 0x03);
            Assert.AreEqual(cnkB.Blocks[0, 0, 3], 0x04);

            Console.WriteLine("Opening {0}...", cnkB.Filename);

            NbtFile chunkFile = new NbtFile(cnkB.Filename);
            chunkFile.LoadFile();

            NbtCompound level = chunkFile.RootTag.Get<NbtCompound>("Level");

            // Listed from a Minecraft-generated chunk.
            string[] reqdEntries = new string[]{
                "xPos",
                "zPos",
                "LastUpdate",
                "Blocks",
                "Data",
                "SkyLight",
                "BlockLight",
                "HeightMap",
                "TerrainPopulated",
                "Entities",
                "TileEntities"
            };
            foreach (string entry in reqdEntries)
            {
                if (level.Get(entry)==null)
                {
                    Console.WriteLine(chunkFile.RootTag.ToString());
                    Assert.Fail(string.Format("\"{0}\" is not included", entry));
                }
                else
                {
                    Console.WriteLine(" * Has {0}...", entry);
                }
            }

            Directory.Delete("002", true);
        }
Beispiel #4
0
        public void TEST004_AddEntities()
        {
            if (Directory.Exists("004"))
                Directory.Delete("004", true);
            Directory.CreateDirectory("004"); // Copies map here.

            {
                InfdevHandler a = new InfdevHandler();
                a.Save("004/level.dat");
                a.SetDimension(0);

                Sheep b = new Sheep();
                b.Air = 300;
                b.AttackTime = 0;
                b.DeathTime = 0;
                b.FallDistance = 0;
                b.Fire = -1;
                b.Health = 20;
                b.Sheared = false;
                b.UUID = Guid.NewGuid();
                b.Pos = new Vector3d(8, 100, 8);
                b.Rotation = new Rotation(0, 0);

                a.AddEntity(b);

                a.Save();
            }

            {
                InfdevHandler a = new InfdevHandler();
                a.Load("004/level.dat");
                a.SetDimension(0);

                Chunk chunk = a.GetChunk(0, 0,false);
                Assert.IsNotNull(chunk, "Sheep didn't get saved; Chunk didn't even get created.");
                Assert.AreEqual(1,chunk.Entities.Count,"The sheep didn't get saved.");
            }

            Directory.Delete("004", true);
        }
Beispiel #5
0
        public void TEST003_EditLevel()
        {
            if (Directory.Exists("003"))
                Directory.Delete("003", true);
            Directory.CreateDirectory("003"); // Copies map here.
            Utils.CopyRecursive("001_PRISTINE", "003");

            {
                InfdevHandler a = new InfdevHandler();
                a.Load("003/level.dat");
                a.SetDimension(0);

                a.Health = 10;

                a.Save();
            }
            InfdevHandler b = new InfdevHandler();
            b.Load("003/level.dat");
            b.SetDimension(0);

            Assert.True(b.Health == 10);

            Directory.Delete("003", true);
        }