Add item groups (aka creative tabs)#1866
Conversation
| * | ||
| * @return The item group or {@link Optional#empty()} otherwise | ||
| */ | ||
| Optional<ItemGroup> getItemGroup(); |
There was a problem hiding this comment.
Remove this method - it be can retrieved from getItem() instead.
| * | ||
| * @return The item group or {@link Optional#empty()} otherwise | ||
| */ | ||
| Optional<ItemGroup> getItemGroup(); |
There was a problem hiding this comment.
An item can be in multiple groups.
There was a problem hiding this comment.
Quite possibly needs to be a Collection<ItemGroup>, since Collections.empty() is easy to call.
| * Represents an item group, or creative tab. | ||
| */ | ||
| @CatalogedBy(ItemGroups.class) | ||
| public interface ItemGroup extends CatalogType, Translatable {} |
There was a problem hiding this comment.
Braces on different lines and leave a blank line between. Also, can the icon of the item group be exposed?
There was a problem hiding this comment.
You should add a method to see if an item is in this item group possibly.
There was a problem hiding this comment.
Unfortunately, item group icons are client only.
There was a problem hiding this comment.
At the very least, make the class ending brace on a new line and leave an empty line in the middle.
|
|
||
| public static final ItemGroup TRANSPORTATION = DummyObjectProvider.createFor(ItemGroup.class, "TRANSPORTATION"); | ||
|
|
||
| // SORTFIELDS:OFF |
There was a problem hiding this comment.
You missed the SEARCH item group.
There was a problem hiding this comment.
Yes, SEARCH, along with HOTBAR and INVENTORY, were skipped because they are not so much item groups as they are creative tabs.
There was a problem hiding this comment.
Are you attempting to expose the tab itself, for say, GUI click events.
Or are you attempting to expose the property of items to belong to a creative tab?
There was a problem hiding this comment.
Yeah, just exposing the property of items to belong to an item group.
| * Represents an item group, or creative tab. | ||
| */ | ||
| @CatalogedBy(ItemGroups.class) | ||
| public interface ItemGroup extends CatalogType, Translatable {} |
There was a problem hiding this comment.
At the very least, make the class ending brace on a new line and leave an empty line in the middle.
| import org.spongepowered.api.util.annotation.CatalogedBy; | ||
|
|
||
| /** | ||
| * Represents an item group, or creative tab. |
There was a problem hiding this comment.
How would this compare to being used? They're just signified by where they show on clients? There's otherwise no other usable functionality to gain from this, right?
There was a problem hiding this comment.
Should document by answering these questions in some sense. That will fill out the javadoc for this class.
| import org.spongepowered.api.util.generator.dummy.DummyObjectProvider; | ||
|
|
||
| /** | ||
| * An enumeration of all possible {@link ItemGroup}s in vanilla minecraft. |
There was a problem hiding this comment.
Maybe phrase it as An enumeration of the known vanilla {@link ItemGroup}s in Minecraft. Mods may change and/or introduce new groups at runtime.
| * | ||
| * @return The item group or {@link Optional#empty()} otherwise | ||
| */ | ||
| Optional<ItemGroup> getItemGroup(); |
There was a problem hiding this comment.
Quite possibly needs to be a Collection<ItemGroup>, since Collections.empty() is easy to call.
|
~wip |
|
~qa |
|
@gbui Can you offer some usecases? At the moment, without any sample usecases, or user stories, I'm not sure whether this API is sufficient or not. I like that you have the possibility for an item to be in multiple groups. @gabizou I'm not sold on ItemCollection as a name, it adds confusion with Java's Collections to make it seem like it's related to the Collections API / interfaces / classes. |
|
Why just not name it |
|
@ryantheleach A sample usecase could be creating an in-game shopping catalog, organized by item group. This would make it easier for players to navigate the interface (which in this case would be an inventory "GUI"). @XakepSDK I went with |
|
@XakepSDK It's worth noting that we've renamed |
|
@gbui That makes sense to me. Thanks. |
SpongeAPI | SpongeCommon | SpongeForge
ItemGroupinterface, cataloged byItemGroupsOptional<ItemGroup> getItemGroup()toBlockTypeandItemTypeGranted, creative tabs are not super important on the server, but it could be useful, for example, for detecting mod-added tabs.
have mercy on me, this is my first sponge pull request