Skip to content

Commit

Permalink
Fixed issue with chests failing to save to a schematic due to a NullP…
Browse files Browse the repository at this point in the history
…ointerException.
  • Loading branch information
sk89q committed Dec 31, 2010
1 parent 59afcce commit 24434e3
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/com/sk89q/worldedit/blocks/ChestBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,15 @@ public Map<String,Tag> toTileEntityNBT()
List<Tag> itemsList = new ArrayList<Tag>();
for (int i = 0; i < items.length; i++) {
BaseItemStack item = items[i];
Map<String,Tag> data = new HashMap<String,Tag>();
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<String,Tag> data = new HashMap<String,Tag>();
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<String,Tag> values = new HashMap<String,Tag>();
values.put("Items", new ListTag("Items", CompoundTag.class, itemsList));
Expand Down

0 comments on commit 24434e3

Please sign in to comment.