Fabric API

Fabric API

106M Downloads

[fabric-item-groups] Feature request: add a way to not overwrite the vanilla behaviour of appendStacks

UpcraftLP opened this issue ยท 3 comments

commented

currently, when using FabricItemGroupBuilder#stacksForDisplay() the vanilla behaviour of adding all items that have this itemgroup is replaced with a completely custom list.

My suggestion is to add another overload with a boolean flag, that only replaces the items when set to true (default value to not break backwards compatibility).

the current implementation would then just call the new one with the default value.

commented

This is not applicable to 1.19.3 anymore.

commented

I would add onto this, and request a FabricItemGroupBuilder#build(BiFunction<Integer, String, ItemGroup>) to be added, so that we can use custom item group implementations (for eg. specific item display customization). Currently, if we want to use something else than Fabric API's implementation, we have to either use the internal interface ItemGroupExtensions, or copy the internals entirely.

commented

While FabricItemGroupBuilder#stacksForDisplay() is now deprecated, the method that replaced it is no better. I would also like to see the appendItems() method actually append rathen then replace. I should add, though, that a current workaround would be to add something like Registry.ITEM.stream().filter(isInThisGroup()).map(ItemStack::new).forEach(itemList::add); to the beginning of the Consumer, thus placing any existing group members back into the list before replacing it.

/**
* This allows for a custom list of items to be displayed in a tab, this enabled tabs to be created with a custom set of items.
*
* @param stacksForDisplay Add ItemStack's to this list to show in the ItemGroup
* @return a reference to the FabricItemGroupBuilder
*/
public FabricItemGroupBuilder appendItems(Consumer<List<ItemStack>> stacksForDisplay) {
this.stacksForDisplay = stacksForDisplay;
return this;
}