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); }
protected override void EntityInit(CompoundTag nbt) { base.EntityInit(nbt); this.Age = nbt.GetShort("Age"); this.PickupDelay = nbt.GetShort("PickupDelay"); this.Owner = nbt.GetString("Owner"); this.Item = NBTIO.ReadItem(nbt.GetCompound("Item")); this.SetFlag(Entity.DATA_FLAGS, Entity.DATA_FLAG_IMMOBILE, true); }
public BlockEntityChest(Position position, CompoundTag nbt = null) : base(position, nbt) { this.Inventory = new ChestInventory(this); if (!this.NamedTag.Exist("items")) { this.NamedTag.PutList(new ListTag("items", NBTTagType.COMPOUND)); } ListTag items = this.NamedTag.GetList("items"); for (int i = 0; i < items.Count; ++i) { this.Inventory.SetItem(i, NBTIO.ReadItem((CompoundTag)items[i])); } }
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); } }
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); } }
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); } }