A way to sort mod items in creative tabs.
BasicallyIAmFox opened this issue ยท 2 comments
A lot of mods are vanilla-like, quality of life, etch, and so most of them add some content like blocks and items. Modders might want to put their X item next to Y vanilla item. There loads of examples where modders would want to put their items next to vanilla items, like custom froglights next to vanilla, custom wool/dyes next to vanilla, custom coral types next to vanilla, new plant seeds next to vanilla, and there's much more examples.
Not sure if such (complex?) suggestion would work for Fabric tho. (as Fabric considered as lightweight iirc)
You can do this yourself, just override Item.appendStacks() for your item.
This method is normally used to create multiple creative mode itemstacks for your item, e.g. potions
public static final Item TEST = Registry.register(Registry.ITEM, new Identifier(modid, "test"),
new Item(new Item.Settings().group(ItemGroup.BUILDING_BLOCKS)) {
@Override
public void appendStacks(ItemGroup group, DefaultedList<ItemStack> stacks) {
// place directly after minecraft:stone
int index = findIndex(stacks, Items.STONE);
stacks.add(index + 1, new ItemStack(this));
}
});
private static int findIndex(List<ItemStack> stacks, Item item) {
for (var i = 0; i < stacks.size(); ++i) {
if (stacks.get(i).isOf(item)) {
return i;
}
}
return -1;
}
๐ We use the issue tracker exclusively for final bug reports and feature requests. However, this issue appears to be better suited for either a discussion thread, or a message on our discord server. Please post your request on one of these, and the conversation can continue there.