Skip to content

Commit

Permalink
Add new items to item groups
Browse files Browse the repository at this point in the history
  • Loading branch information
Juuxel committed Jul 21, 2023
1 parent ca41b7e commit 9a5d69a
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/main/java/juuxel/woodsandmires/item/WamItemGroups.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
import net.minecraft.item.Item;
import net.minecraft.item.ItemConvertible;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemGroups;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;

import java.util.Arrays;
import java.util.List;
import java.util.function.Predicate;

public final class WamItemGroups {
public static void init() {
Expand Down Expand Up @@ -61,6 +65,18 @@ public static void init() {
WamItems.PINE_BOAT,
WamItems.PINE_CHEST_BOAT);
});
ItemGroupEvents.modifyEntriesEvent(ItemGroups.INGREDIENTS).register(entries -> {
addBefore(entries, stack -> stack.isOf(Items.ENCHANTED_BOOK),
WamItems.PINE_CONE);
});
ItemGroupEvents.modifyEntriesEvent(ItemGroups.FOOD_AND_DRINK).register(entries -> {
entries.add(WamItems.PINE_CONE_JAM);
});
}

private static void addBefore(FabricItemGroupEntries entries, Predicate<ItemStack> predicate, ItemConvertible... items) {
var stacks = Arrays.stream(items).map(ItemStack::new).toList();
entries.addBefore(predicate, stacks, ItemGroup.StackVisibility.PARENT_AND_SEARCH_TABS);
}

private static void addAfterFirstEnabled(FabricItemGroupEntries entries, List<Item> after, ItemConvertible... items) {
Expand Down

0 comments on commit 9a5d69a

Please sign in to comment.