예제 #1
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"));
        }
        public PlayerInventory(Player player) : base(player, 36)
        {
            if (!player.NamedTag.Exist("Inventory"))
            {
                ListTag initItems = new ListTag("Inventory", NBTTagType.COMPOUND);
                for (int i = 0; i < this.Size; ++i)
                {
                    initItems.Add(NBTIO.WriteItem(Item.Get(0, 0, 0), i));
                }
                player.NamedTag.PutList(initItems);
            }

            ListTag items = player.NamedTag.GetList("Inventory");

            for (int i = 0; i < this.Size; ++i)
            {
                Item item = NBTIO.ReadItem((CompoundTag)items[i]);
                this.SetItem(i, item, false);
            }

            this.PlayerCursorInventory     = new PlayerCursorInventory(player);
            this.PlayerEnderChestInventory = new PlayerEnderChestInventory(player);

            this.CraftingGridInventory = new CraftingGridInventory(player);
        }
예제 #3
0
        public override void SaveNBT()
        {
            ListTag inventory = new ListTag("EnderChestInventory", NBTTagType.COMPOUND);

            for (int i = 0; i < this.Size; ++i)
            {
                inventory.Add(NBTIO.WriteItem(this.GetItem(i), i));
            }
            this.Player.NamedTag.PutList(inventory);
        }
예제 #4
0
        public override CompoundTag SaveNBT()
        {
            CompoundTag nbt = base.SaveNBT();

            nbt.PutShort("Age", this.Age);
            nbt.PutShort("PickupDelay", this.PickupDelay);
            nbt.PutString("Owner", this.Owner);
            nbt.PutCompound("Item", NBTIO.WriteItem(this.Item));

            return(nbt);
        }
예제 #5
0
        public virtual CompoundTag SaveNBT()
        {
            CompoundTag nbt  = new CompoundTag();
            ListTag     list = new ListTag(this.Name, NBTTagType.COMPOUND);

            for (int i = 0; i < this.Size; ++i)
            {
                list.Add(NBTIO.WriteItem(this.GetItem(i), i));
            }
            nbt.PutList(list);
            return(nbt);
        }
예제 #6
0
        public virtual void LoadNBT(CompoundTag nbt)
        {
            if (!nbt.Exist(this.Name))
            {
                ListTag list = new ListTag(this.Name, NBTTagType.COMPOUND);
                for (int i = 0; i < this.Size; ++i)
                {
                    list.Add(NBTIO.WriteItem(Item.Get(0, 0, 0)));
                }
                nbt.PutList(list);
            }

            ListTag items = nbt.GetList(this.Name);

            for (int i = 0; i < this.Size; ++i)
            {
                Item item = NBTIO.ReadItem((CompoundTag)items[i]);
                this.SetItem(i, item, false);
            }
        }
        public ChestInventory(BlockEntityChest holder) : base(holder)
        {
            if (!holder.NamedTag.Exist("Items"))
            {
                ListTag initItems = new ListTag("Items", NBTTagType.COMPOUND);
                for (int i = 0; i < this.Size; ++i)
                {
                    initItems.Add(NBTIO.WriteItem(Item.Get(0, 0, 0), i));
                }
                holder.NamedTag.PutList(initItems);
            }

            ListTag items = holder.NamedTag.GetList("Items");

            for (int i = 0; i < this.Size; ++i)
            {
                Item item = NBTIO.ReadItem((CompoundTag)items[i]);
                this.SetItem(i, item, false);
            }
        }
        public EntityArmorInventory(EntityLiving entity) : base(entity)
        {
            if (!entity.NamedTag.Exist("Armor"))
            {
                ListTag newTag = new ListTag("Armor", NBTTagType.COMPOUND);
                for (int i = 0; i < this.Size; ++i)
                {
                    newTag.Add(NBTIO.WriteItem(Item.Get(0, 0, 0), i));
                }
                entity.NamedTag.PutList(newTag);
            }

            ListTag items = entity.NamedTag.GetList("Armor");

            for (int i = 0; i < this.Size; ++i)
            {
                Item item = NBTIO.ReadItem((CompoundTag)items[i]);
                this.SetItem(i, item, false);
            }
        }
예제 #9
0
        public EntityOffhandInventory(EntityLiving holder) : base(holder)
        {
            if (!holder.NamedTag.Exist("Offhand"))
            {
                ListTag newTag = new ListTag("Offhand", NBTTagType.COMPOUND);
                for (int i = 0; i < this.Size; ++i)
                {
                    newTag.Add(NBTIO.WriteItem(Item.Get(0, 0, 0)));
                }
                holder.NamedTag.PutList(newTag);
            }

            ListTag items = holder.NamedTag.GetList("Offhand");

            for (int i = 0; i < this.Size; ++i)
            {
                Item item = NBTIO.ReadItem((CompoundTag)items[i]);
                this.SetItem(i, item, false);
            }
        }
예제 #10
0
        public PlayerEnderChestInventory(Player player) : base(null)
        {
            this.Player = player;

            if (!player.NamedTag.Exist("EnderChestInventory"))
            {
                ListTag newTag = new ListTag("EnderChestInventory", NBTTagType.COMPOUND);
                for (int i = 0; i < this.Size; ++i)
                {
                    newTag.Add(NBTIO.WriteItem(Item.Get(0, 0, 0)));
                }
                player.NamedTag.PutList(newTag);
            }

            ListTag items = player.NamedTag.GetList("EnderChestInventory");

            for (int i = 0; i < this.Size; ++i)
            {
                Item item = NBTIO.ReadItem((CompoundTag)items[i]);
                this.SetItem(i, item, false);
            }
        }