Jump to content

[Help - 1.8] Drawing Slots respective to width/height?


Recommended Posts

Posted

I feel like I am being a moron...

 

is the location that each Slot is drawn in a custom GUI determined from the custom container?

I have dug through the source code and the only mention of coordinates I can find about drawing the slots is from the container class.

 


 

With that being said:

 

  • What exactly are the coordinates measured in? I presume pixels, but where from - the origin?
  • In the GUI class, it is possible to reference width and height, so that you can draw each box relative to the screen size... however, if you aren't drawing the slots relative to this, there isn't much point
  • Is there a way to draw slots onto a gui respective to the size of the clients screen?

 

Essentially, I have multiple GUI components that have different widths/heights and would like them all (and their corresponding slot spaces) to be in the centre of the clients screen. This is easy for the GUI components (width / height), but I cant figure out how to achieve it with slots. 

 

Thanks in advance.

 


 

From CustomContainer (extends Container.class)

 

 

for (int i = 0; i < 3; ++i)
        {
            for (int j = 0; j < 9; ++j)
            {
                addSlotToContainer(new Slot(parInventoryPlayer, j+i*9+9, 
                8+j*18, 184+i*18));
            }
        }

 

 

 

From Container.class:

 

 

protected Slot addSlotToContainer(Slot slotIn)
    {
        slotIn.slotNumber = this.inventorySlots.size();
        this.inventorySlots.add(slotIn);
        this.inventoryItemStacks.add((Object)null);
        return slotIn;
    }

 

 

 

From Slot.class:

 

 

public Slot(IInventory inventoryIn, int index, int xPosition, int yPosition)
    {
        this.inventory = inventoryIn;
        this.slotIndex = index;
        this.xDisplayPosition = xPosition;
        this.yDisplayPosition = yPosition;
    }

 

 

 

 

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.