ActuallyAdditions/src/main/java/de/ellpeck/actuallyadditions/mod/ActuallyTabs.java

37 lines
1.5 KiB
Java
Raw Normal View History

2024-03-03 01:20:53 +01:00
package de.ellpeck.actuallyadditions.mod;
import de.ellpeck.actuallyadditions.mod.items.ActuallyItems;
import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy;
import net.minecraft.core.registries.Registries;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.CreativeModeTabs;
import net.minecraft.world.item.ItemStack;
2024-03-04 20:21:48 +01:00
import net.neoforged.bus.api.IEventBus;
import net.neoforged.neoforge.registries.DeferredRegister;
2024-03-03 01:20:53 +01:00
import java.util.List;
import java.util.function.Supplier;
public class ActuallyTabs {
public static final DeferredRegister<CreativeModeTab> CREATIVE_MODE_TABS = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, ActuallyAdditions.MODID);
public static final Supplier<CreativeModeTab> GROUP = CREATIVE_MODE_TABS.register("tab", () -> CreativeModeTab.builder()
.icon(() -> ActuallyItems.ITEM_BOOKLET.get().getDefaultInstance())
.withTabsBefore(CreativeModeTabs.SPAWN_EGGS)
.title(Component.translatable("itemGroup.actuallyadditions"))
.displayItems((parameters, output) -> {
List<ItemStack> stacks = ActuallyItems.ITEMS.getEntries().stream().map(reg -> new ItemStack(reg.get())).toList();
stacks.forEach(stack -> {
if(stack.getItem() instanceof ItemEnergy itemEnergy) {
stack.getOrCreateTag().putDouble("Energy", itemEnergy.getMaxEnergyStored(stack));
}
});
output.acceptAll(stacks);
}).build());
public static void init(IEventBus evt) {
CREATIVE_MODE_TABS.register(evt);
}
}