With boxes do you mean slots?
when you add a slot to your container like such:
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 9; j++) {
addSlotToContainer(new Slot(playerInv, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
}
}
you're doing the following: You add 3 rows with each 9 slots. Every time i increases it goes 18 pixels down (slots are 18 big, 2 pixels around the 16 width item.) and every time j increases it goes 18 pixels to the right for the same reasons.
The second value is the index, this is increased by 1 for every new slot basically. So every i adds 9, every j adds 1.
addSlotToContainer(new Slot(inventoryToUse, slotIndex, xCoordinate, yCoordinate));
basically the slotindex is the index of the slot within the inventory. Vanilla inventory uses 0-35 for the items with 0-8 being the hotbar. slots 35-38 are armour.
the xCoordinate is the spot within your GUI where you want to put your slot. The y Coordinate is the height from the top where your slot is.
When you draw your Container the point '0' in x and y are the top left corner. in the GuiContainer (client side) you want to make your own 0 point, since 0 is the top left corner of the screen, not the gui.
You have already declared the two variables for x and y in your gui using the following code however :
int x = (width - xSize) / 2;
int y = (height - ySize) / 2;
so if you want something in the GuiContainer to be 15 pixels to the right and 10 pixels down(From the top left corner of your gui) you want to use
drawTexturedModalRect(x+15, y+10, startOfTextureX, startOfTextureY, rectWidth, rectHeight);
obviously if you want something to be in the corner of the screen you can just use 0 instead of x+number
To clarify. the Container is your class extending container. the GuiContainer is the class extending GuiContainer. You probably know this. I'm just clarifying.