Esempio n. 1
0
        public void TestNbtSmallFileLoading()
        {
            var file = new NbtFile();
            file.LoadFile("TestFiles/test.nbt.gz");

            AssertNbtSmallFile(file);
        }
Esempio n. 2
0
        public void TestNbtSmallFileLoadingUncompressed()
        {
            var file = new NbtFile();
            file.LoadFile("TestFiles/test.nbt", false);

            AssertNbtSmallFile(file);
        }
        public void TestNbtSmallFileLoading()
        {
            var file = new NbtFile();

            file.LoadFile("TestFiles/test.nbt.gz");

            AssertNbtSmallFile(file);
        }
Esempio n. 4
0
        private void Form1_Load(object sender, EventArgs e)
        {
            NbtFile test = new NbtFile("C:\\Users\\Paul Bruner\\Desktop\\Ol Drive\\alu-new-sixteen-bits.schematic", true);

            test.LoadFile();

            redBmp = new redstoneBmp();
        }
Esempio n. 5
0
        public void TestnbtBigFileLoadingUncompressed()
        {
            var file = new NbtFile();

            file.LoadFile("TestFiles/bigtest.nbt", false);

            AssertNbtBigFile(file);
        }
Esempio n. 6
0
        private void UpdatePosition()
        {
            NbtFile PlayerDat = new NbtFile(this.Server.ServerDirectory + "\\world\\players\\" + this.Username + ".dat");

            PlayerDat.LoadFile();
            this._position.x = PlayerDat.Query <LibNbt.Tags.NbtDouble>("//Pos/0").Value;
            this._position.y = PlayerDat.Query <LibNbt.Tags.NbtDouble>("//Pos/1").Value;
            this._position.z = PlayerDat.Query <LibNbt.Tags.NbtDouble>("//Pos/2").Value;
            PlayerDat.Dispose();
        }
Esempio n. 7
0
        private void button8_Click_1(object sender, EventArgs e)
        {
            NbtFile PlayerDat = new NbtFile(YAMS.Core.RootFolder + "\\servers\\1\\world\\players\\bigolslabomeat.dat");

            PlayerDat.LoadFile();
            Vector _position;

            _position.x = PlayerDat.Query <LibNbt.Tags.NbtDouble>("//Pos/0").Value;
            _position.y = PlayerDat.Query <LibNbt.Tags.NbtDouble>("//Pos/1").Value;
            _position.z = PlayerDat.Query <LibNbt.Tags.NbtDouble>("//Pos/2").Value;
            PlayerDat.Dispose();

            MessageBox.Show("x:" + _position.x.ToString() + " y:" + _position.y.ToString() + " z:" + _position.z.ToString());
        }
Esempio n. 8
0
        public static void test(Player player, Command cmd)
        {
            if (!File.Exists("C:/users/jb509/desktop/1.schematic"))
            {
                player.Message("Nop"); return;
            }
            NbtFile file = new NbtFile("C:/users/jb509/desktop/1.schematic");

            file.RootTag = new NbtCompound("Schematic");
            file.LoadFile();
            bool  notClassic = false;
            short width      = file.RootTag.Query <NbtShort>("/Schematic/Width").Value;
            short height     = file.RootTag.Query <NbtShort>("/Schematic/Height").Value;
            short length     = file.RootTag.Query <NbtShort>("/Schematic/Length").Value;

            Byte[] blocks = file.RootTag.Query <NbtByteArray>("/Schematic/Blocks").Value;

            Vector3I pos = player.Position.ToBlockCoords();
            int      i   = 0;

            player.Message("&SDrawing Schematic ({0}x{1}x{2})", length, width, height);
            for (int x = pos.X; x < width + pos.X; x++)
            {
                for (int y = pos.Y; y < length + pos.Y; y++)
                {
                    for (int z = pos.Z; z < height + pos.Z; z++)
                    {
                        if (Enum.Parse(typeof(Block), ((Block)blocks[i]).ToString(), true) != null)
                        {
                            if (!notClassic && blocks[i] > 49)
                            {
                                notClassic = true;
                                player.Message("&WSchematic used is not designed for Minecraft Classic;" +
                                               " Converting all unsupported blocks with air");
                            }
                            if (blocks[i] < 50)
                            {
                                player.WorldMap.QueueUpdate(new BlockUpdate(null, (short)x, (short)y, (short)z, (Block)blocks[i]));
                            }
                        }
                        i++;
                    }
                }
            }
            file.Dispose();
        }
