@Override
public boolean setBlock(Vector position, BaseBlock block, boolean notifyAndLight) throws WorldEditException {
checkNotNull(position);
checkNotNull(block);
World world = getWorldChecked();
int x = position.getBlockX();
int y = position.getBlockY();
int z = position.getBlockZ();
// First set the block
Chunk chunk = world.getChunkFromChunkCoords(x >> 4, z >> 4);
int previousId = 0;
if (notifyAndLight) {
previousId = Block.getIdFromBlock(chunk.getBlock(x & 15, y, z & 15));
}
boolean successful = chunk.func_150807_a(x & 15, y, z & 15, Block.getBlockById(block.getId()), block.getData());
// Create the TileEntity
if (successful) {
CompoundTag tag = block.getNbtData();
if (tag != null) {
NBTTagCompound nativeTag = NBTConverter.toNative(tag);
nativeTag.setString("id", block.getNbtId());
TileEntityUtils.setTileEntity(getWorld(), position, nativeTag);
}
}
if (notifyAndLight) {
world.func_147451_t(x, y, z);
world.markBlockForUpdate(x, y, z);
world.notifyBlockChange(x, y, z, Block.getBlockById(previousId));
Block mcBlock = Block.getBlockById(previousId);
if (mcBlock != null && mcBlock.hasComparatorInputOverride()) {
world.func_147453_f(x, y, z, Block.getBlockById(block.getId()));
}
}
return successful;
}