From 24434e3e6fbf4bf440c6b87c163e2cc12de10591 Mon Sep 17 00:00:00 2001 From: sk89q Date: Fri, 31 Dec 2010 01:20:00 -0800 Subject: [PATCH] Fixed issue with chests failing to save to a schematic due to a NullPointerException. --- src/com/sk89q/worldedit/blocks/ChestBlock.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/com/sk89q/worldedit/blocks/ChestBlock.java b/src/com/sk89q/worldedit/blocks/ChestBlock.java index 5d39a9296..5aaade6c5 100644 --- a/src/com/sk89q/worldedit/blocks/ChestBlock.java +++ b/src/com/sk89q/worldedit/blocks/ChestBlock.java @@ -105,13 +105,15 @@ public class ChestBlock extends BaseBlock implements TileEntityBlock { List itemsList = new ArrayList(); for (int i = 0; i < items.length; i++) { BaseItemStack item = items[i]; - Map data = new HashMap(); - CompoundTag itemTag = new CompoundTag("Items", data); - data.put("id", new ShortTag("id", item.getID())); - data.put("Damage", new ShortTag("Damage", item.getDamage())); - data.put("Count", new ByteTag("Count", (byte)item.getAmount())); - data.put("Slot", new ByteTag("Slot", (byte)i)); - itemsList.add(itemTag); + if (item != null) { + Map data = new HashMap(); + CompoundTag itemTag = new CompoundTag("Items", data); + data.put("id", new ShortTag("id", item.getID())); + data.put("Damage", new ShortTag("Damage", item.getDamage())); + data.put("Count", new ByteTag("Count", (byte)item.getAmount())); + data.put("Slot", new ByteTag("Slot", (byte)i)); + itemsList.add(itemTag); + } } Map values = new HashMap(); values.put("Items", new ListTag("Items", CompoundTag.class, itemsList));