public override void OnBlockPlaced(ItemStack byItemStack = null) { BlockContainer container = byItemStack?.Block as BlockContainer; if (container != null) { ItemStack[] stacks = container.GetContents(api.World, byItemStack); for (int i = 0; stacks != null && i < stacks.Length; i++) { Inventory[i].Itemstack = stacks[i]?.Clone(); } } }
public override void OnBlockPlaced(ItemStack byItemStack = null) { BlockContainer container = byItemStack?.Block as BlockContainer; if (container != null) { ItemStack[] stacks = container.GetContents(Api.World, byItemStack); if (stacks != null && stacks.Length > Inventory.Count) { throw new InvalidOperationException(string.Format("OnBlockPlaced stack copy failed. Trying to set {0} stacks on an inventory with {1} slots", stacks.Length, Inventory.Count)); } for (int i = 0; stacks != null && i < stacks.Length; i++) { Inventory[i].Itemstack = stacks[i]?.Clone(); } } }