API to allow for adding additional Creative Tabs
2xsaiko opened this issue ยท 17 comments
Vanilla MC can only handle 12 creative tabs (the already existing ones). There's no support for additional ones, which a lot of mods will surely want to add.
Implementing the logic should be relatively easy, there needs to be a method to create a new ItemGroup which also resizes the ItemGroup.GROUPS array (it's only 12 in size by default) to allow storing the newly created group. That should be everything that's needed to get this part to work.
Creative inventory UI will be a bit more difficult. There's a couple approaches I've thought of that can be taken:
-
The Forge approach:
Just add two buttons that switch between the creative tabs currently displayed, like Forge does. This is kind of ugly imo, since the two buttons don't fit into the rest of the GUI. -
Scroll bar:
Move all the creative tab buttons (except search & inventory ones) into a list on one side of the inventory gui, and add a scroll bar to it. This would look way nicer, and would be more user friendly in my opinion (dragging the mouse lets you scroll way faster to search for a tab than clicking a button a gajillion times, depending on how many mods are installed). Something like this would do the trick, I think. (I haven't moved the three tabs that are special, the search, saved items, and player inventory tab, these could either stay where they are, move to either the top or bottom completely, or just get added into the list too, which would probably be the easiest to handle.)
Thoughts? :P
2 Buttons - Is good as it would be easy to implement, but as you said it is ugly and not very user friendly.
Scroll - That screenshot looks really good! And I feel like it doesn't move too far away from vanilla MC. One thing I would suggest is to default back to vanilla when there are no extra item groups added. I think keeping the 3 special buttons as is its fine.
I think the API should exist in Fabric but the GUI shouldn't be included. Similar to Mod Menu, different mods could have their own takes on ways to display the tabs.
Also, this is just my opinion, but I believe mods should try to reuse vanilla tabs if possible. A mod with 4 new item doesn't need it's own tab. Also a lot of mod-divided tabs ruins a bit of the immersion.
But then you'd have to install a mod just to make it display more tabs than the default, which you almost always want unless you don't have mods installed that add blocks/items. I'd prefer modmuss's suggestion - displaying the original tab layout, in case they fit.
Of course, other mods can always override the GUI if they want, just like they can in Forge, but there should be a reasonable default implementation
Unlike mod menu there can only be one creative gui, I understand what you are saying however. Once option would be to have the API for adding new creative tabs, and possibly a default implementation in fabric, and then a way to allow other mods to come in and replace it.
Im not sure if this is over-complicating it however.
The creative GUI is something that all mods that add a block or item usually use so having an built in solution might come in handy.
Ok, Fabric should have an API method to revert the GUI to vanilla then IMO and I would be fine with that.
I agree with having an overrideable default implementation. IMO it should be as close to vanilla as possible (The two button version).
Yeah, one other idea would be to have a basic forge like version with the two button that just adds to the creative tab, and then have the fancy version as a separate mod. By the sounds of it this would be the preferred idea.
The two button one is annoying to use though and looks less vanilla/more out of place than the one I made (of course, I wouldn't say no to different suggestions for how it could look :P)
What about sub-categories under the existing vanilla ones? The vanilla kinda covers most themes already... sub-categories could fix the massive amount of items in each
I agree it looks good but if there's no mods that add a tab, the layout should be identical to vanilla.
What about sub-categories under the existing vanilla ones? The vanilla kinda covers most themes already... sub-categories could fix the massive amount of items in each
Interesting idea, how would you handle mods whose items don't fit under one of the existing tabs, like some tech mod, though? Let's take IC2 for example, the closest I would put it under would be Redstone, but that doesn't quite fit in most cases. Or have this as an addition, because this would also fix some mods having like 4 tabs for each category of their items, instead they could just have one tab and some subcategories instead, so they take up less space overall. And then just have a small dropdown arrow that pops up a list with clickable subcategories or something.
This might take it a bit too far though, because in addition to rendering code, more logic code would have to be added to allow for this ;)
Might not be too bad though, idk
I agree it looks good but if there's no mods that add a tab, the layout should be identical to vanilla.
Yeah, I agree with that, because if they all fit, the existing one is actually easier to use since you don't have to scroll at all
I think that a default implementation should be fine provided that there are hooks for mods to replace it with their own, or at the very least make it friendly to Mixins.
I think sub categories might not be the best idea (in another add on possibly) this is because right now its easy to add your item to any creative tab, the methods are already there. Adding sub categories would require a whole new api.
Categories might be great for a mod pack maker who has the time and energy to go though and put stuff into them.
I'd personally love to see mods categorize their own pages similar to curse discovery: Adventure, Armor/Tools, Magic, Tech, Storage, Cosmetic, something like that. That'd help users drill straight down into what they need, and whoever provided the gui for it would quickly become a must-have QoL mod.
It'd be a tiny extra step for the modder to supply category information. Imagine:
Vanilla tabs all become part of a dedicated "vanilla" category.
Modders register a page something like ItemGroup someTechBlocks = ItemGroup.register("tech", new ItemGroup(0, "modname_sometechblocks")); //the tab index is ignored and assigned to the first free slot
, understanding that the mod would provide localization keys at itemgroup.modname_sometechblocks
and itemgroup_category.tech
. For the category key, many mods might provide the same localization key and that's fine. Not a lot harder than sticking blocks onto the end of existing tabs, and if you want to do that you still can.
If no mods add item pages, use the vanilla creative GUI.
If mods add item pages, a barebones Fabric-module-provided two-arrow view into the flat pages (higher-level "page category" information is present but ignored)
A mod can replace this default implementation, and has the option to honor this tiered information and present pages within categories, add scrollbars, etc. as it sees fit. This part will need to be a whole API regardless of whether it's simple or fancy, but we'll need to be able to replace other GUIs for e.g. baubles menus, so the benefit may be shared.
Finally, under any implementation there'd need to be a contractual understanding that creative tabs should never change after a certain point, and that point should be known so that alternate menu mods could build and cache a category map by querying the tabs.
See #44
@asiekierka I think this can be closed