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.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<String, Tag> 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;

View File

@ -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<String, Tag> 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;