All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.magistuarmory.misc.ModCreativeTabs Maven / Gradle / Ivy

The newest version!
package com.magistuarmory.misc;

import com.magistuarmory.EpicKnights;
import com.magistuarmory.item.ArmorDecoration;
import com.magistuarmory.item.ModItems;
import dev.architectury.registry.CreativeTabRegistry;
import dev.architectury.registry.registries.DeferredSupplier;
import dev.architectury.registry.registries.RegistrySupplier;
import net.minecraft.class_1761;
import net.minecraft.class_1792;
import net.minecraft.class_1799;
import net.minecraft.class_1802;
import net.minecraft.class_1935;
import net.minecraft.class_2561;
import net.minecraft.class_2960;
import net.minecraft.class_5321;
import net.minecraft.class_7706;
import net.minecraft.class_7924;
import net.minecraft.world.item.*;
import dev.architectury.registry.registries.DeferredRegister;
import java.util.*;
import java.util.function.Supplier;

public class ModCreativeTabs
{
	static Supplier ARMET_WITH_PLUME_SUPPLIER = () -> ModItems.getDecoratedStack(ModItems.ARMET, ModItems.BIG_PLUME_DECORATION);
	static Supplier CEREMONIAL_ARMET_WITH_PLUME_SUPPLIER = () -> ModItems.getDecoratedStack(ModItems.CEREMONIAL_ARMET, ModItems.BIG_PLUME_DECORATION);

	static final DeferredRegister TABS = DeferredRegister.create(EpicKnights.ID, class_7924.field_44688);

	static final RegistrySupplier ARMOR = TABS.register("armor", () -> CreativeTabRegistry.create(
		class_2561.method_43471("itemGroup." + EpicKnights.ID + ".armor"), ARMET_WITH_PLUME_SUPPLIER));
	static final RegistrySupplier WEAPONS = createTab("weapons", ModItems.FLAME_BLADED_SWORDS.iron);
	static final RegistrySupplier PARTICULAR_WEAPONS = createTab("particular_weapons", ModItems.NOBLE_SWORD);
	static final RegistrySupplier SHIELDS = createTab("shields", ModItems.HEATER_SHIELDS.iron);
	static final RegistrySupplier RUSTED = createTab("rusted", ModItems.RUSTED_BASTARD_SWORD);
	static final RegistrySupplier ARMOR_DECORATIONS = createTab("armor_decorations", ModItems.CROWN_DECORATION);

	public static final class_5321 ARMOR_RESOURCE_KEY = class_5321.method_29179(class_7924.field_44688, new class_2960(EpicKnights.ID, "armor"));
	public static final class_5321 WEAPONS_RESOURCE_KEY = class_5321.method_29179(class_7924.field_44688, new class_2960(EpicKnights.ID, "weapons"));
	public static final class_5321 PARTICULAR_WEAPONS_RESOURCE_KEY = class_5321.method_29179(class_7924.field_44688, new class_2960(EpicKnights.ID, "particular_weapons"));
	public static final class_5321 SHIELDS_RESOURCE_KEY = class_5321.method_29179(class_7924.field_44688, new class_2960(EpicKnights.ID, "shields"));
	public static final class_5321 RUSTED_RESOURCE_KEY = class_5321.method_29179(class_7924.field_44688, new class_2960(EpicKnights.ID, "rusted"));
	public static final class_5321 ARMOR_DECORATIONS_RESOURCE_KEY = class_5321.method_29179(class_7924.field_44688, new class_2960(EpicKnights.ID, "armor_decorations"));
	public static final class_5321 INGRIDIENTS_RESOURCE_KEY = class_7706.field_41062;

	public static RegistrySupplier createTab(String name, RegistrySupplier supplier)
	{
		return TABS.register(name, () -> CreativeTabRegistry.create(
				class_2561.method_43471("itemGroup." + EpicKnights.ID + "." + name),
				() -> new class_1799(getIconItem(supplier))));
	}

	public static class_1792 getIconItem(RegistrySupplier supplier)
	{
		if (supplier != null && supplier.get() != null)
			return supplier.get();
		return class_1802.field_8077;
	}

