Fixed chunk loading code not properly handling tile entity data.

This commit is contained in:
sk89q 2012-08-24 16:50:32 -07:00
parent 6a162a4269
commit 3b59798f37
2 changed files with 22 additions and 24 deletions

View File

@ -15,13 +15,6 @@ import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldedit.LocalWorld; import com.sk89q.worldedit.LocalWorld;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.BaseBlock; 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; import com.sk89q.worldedit.blocks.TileEntityBlock;
public class AnvilChunk implements Chunk { public class AnvilChunk implements Chunk {
@ -187,7 +180,11 @@ public class AnvilChunk implements Chunk {
populateTileEntities(); populateTileEntities();
} }
return new CompoundTag("", tileEntities.get(new BlockVector(pos))); Map<String, Tag> values = tileEntities.get(new BlockVector(pos));
if (values == null) {
return null;
}
return new CompoundTag("", values);
} }
@Override @Override
@ -196,7 +193,7 @@ public class AnvilChunk implements Chunk {
int data = getBlockData(pos); int data = getBlockData(pos);
BaseBlock block; 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); block = new SignBlock(id, data);
} else if (id == BlockID.CHEST) { } else if (id == BlockID.CHEST) {
block = new ChestBlock(data); block = new ChestBlock(data);
@ -208,14 +205,16 @@ public class AnvilChunk implements Chunk {
block = new MobSpawnerBlock(data); block = new MobSpawnerBlock(data);
} else if (id == BlockID.NOTE_BLOCK) { } else if (id == BlockID.NOTE_BLOCK) {
block = new NoteBlock(data); block = new NoteBlock(data);
} else { } else {*/
block = new BaseBlock(id, data); block = new BaseBlock(id, data);
} //}
if (block instanceof TileEntityBlock) { if (block instanceof TileEntityBlock) {
CompoundTag tileEntity = getBlockTileEntity(pos); CompoundTag tileEntity = getBlockTileEntity(pos);
if (tileEntity != null) {
((TileEntityBlock) block).setNbtData(tileEntity); ((TileEntityBlock) block).setNbtData(tileEntity);
} }
}
return block; return block;
} }

View File

@ -33,13 +33,6 @@ import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldedit.LocalWorld; import com.sk89q.worldedit.LocalWorld;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.BaseBlock; 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; import com.sk89q.worldedit.blocks.TileEntityBlock;
/** /**
@ -185,7 +178,11 @@ public class OldChunk implements Chunk {
populateTileEntities(); populateTileEntities();
} }
return new CompoundTag("", tileEntities.get(new BlockVector(pos))); Map<String, Tag> values = tileEntities.get(new BlockVector(pos));
if (values == null) {
return null;
}
return new CompoundTag("", values);
} }
@Override @Override
@ -194,7 +191,7 @@ public class OldChunk implements Chunk {
int data = getBlockData(pos); int data = getBlockData(pos);
BaseBlock block; 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); block = new SignBlock(id, data);
} else if (id == BlockID.CHEST) { } else if (id == BlockID.CHEST) {
block = new ChestBlock(data); block = new ChestBlock(data);
@ -206,14 +203,16 @@ public class OldChunk implements Chunk {
block = new MobSpawnerBlock(data); block = new MobSpawnerBlock(data);
} else if (id == BlockID.NOTE_BLOCK) { } else if (id == BlockID.NOTE_BLOCK) {
block = new NoteBlock(data); block = new NoteBlock(data);
} else { } else {*/
block = new BaseBlock(id, data); block = new BaseBlock(id, data);
} //}
if (block instanceof TileEntityBlock) { if (block instanceof TileEntityBlock) {
CompoundTag tileEntity = getBlockTileEntity(pos); CompoundTag tileEntity = getBlockTileEntity(pos);
if (tileEntity != null) {
((TileEntityBlock) block).setNbtData(tileEntity); ((TileEntityBlock) block).setNbtData(tileEntity);
} }
}
return block; return block;
} }