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

Hi,

mods like Tinkers Construct and Galacticraft add custom Inventory Tabs (like the ones in creative) to the players survival inventory. Making all these differnt mod tabs compatible with each other takes a lot of time for the mod authors or is not even possible if the one or more of the mods is not open source. If it is open source it takes a long time to look through the other modders code.

 

It would be awesome if Forge could provide an easy way to add Tabs to the survival inventory in order to solve this problem.

 

 

I solved the problem by using Java reflection, but it would be really useful if you could make GuiScreen.buttonList a public field.

 

 

Define tabs.

 

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

He is talking about buttons added to the inventory GUI, with a matching design like the icons for creative inventory.

The only thing that Forge could do to ease the process would be to make GuiScreen.buttonList public.

I know what he's talking about, I want him to think about his proposal more and come back with something more fleshed out about how it would be done.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

  • Author

The only thing that Forge could do to ease the process would be to make GuiScreen.buttonList public.

 

That would be really helpful. I had a more detailed look at TinkersConstruct´s TabRegistry class and that is the code they use to add their Tab buttons to the inventory screen (called when the inventory key is used):

 

public static void addTabsToInventory (GuiContainer gui)
    {
        if (gui.getClass() == GuiInventory.class)
        {
            // Values are public at runtime.
            int cornerX = gui.xSize;
            int cornerY = gui.guiTop;
            gui.buttonList.clear();

            updateTabValues(cornerX, cornerY, InventoryTabVanilla.class);
            addTabsToList(gui.buttonList);
        }
    }

public static void updateTabValues (int cornerX, int cornerY, Class<?> selectedButton)
    {
        int count = 2;
        for (int i = 0; i < tabList.size(); i++)
        {
            AbstractTab t = tabList.get(i);

            if (t.shouldAddToList())
            {
                t.id = count;
                t.xPosition = cornerX + (count - 2) * 28;
                t.yPosition = cornerY - 28;
                t.enabled = !t.getClass().equals(selectedButton);
                count++;
            }
        }
    }

    public static void addTabsToList (List buttonList)
    {
        for (AbstractTab tab : tabList)
        {
            if (tab.shouldAddToList())
            {
                buttonList.add(tab);
            }
        }
    }

 

Here is the full class:

https://github.com/SlimeKnights/TinkersConstruct/blob/master/src/main/java/tconstruct/client/tabs/TabRegistry.java

 

As the comment says the values are all public at runtime. I must admit that I am just coding Java for a year now and have no direct idea on how this is handled at runtime, but as

GuiInventory.xSize
GuiInventory.ySize
GuiInventory.guiTop
GuiInventory.guiBottom
GuiInventory.buttonList

are not public fields there is no direct way to use them (without working around it).

 

I would like to suggest making these fields "public" unless you see a problem in doing this. (I don´t know if there is a reason they are not public yet?)

   

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.