public void CopyTo(WindowArea area) { for (int i = 0; i < area.Length && i < Length; i++) { area[i] = this[i]; } }
protected internal virtual int MoveOrMergeItem(int index, ItemStack item, WindowArea from) { int emptyIndex = -1; var maximumStackSize = Item.GetMaximumStackSize(new ItemDescriptor(item.Id, item.Metadata)); for (int i = 0; i < Length; i++) { if (this[i].Empty && emptyIndex == -1) emptyIndex = i; else if (this[i].Id == item.Id && this[i].Metadata == item.Metadata && this[i].Count < maximumStackSize) { // Merging takes precedence over empty slots emptyIndex = -1; if (from != null) from[index] = ItemStack.EmptyStack; if (this[i].Count + item.Count > maximumStackSize) { item = new ItemStack(item.Id, (sbyte)(item.Count - (maximumStackSize - this[i].Count)), item.Metadata, item.Nbt); this[i] = new ItemStack(item.Id, (sbyte)maximumStackSize, item.Metadata, item.Nbt); continue; } this[i] = new ItemStack(item.Id, (sbyte)(this[i].Count + item.Count), item.Metadata); return i; } } if (emptyIndex != -1) { if (from != null) from[index] = ItemStack.EmptyStack; this[emptyIndex] = item; } return emptyIndex; }
protected internal override int MoveOrMergeItem(int index, ItemStack slot, WindowArea from) { for (int i = 0; i < Length; i++) { if (IsValid(slot, i)) { if (this[i].Empty) { this[i] = slot; from[index] = ItemStack.EmptyStack; return i; } } } return -1; }
protected internal override int MoveOrMergeItem(int index, ItemStack slot, WindowArea from) { for (int i = 0; i < Length; i++) { if (IsValid(slot, i)) { if (this[i].Empty) { this[i] = slot; from[index] = ItemStack.EmptyStack; return(i); } } } return(-1); }
protected internal virtual int MoveOrMergeItem(int index, ItemStack item, WindowArea from) { int emptyIndex = -1; //var maximumStackSize = Item.GetMaximumStackSize(new ItemDescriptor(item.Id, item.Metadata)); // TODO var maximumStackSize = 64; for (int i = 0; i < Length; i++) { if (this[i].Empty && emptyIndex == -1) { emptyIndex = i; } else if (this[i].Id == item.Id && this[i].Metadata == item.Metadata && this[i].Count < maximumStackSize) { // Merging takes precedence over empty slots emptyIndex = -1; if (from != null) { from[index] = ItemStack.EmptyStack; } if (this[i].Count + item.Count > maximumStackSize) { item = new ItemStack(item.Id, (sbyte)(item.Count - (maximumStackSize - this[i].Count)), item.Metadata, item.Nbt); this[i] = new ItemStack(item.Id, (sbyte)maximumStackSize, item.Metadata, item.Nbt); continue; } this[i] = new ItemStack(item.Id, (sbyte)(this[i].Count + item.Count), item.Metadata); return(i); } } if (emptyIndex != -1) { if (from != null) { from[index] = ItemStack.EmptyStack; } this[emptyIndex] = item; } return(emptyIndex); }
public void CopyTo(WindowArea area) { for (int i = 0; i < area.Length && i < Length; i++) area[i] = this[i]; }