2021-03-01 11:56:30 +01:00
|
|
|
package com.minelittlepony.unicopia.item;
|
|
|
|
|
2022-09-30 14:52:26 +02:00
|
|
|
import java.util.function.Supplier;
|
2021-03-01 11:56:30 +01:00
|
|
|
|
2022-09-30 14:52:26 +02:00
|
|
|
import com.minelittlepony.unicopia.UTags;
|
2022-08-27 15:14:00 +02:00
|
|
|
import com.minelittlepony.unicopia.Unicopia;
|
2022-09-30 12:43:07 +02:00
|
|
|
import com.minelittlepony.unicopia.item.toxin.Toxic;
|
2021-03-01 11:56:30 +01:00
|
|
|
import com.minelittlepony.unicopia.item.toxin.ToxicHolder;
|
|
|
|
import net.minecraft.item.Item;
|
|
|
|
import net.minecraft.item.ItemGroup;
|
|
|
|
import net.minecraft.item.ItemStack;
|
2022-03-26 22:51:34 +01:00
|
|
|
import net.minecraft.item.Items;
|
2022-09-30 14:52:26 +02:00
|
|
|
import net.minecraft.tag.TagKey;
|
2021-03-01 11:56:30 +01:00
|
|
|
import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder;
|
|
|
|
import net.minecraft.util.collection.DefaultedList;
|
|
|
|
import net.minecraft.util.registry.Registry;
|
|
|
|
|
|
|
|
public interface UItemGroups {
|
2022-08-27 15:14:00 +02:00
|
|
|
ItemGroup ALL_ITEMS = FabricItemGroupBuilder.create(Unicopia.id("items")).appendItems(list -> {
|
2022-03-26 22:51:34 +01:00
|
|
|
list.add(Items.APPLE.getDefaultStack());
|
2021-03-01 11:56:30 +01:00
|
|
|
|
|
|
|
DefaultedList<ItemStack> defs = DefaultedList.of();
|
|
|
|
UItems.ITEMS.stream()
|
|
|
|
.filter(item -> !(item instanceof ChameleonItem) || ((ChameleonItem)item).isFullyDisguised())
|
2022-09-30 12:43:07 +02:00
|
|
|
.forEach(item -> item.appendStacks(ItemGroup.SEARCH, defs));
|
2021-03-01 11:56:30 +01:00
|
|
|
list.addAll(defs);
|
|
|
|
}).icon(UItems.EMPTY_JAR::getDefaultStack).build();
|
2022-08-27 15:14:00 +02:00
|
|
|
ItemGroup HORSE_FEED = FabricItemGroupBuilder.create(Unicopia.id("horsefeed")).appendItems(list -> {
|
2021-03-01 11:56:30 +01:00
|
|
|
list.addAll(Registry.ITEM.stream()
|
|
|
|
.map(Item::getDefaultStack)
|
2022-09-30 14:52:26 +02:00
|
|
|
.filter(stack -> ((ToxicHolder)stack.getItem()).getToxic(stack) != Toxic.EMPTY)
|
|
|
|
.toList());
|
2021-03-01 11:56:30 +01:00
|
|
|
}).icon(UItems.ZAP_APPLE::getDefaultStack).build();
|
|
|
|
|
2022-09-30 14:52:26 +02:00
|
|
|
ItemGroup EARTH_PONY_ITEMS = forTag("earth_pony", UItems.APPLE_PIE::getDefaultStack);
|
|
|
|
ItemGroup UNICORN_ITEMS = forTag("unicorn", UItems.SPELLBOOK::getDefaultStack);
|
|
|
|
ItemGroup PEGASUS_ITEMS = forTag("pegasus", UItems.PEGASUS_FEATHER::getDefaultStack);
|
|
|
|
ItemGroup BAT_PONY_ITEMS = forTag("bat_pony", UItems.SUNGLASSES::getDefaultStack);
|
|
|
|
ItemGroup CHANGELING_ITEMS = forTag("changeling", Items.SCULK_SHRIEKER::getDefaultStack);
|
|
|
|
|
|
|
|
static ItemGroup forTag(String name, Supplier<ItemStack> icon) {
|
|
|
|
TagKey<Item> key = UTags.item("groups/" + name);
|
|
|
|
return FabricItemGroupBuilder.create(Unicopia.id(name)).appendItems(list -> {
|
|
|
|
list.addAll(Registry.ITEM.getEntryList(key)
|
|
|
|
.stream()
|
|
|
|
.flatMap(named -> named.stream())
|
|
|
|
.map(entry -> entry.value())
|
|
|
|
.map(Item::getDefaultStack)
|
|
|
|
.toList());
|
|
|
|
}).icon(icon).build();
|
|
|
|
}
|
|
|
|
|
2021-03-01 11:56:30 +01:00
|
|
|
static void bootstrap() {}
|
|
|
|
}
|