From 3b59798f37aedbe06656cbff7c6cd3d489ff3f9e Mon Sep 17 00:00:00 2001 From: sk89q Date: Fri, 24 Aug 2012 16:50:32 -0700 Subject: [PATCH] Fixed chunk loading code not properly handling tile entity data. --- .../com/sk89q/worldedit/data/AnvilChunk.java | 23 +++++++++---------- .../com/sk89q/worldedit/data/OldChunk.java | 23 +++++++++---------- 2 files changed, 22 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/sk89q/worldedit/data/AnvilChunk.java b/src/main/java/com/sk89q/worldedit/data/AnvilChunk.java index 8605c9be3..d539abf4a 100644 --- a/src/main/java/com/sk89q/worldedit/data/AnvilChunk.java +++ b/src/main/java/com/sk89q/worldedit/data/AnvilChunk.java @@ -15,13 +15,6 @@ import com.sk89q.worldedit.BlockVector; import com.sk89q.worldedit.LocalWorld; import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.blocks.BaseBlock; -import com.sk89q.worldedit.blocks.BlockID; -import com.sk89q.worldedit.blocks.ChestBlock; -import com.sk89q.worldedit.blocks.DispenserBlock; -import com.sk89q.worldedit.blocks.FurnaceBlock; -import com.sk89q.worldedit.blocks.MobSpawnerBlock; -import com.sk89q.worldedit.blocks.NoteBlock; -import com.sk89q.worldedit.blocks.SignBlock; import com.sk89q.worldedit.blocks.TileEntityBlock; public class AnvilChunk implements Chunk { @@ -187,7 +180,11 @@ public class AnvilChunk implements Chunk { populateTileEntities(); } - return new CompoundTag("", tileEntities.get(new BlockVector(pos))); + Map values = tileEntities.get(new BlockVector(pos)); + if (values == null) { + return null; + } + return new CompoundTag("", values); } @Override @@ -196,7 +193,7 @@ public class AnvilChunk implements Chunk { int data = getBlockData(pos); BaseBlock block; - if (id == BlockID.WALL_SIGN || id == BlockID.SIGN_POST) { + /*if (id == BlockID.WALL_SIGN || id == BlockID.SIGN_POST) { block = new SignBlock(id, data); } else if (id == BlockID.CHEST) { block = new ChestBlock(data); @@ -208,13 +205,15 @@ public class AnvilChunk implements Chunk { block = new MobSpawnerBlock(data); } else if (id == BlockID.NOTE_BLOCK) { block = new NoteBlock(data); - } else { + } else {*/ block = new BaseBlock(id, data); - } + //} if (block instanceof TileEntityBlock) { CompoundTag tileEntity = getBlockTileEntity(pos); - ((TileEntityBlock) block).setNbtData(tileEntity); + if (tileEntity != null) { + ((TileEntityBlock) block).setNbtData(tileEntity); + } } return block; diff --git a/src/main/java/com/sk89q/worldedit/data/OldChunk.java b/src/main/java/com/sk89q/worldedit/data/OldChunk.java index 9f7bd3402..3a2fb8a9c 100644 --- a/src/main/java/com/sk89q/worldedit/data/OldChunk.java +++ b/src/main/java/com/sk89q/worldedit/data/OldChunk.java @@ -33,13 +33,6 @@ import com.sk89q.worldedit.BlockVector; import com.sk89q.worldedit.LocalWorld; import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.blocks.BaseBlock; -import com.sk89q.worldedit.blocks.BlockID; -import com.sk89q.worldedit.blocks.ChestBlock; -import com.sk89q.worldedit.blocks.DispenserBlock; -import com.sk89q.worldedit.blocks.FurnaceBlock; -import com.sk89q.worldedit.blocks.MobSpawnerBlock; -import com.sk89q.worldedit.blocks.NoteBlock; -import com.sk89q.worldedit.blocks.SignBlock; import com.sk89q.worldedit.blocks.TileEntityBlock; /** @@ -185,7 +178,11 @@ public class OldChunk implements Chunk { populateTileEntities(); } - return new CompoundTag("", tileEntities.get(new BlockVector(pos))); + Map values = tileEntities.get(new BlockVector(pos)); + if (values == null) { + return null; + } + return new CompoundTag("", values); } @Override @@ -194,7 +191,7 @@ public class OldChunk implements Chunk { int data = getBlockData(pos); BaseBlock block; - if (id == BlockID.WALL_SIGN || id == BlockID.SIGN_POST) { + /*if (id == BlockID.WALL_SIGN || id == BlockID.SIGN_POST) { block = new SignBlock(id, data); } else if (id == BlockID.CHEST) { block = new ChestBlock(data); @@ -206,13 +203,15 @@ public class OldChunk implements Chunk { block = new MobSpawnerBlock(data); } else if (id == BlockID.NOTE_BLOCK) { block = new NoteBlock(data); - } else { + } else {*/ block = new BaseBlock(id, data); - } + //} if (block instanceof TileEntityBlock) { CompoundTag tileEntity = getBlockTileEntity(pos); - ((TileEntityBlock) block).setNbtData(tileEntity); + if (tileEntity != null) { + ((TileEntityBlock) block).setNbtData(tileEntity); + } } return block;