Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.