From 96107038746354f77494bce1b3317ea8936eb436 Mon Sep 17 00:00:00 2001 From: natalieogle Date: Sun, 21 Feb 2016 18:50:54 -0800 Subject: [PATCH] Add check to only build itemStack if there are items. --- src/pane.coffee | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/pane.coffee b/src/pane.coffee index 277835d3c..1504553af 100644 --- a/src/pane.coffee +++ b/src/pane.coffee @@ -300,10 +300,11 @@ class Pane extends Model # Build the itemStack after deserializing addItemsToStack: (itemStackIndices) -> - if itemStackIndices.length is 0 or itemStackIndices.length isnt @items.length or itemStackIndices.indexOf(-1) >= 0 - itemStackIndices = (i for i in [0..@items.length-1]) - for itemIndex in itemStackIndices - @addItemToStack(@items[itemIndex]) + if @items.length > 0 + if itemStackIndices.length is 0 or itemStackIndices.length isnt @items.length or itemStackIndices.indexOf(-1) >= 0 + itemStackIndices = (i for i in [0..@items.length-1]) unless @items.length is 0 + for itemIndex in itemStackIndices + @addItemToStack(@items[itemIndex]) # Add item (or move item) to the end of the itemStack addItemToStack: (newItem) ->