@Override
public void onDraw(Canvas canvas) {
int numSlots = Math.min(InventoryUtils.getSlotCount(getTargetEntity()) - getCellOffset(), getMaxCellCount());
if (numSlots != 0 && !cells.isEmpty()) {
Vector2i cellSize = canvas.calculatePreferredSize(cells.get(0));
int horizontalCells = Math.min(maxHorizontalCells, canvas.size().getX() / cellSize.getX());
for (int i = 0; i < numSlots && i < cells.size(); ++i) {
int horizPos = i % horizontalCells;
int vertPos = i / horizontalCells;
canvas.drawWidget(cells.get(i), Rect2i.createFromMinAndSize(horizPos * cellSize.x, vertPos * cellSize.y, cellSize.x, cellSize.y));
}