Esempio n. 9
0
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            openFileDialog.Filter           = "Schematic Files .schematic | *.schematic";
            openFileDialog.Title            = "Select a Schematic";
            openFileDialog.InitialDirectory = System.Environment.GetFolderPath(Environment.SpecialFolder.Personal);

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                NbtFile test = new NbtFile(openFileDialog.FileName, true);
                test.LoadFile();
                AssertNbtBigFile(test);
                paintIt     = true;
                this.Width  = rXmax * 20;
                this.Height = rYmax * 20;
                this.Refresh();

                Console.WriteLine("CLICK!");
            }
        }
Esempio n. 10
0
        public void TestNbtListType()
        {
            var file = new NbtFile();
            file.RootTag = new NbtCompound("ListTypeTest");

            NbtTagType mytype = NbtTagType.TAG_Compound;

            NbtList list = new NbtList("Entities", null, mytype);
            file.RootTag.Tags.Add(list);

            file.SaveFile("TestFiles/NbtListType.nbt");

            NbtFile read = new NbtFile();
            read.LoadFile("TestFiles/NbtListType.nbt");
            Assert.NotNull(read);
            Console.WriteLine(read.RootTag.ToString());

            NbtList readlist = (NbtList)read.RootTag.Tags.ToArray()[0];
            Assert.NotNull(readlist);

            Assert.AreEqual(mytype, readlist.ListType);
        }
Esempio n. 11
0
 public void TagQueryTestSetUp()
 {
     _file = new NbtFile();
     _file.LoadFile("TestFiles/bigtest.nbt.gz");
 }
Esempio n. 12
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);
        }
Esempio n. 13
0
        public static Blocks Load(string filename)
        {
            NbtFile f = new NbtFile();

            f.LoadFile(filename);
            NbtCompound root    = f.RootTag;
            NbtTag      nBlocks = root["Blocks"];
            NbtTag      nData   = root["Data"];
            NbtTag      nWidth  = root["Width"];
            NbtTag      nLength = root["Length"];
            NbtTag      nHeight = root["Height"];

            byte[] blocks = ((NbtByteArray)nBlocks).Value;
            byte[] extra  = ((NbtByteArray)nData).Value;
            int    X      = (int)((NbtShort)nWidth).Value;
            int    Y      = (int)((NbtShort)nLength).Value;
            int    Z      = (int)((NbtShort)nHeight).Value;
            Blocks b      = new Blocks(X, Y, Z);

            //bool sch = filename.EndsWith(".schematic");

            for (int i = 0; i < blocks.Length; i++)
            {
                switch (blocks[i])
                {
                case 0:
                case 6:
                case 37:
                case 38:
                case 39:
                case 40:
                case 51:
                case 59:
                case 63:
                case 65:
                case 66:
                case 68:
                case 78:
                case 83:
                    b[i] = Block.AIR;
                    break;

                case 55:
                    b[i] = Block.WIRE;
                    break;

                case 75:     // Off
                    b[i] = new Block(BlockType.TORCH, PlaceTorch(extra[i]), 0, 0, 0);

                    break;

                case 76:     // Off
                    b[i] = new Block(BlockType.TORCH, PlaceTorch(extra[i]), 16, 0, 0);

                    // System.Console.WriteLine("Loc: {2}  Torch Dir: {0}    Byte: {1}", b[i].Place.ToString(), extra[i] & 0x7,i);
                    break;

                case 69:
                    b[i] = new Block(BlockType.LEVER, PlaceTorch(extra[i]), (extra[i] & 0x8) == 1 ? 16 : 0, 0, 0);

                    //   System.Console.WriteLine("Lever Dir: {0}    Byte: {1}", b[i].Place.ToString(), extra[i] & 0x7);
                    break;

                case 70:
                case 72:
                    b[i] = Block.PREASUREPAD;
                    break;

                case 77:
                    b[i]       = Block.BUTTON;
                    b[i].Place = PlaceButton(extra[i]);
                    break;

                case 64:     // doors not working yet
                case 71:
                    break;

                case 93:     // skip repeaters for now

                    break;

                default:
                    b[i] = Block.BLOCK;
                    break;
                }
            }


            return(b);
        }
Esempio n. 14
0
 public void TagQueryTestSetUp()
 {
     _file = new NbtFile();
     _file.LoadFile("TestFiles/bigtest.nbt.gz");
 }