示例#1
0
        public void NBTIOTests_WriteGZFileTest()
        {
            ListTag list = new ListTag("list", NBTTagType.COMPOUND);

            list.Add(new CompoundTag().PutInt("c1", 123));
            list.Add(new CompoundTag().PutLong("c2", 123456));
            CompoundTag subTag = new CompoundTag();

            subTag.PutBool("bool", true);
            subTag.PutByte("byte", 123);
            CompoundTag tag = new CompoundTag();

            tag.PutBool("bool", true);
            tag.PutByte("byte", 123);
            tag.PutByteArray("byteArray", ArrayUtils.CreateArray <byte>(200));
            tag.PutShort("short", 12345);
            tag.PutInt("int", 12345678);
            tag.PutIntArray("intArray", ArrayUtils.CreateArray <int>(200));
            tag.PutLong("long", 123456789123456);
            tag.PutLongArray("longArray", ArrayUtils.CreateArray <long>(200));
            tag.PutFloat("float", 12.3456f);
            tag.PutDouble("double", 12.3456789);
            tag.PutList(list);
            tag.PutCompound("com", subTag);
            NBTIO.WriteGZIPFile(Environment.CurrentDirectory + "\\test2.nbt", tag);
        }
示例#2
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"));
        }
示例#3
0
        public void Create(World world)
        {
            CompoundTag tag = new CompoundTag("");

            tag.PutCompound("Data", this.CreateData(world));

            NBTIO.WriteGZIPFile($"{Server.ExecutePath}\\worlds\\{world.Name}\\level.dat", tag);
        }
示例#4
0
        public void Save()
        {
            CompoundTag tag = new CompoundTag();

            tag.PutCompound("Data", this.Data);
            tag = new CompoundTag().PutCompound("", tag);
            NBTIO.WriteGZIPFile(this.FolderPath, tag, NBTEndian.BIG_ENDIAN);
        }
示例#5
0
        public void Save()
        {
            if (this.HasSpawned)
            {
                this.SaveNBT();

                string path = $"{Server.ExecutePath}\\players\\{this.Name}.dat";
                NBTIO.WriteGZIPFile(path, this.NamedTag, NBTEndian.BIG_ENDIAN);
            }
        }
示例#6
0
        public void SaveOfflinePlayerData(string xuid, CompoundTag nbt)
        {
            string path = $"{PlayerDataPath}/{xuid}.dat";

            NBTIO.WriteGZIPFile(path, nbt, NBTEndian.BIG_ENDIAN);
        }