Пример #1
0
        public void NBTIOTests_ReadGZFileTest()
        {
            CompoundTag tag = NBTIO.ReadGZIPFile(Environment.CurrentDirectory + "\\test2.nbt");

            Console.WriteLine(tag);
            Console.WriteLine(tag.GetList("list")[0]);
        }
Пример #2
0
        private void gZipGToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.AddExtension     = true;
            dialog.CheckFileExists  = true;
            dialog.CheckPathExists  = true;
            dialog.Multiselect      = false;
            dialog.RestoreDirectory = true;
            dialog.Title            = LangManager.GetString("nbtViewer_selectNBTFormatFile");

            DialogResult result = dialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                this.cacheData.NBTViewerCache.Rows.Clear();
                try
                {
                    CompoundTag tag = NBTIO.ReadGZIPFile(dialog.FileName, this.Endian);
                    this._Load(tag);
                }
                catch (Exception exc)
                {
                    MessageBox.Show(exc.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Пример #3
0
        public void NBTIOTests_Test3()
        {
            this.namedTag = new CompoundTag();
            this.namedTag.PutList(new ListTag("Attributes", NBTTagType.COMPOUND));

            this.namedTag.PutList(new ListTag("Pos", NBTTagType.FLOAT));
            this.namedTag.PutList(new ListTag("Rotation", NBTTagType.FLOAT));

            this.namedTag.PutInt("PlayerGameMode", 0);
            this.namedTag.PutInt("PlayerLevel", 0);
            this.namedTag.PutFloat("PlayerLevelProgress", 0f);

            if (!this.namedTag.Exist("Inventory"))
            {
                ListTag initItems = new ListTag("Inventory", NBTTagType.COMPOUND);
                for (int i = 0; i < 36; ++i)
                {
                    initItems.Add(NBTIO.WriteItem(Item.Get(0), i));
                }
                this.namedTag.PutList(initItems);
            }

            ListTag items = this.namedTag.GetList("Inventory");

            for (int i = 0; i < 36; ++i)
            {
                Item item = NBTIO.ReadItem((CompoundTag)items[i]);
            }

            NBTIO.WriteGZIPFile(Environment.CurrentDirectory + "\\test3.nbt", this.namedTag);
            Console.WriteLine(NBTIO.ReadGZIPFile(Environment.CurrentDirectory + "\\test3.nbt"));
        }
Пример #4
0
        private void LoadData()
        {
            string path = $"{Server.ExecutePath}\\players\\{this.Name}.dat";

            if (!File.Exists(path))
            {
                PlayerCreateDataEventArgs playerCreateDataEvent = new PlayerCreateDataEventArgs(this);
                PlayerEvents.OnPlayerCreateData(playerCreateDataEvent);

                this.RegisterData();
            }
            else
            {
                this.NamedTag = NBTIO.ReadGZIPFile(path, NBTEndian.BIG_ENDIAN);
            }

            this.Inventory = new PlayerInventory(this);

            this.gameMode = GameModeExtention.FromIndex(this.NamedTag.GetInt("PlayerGameMode"));
        }
Пример #5
0
        public CompoundTag GetOfflinePlayerData(string xuid)
        {
            string      path = $"{PlayerDataPath}/{xuid}.dat";
            CompoundTag nbt;

            if (!File.Exists(path))
            {
                World    world = World.GetMainWorld();
                Position pos   = world.GetWorldSpawn();
                nbt = new CompoundTag()
                      .PutLong("firstPlayed", DateTime.Now.ToBinary())
                      .PutLong("lastPlayed", DateTime.Now.ToBinary())
                      .PutList(new ListTag("Pos", NBTTagType.FLOAT)
                               .Add(new FloatTag("", pos.X))
                               .Add(new FloatTag("", pos.Y))
                               .Add(new FloatTag("", pos.Z)))
                      .PutList(new ListTag("Motion", NBTTagType.FLOAT)
                               .Add(new FloatTag("", 0))
                               .Add(new FloatTag("", 0))
                               .Add(new FloatTag("", 0)))
                      .PutList(new ListTag("Rotation", NBTTagType.FLOAT)
                               .Add(new FloatTag("", 0))
                               .Add(new FloatTag("", 0)))
                      .PutString("World", pos.World.Name)
                      .PutInt("Dimension", DimensionIDs.OverWorld)
                      .PutInt("PlayerGameType", Instance.ServerProperty.GameMode.GetIndex())
                      .PutInt("SpawnX", world.SpawnX)
                      .PutInt("SpawnY", world.SpawnY)
                      .PutInt("SpawnZ", world.SpawnZ)
                      .PutInt("Score", 0);

                this.SaveOfflinePlayerData(xuid, nbt);
            }
            else
            {
                nbt = NBTIO.ReadGZIPFile(path, NBTEndian.BIG_ENDIAN);
            }

            return(nbt);
        }
Пример #6
0
        public void Load(World world)
        {
            CompoundTag tag = NBTIO.ReadGZIPFile($"{Server.ExecutePath}\\worlds\\{world.Name}\\level.dat");

            CompoundTag data = tag.GetCompound("Data");
        }
Пример #7
0
        public void Load()
        {
            CompoundTag tag = NBTIO.ReadGZIPFile(this.FolderPath, NBTEndian.BIG_ENDIAN);

            this.Data = tag.GetCompound("").GetCompound("Data");
        }