Why don't you move this code directly into `cBlockEntityWithItems::OnSlotChanged()`? It makes sense - all block entities should update their UI when their slots are changed.