Example #1
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     nbtFile.RootTag.Remove(lastKey);
     nbtFile.Save(path);
     ReloadList();
     Status("File Removed");
 }
Example #2
0
        private void btnNew_Click(object sender, EventArgs e)
        {
            saveFileDialog1.AddExtension = true;
            saveFileDialog1.DefaultExt   = "nbt";
            DialogResult dr = saveFileDialog1.ShowDialog();

            if (dr == DialogResult.OK)
            {
                NBTFile nbtfile = new NBTFile();
                path = saveFileDialog1.FileName;
                nbtfile.Compression = NBT.IO.Compression.NBTCompressionType.Uncompressed;
                nbtfile.RootTagName = "File Store";
                nbtfile.RootTag.Add("CompressionType", new TagString("Uncompressed"));
                nbtfile.Save(path);
                tb_path.Text       = path;
                btn_select.Enabled = true;
            }
        }
Example #3
0
        public void GenerateSchematics(string path, bool trackOutput = false)
        {
            var commands = GetCommands();

            NBTFile file = new NBTFile();

            file.RootTagName = "Schematic";

            file.RootTag.Add("Materials", new TagString("Alpha"));

            List <List <Command> > saveCommands = new List <List <Command> >();

            saveCommands.Add(new List <Command>());

            short current     = 0;
            short currentList = 0;

            int maxWidth = 0;
            int width    = 32;

            for (int i = 0; i < commands.Length;)
            {
                var command = commands[i];

                if (current < width)
                {
                    saveCommands[currentList].Add(command);
                    current++;
                    i++;
                    maxWidth++;
                }
                else if (command.type == CommandType.CHAIN_CONDITIONAL)
                {
                    width++;
                }
                else if (command.type == CommandType.CHAIN && commands[i - 1].type == CommandType.CHAIN_CONDITIONAL)
                {
                    width++;
                }
                else
                {
                    saveCommands.Add(new List <Command>());
                    current = 0;
                    currentList++;
                }
            }

            if (maxWidth < width)
            {
                width = maxWidth;
            }

            int height = 1;
            int length = saveCommands.Count;

            file.RootTag.Add("Width", new TagShort((short)width));
            file.RootTag.Add("Length", new TagShort((short)length));
            file.RootTag.Add("Height", new TagShort((short)height));

            var blockIds  = new Byte[width * height * length];
            var blockData = new Byte[width * height * length];

            TagList tileEntities = new TagList(TagTypes.TagCompound);

            for (int row = 0; row < saveCommands.Count; row++)
            {
                if (saveCommands[row].Count == width)
                {
                    var indices = new List <int>();
                    CreateCommandblockLines(trackOutput, blockIds, blockData, tileEntities, row, saveCommands, indices, width);
                    break;
                }
            }

            file.RootTag.Add("Blocks", new TagByteArray(blockIds));
            file.RootTag.Add("Data", new TagByteArray(blockData));

            file.RootTag.Add("Entities", new TagList(TagTypes.TagCompound));
            file.RootTag.Add("TileEntities", tileEntities);

            if (File.Exists(path))
            {
                File.Delete(path);
            }

            file.Save(path);
        }