	public static void init()
	{
		TABS.register();

		CreativeTabRegistry.appendStack(ARMOR, ARMET_WITH_PLUME_SUPPLIER);
		append(ARMOR, ModItems.KNIGHT_CHESTPLATE);
		append(ARMOR, ModItems.KNIGHT_LEGGINGS);
		append(ARMOR, ModItems.KNIGHT_BOOTS);
		append(ARMOR, ModItems.STECHHELM);
		append(ARMOR, ModItems.JOUSTING_CHESTPLATE);
		append(ARMOR, ModItems.JOUSTING_LEGGINGS);
		append(ARMOR, ModItems.JOUSTING_BOOTS);
		append(ARMOR, ModItems.SALLET);
		append(ARMOR, ModItems.GOTHIC_CHESTPLATE);
		append(ARMOR, ModItems.GOTHIC_LEGGINGS);
		append(ARMOR, ModItems.GOTHIC_BOOTS);
		append(ARMOR, ModItems.MAXIMILIAN_HELMET);
		append(ARMOR, ModItems.MAXIMILIAN_CHESTPLATE);
		append(ARMOR, ModItems.MAXIMILIAN_LEGGINGS);
		append(ARMOR, ModItems.MAXIMILIAN_BOOTS);
		append(ARMOR, ModItems.CHAINMAIL_HELMET);
		append(ARMOR, ModItems.CHAINMAIL_CHESTPLATE);
		append(ARMOR, ModItems.CHAINMAIL_LEGGINGS);
		append(ARMOR, ModItems.CHAINMAIL_BOOTS);
		append(ARMOR, ModItems.KETTLEHAT);
		append(ARMOR, ModItems.PLATEMAIL_CHESTPLATE);
		append(ARMOR, ModItems.PLATEMAIL_LEGGINGS);
		append(ARMOR, ModItems.PLATEMAIL_BOOTS);
		append(ARMOR, ModItems.BARBUTE);
		append(ARMOR, ModItems.HALFARMOR_CHESTPLATE);
		append(ARMOR, ModItems.GREATHELM);
		append(ARMOR, ModItems.CRUSADER_CHESTPLATE);
		append(ARMOR, ModItems.CRUSADER_LEGGINGS);
		append(ARMOR, ModItems.CRUSADER_BOOTS);
		CreativeTabRegistry.appendStack(ARMOR, CEREMONIAL_ARMET_WITH_PLUME_SUPPLIER);
		append(ARMOR, ModItems.CEREMONIAL_CHESTPLATE);
		append(ARMOR, ModItems.CEREMONIAL_BOOTS);
		append(ARMOR, ModItems.COIF);
		append(ARMOR, ModItems.GAMBESON);
		append(ARMOR, ModItems.PANTYHOSE);
		append(ARMOR, ModItems.GAMBESON_BOOTS);
		append(ARMOR, ModItems.BRIGANDINE);
		append(ARMOR, ModItems.NORMAN_HELMET);
		append(ARMOR, ModItems.SHISHAK);
		append(ARMOR, ModItems.BASCINET);
		append(ARMOR, ModItems.XIV_CENTURY_KNIGHT_CHESTPLATE);
		append(ARMOR, ModItems.XIV_CENTURY_KNIGHT_LEGGINGS);
		append(ARMOR, ModItems.XIV_CENTURY_KNIGHT_BOOTS);
		append(ARMOR, ModItems.WINGED_HUSSAR_CHESTPLATE);
		append(ARMOR, ModItems.BURGONET);
		append(ARMOR, ModItems.CUIRASSIER_CHESTPLATE);
		append(ARMOR, ModItems.CUIRASSIER_LEGGINGS);
		append(ARMOR, ModItems.CUIRASSIER_BOOTS);
		append(ARMOR, ModItems.GRAND_BASCINET);
		append(ARMOR, ModItems.KASTENBRUST_CHESTPLATE);
		append(ARMOR, ModItems.KASTENBRUST_LEGGINGS);
		append(ARMOR, ModItems.KASTENBRUST_BOOTS);
		append(ARMOR, ModItems.FACE_HELMET);
		append(ARMOR, ModItems.LAMELLAR_CHESTPLATE);
		append(ARMOR, ModItems.LAMELLAR_BOOTS);
		append(ARMOR, ModItems.BARDING);
		append(ARMOR, ModItems.CHAINMAIL_HORSE_ARMOR);

		append(PARTICULAR_WEAPONS, ModItems.BLACKSMITH_HAMMER);
		append(PARTICULAR_WEAPONS, ModItems.BARBED_CLUB);
		append(PARTICULAR_WEAPONS, ModItems.PITCHFORK);
		append(PARTICULAR_WEAPONS, ModItems.NOBLE_SWORD);
		append(PARTICULAR_WEAPONS, ModItems.CLUB);
		append(PARTICULAR_WEAPONS, ModItems.MESSER_SWORD);
		append(PARTICULAR_WEAPONS, ModItems.LONGBOW);
		append(PARTICULAR_WEAPONS, ModItems.HEAVY_CROSSBOW);

		append(RUSTED, ModItems.RUSTED_BASTARD_SWORD);
		append(RUSTED, ModItems.RUSTED_HEAVY_MACE);
		append(RUSTED, ModItems.CORRUPTED_ROUND_SHIELD);
		append(RUSTED, ModItems.RUSTED_BARBUTE);
		append(RUSTED, ModItems.RUSTED_HALFARMOR_CHESTPLATE);
		append(RUSTED, ModItems.RUSTED_GREATHELM);
		append(RUSTED, ModItems.RUSTED_CRUSADER_CHESTPLATE);
		append(RUSTED, ModItems.RUSTED_CRUSADER_BOOTS);
		append(RUSTED, ModItems.RUSTED_NORMAN_HELMET);
		append(RUSTED, ModItems.RUSTED_CHAINMAIL_HELMET);
		append(RUSTED, ModItems.RUSTED_CHAINMAIL_CHESTPLATE);
		append(RUSTED, ModItems.RUSTED_CHAINMAIL_LEGGINGS);
		append(RUSTED, ModItems.RUSTED_CHAINMAIL_BOOTS);
		append(RUSTED, ModItems.RUSTED_KETTLEHAT);
		
		for (RegistrySupplier item : ModItems.INSTANCE.ingredientItems)
			append(INGRIDIENTS_RESOURCE_KEY, item);

		for (RegistrySupplier supplier : ModItems.STILETTOS.get())
			append(WEAPONS, supplier);
		for (RegistrySupplier supplier : ModItems.SHORT_SWORDS.get())
			append(WEAPONS, supplier);
		for (RegistrySupplier supplier : ModItems.KATZBALGERS.get())
			append(WEAPONS, supplier);
		for (RegistrySupplier supplier : ModItems.PIKES.get())
			append(WEAPONS, supplier);
		for (RegistrySupplier supplier : ModItems.RANSEURS.get())
			append(WEAPONS, supplier);
		for (RegistrySupplier supplier : ModItems.AHLSPIESSES.get())
			append(WEAPONS, supplier);
		for (RegistrySupplier supplier : ModItems.GIANT_LANCES.get())
			append(WEAPONS, supplier);
		for (RegistrySupplier supplier : ModItems.BASTARD_SWORDS.get())
			append(WEAPONS, supplier);
		for (RegistrySupplier supplier : ModItems.ESTOCS.get())
			append(WEAPONS, supplier);
		for (RegistrySupplier supplier : ModItems.CLAYMORS.get())
			append(WEAPONS, supplier);
		for (RegistrySupplier supplier : ModItems.ZWEIHANDERS.get())
			append(WEAPONS, supplier);
		for (RegistrySupplier supplier : ModItems.FLAME_BLADED_SWORDS.get())
			append(WEAPONS, supplier);
		for (RegistrySupplier supplier : ModItems.LOCHABER_AXES.get())
			append(WEAPONS, supplier);
		for (RegistrySupplier supplier : ModItems.CONCAVE_EDGED_HALBERDS.get())
			append(WEAPONS, supplier);
		for (RegistrySupplier supplier : ModItems.HEAVY_MACES.get())
			append(WEAPONS, supplier);
		for (RegistrySupplier supplier : ModItems.HEAVY_WAR_HAMMERS.get())
			append(WEAPONS, supplier);
		for (RegistrySupplier supplier : ModItems.LUCERNE_HAMMERS.get())
			append(WEAPONS, supplier);
		for (RegistrySupplier supplier : ModItems.MORNINGSTARS.get())
			append(WEAPONS, supplier);
		for (RegistrySupplier supplier : ModItems.FLAILS.get())
			append(WEAPONS, supplier);
		for (RegistrySupplier supplier : ModItems.GUISARMES.get())
			append(WEAPONS, supplier);

		for (RegistrySupplier supplier : ModItems.HEATER_SHIELDS.get())
			append(SHIELDS, supplier);
		for (RegistrySupplier supplier : ModItems.TARGETS.get())
			append(SHIELDS, supplier);
		for (RegistrySupplier supplier : ModItems.BUCKLERS.get())
			append(SHIELDS, supplier);
		for (RegistrySupplier supplier : ModItems.RONDACHES.get())
			append(SHIELDS, supplier);
		for (RegistrySupplier supplier : ModItems.TARTSCHES.get())
			append(SHIELDS, supplier);
		for (RegistrySupplier supplier : ModItems.ELLIPTICAL_SHIELDS.get())
			append(SHIELDS, supplier);
		for (RegistrySupplier supplier : ModItems.ROUND_SHIELDS.get())
			append(SHIELDS, supplier);
		for (RegistrySupplier supplier : ModItems.PAVISES.get())
			append(SHIELDS, supplier);
		for (RegistrySupplier supplier : ModItems.KITE_SHIELDS.get())
			append(SHIELDS, supplier);
		
		for (RegistrySupplier supplier : ModItems.INSTANCE.armorDecorationItems)
			append(ARMOR_DECORATIONS, () -> supplier.get().method_8389());
	}

	@SafeVarargs
	public static > void append(class_5321 tab, T... items)
	{
		Arrays.stream(items).filter(Objects::nonNull).forEach((item) -> CreativeTabRegistry.append(tab, item));
	}
	
	@SafeVarargs
	public static > void append(DeferredSupplier tab, T... items)
	{
		Arrays.stream(items).filter(Objects::nonNull).forEach((item) -> CreativeTabRegistry.append(tab, item));
	}
}