Search in sources :

Example 1 with ISortableItem

use of stevekung.mods.moreplanets.util.items.ISortableItem in project MorePlanets by SteveKunG.

the class CommonRegisterHelper method registerSorted.

public static void registerSorted(Item item) {
    if (item instanceof ISortableItem) {
        ISortableItem sortableItem = (ISortableItem) item;
        NonNullList<ItemStack> items = NonNullList.create();
        item.getSubItems(MorePlanetsCore.ITEM_TAB, items);
        for (ItemStack itemStack : items) {
            EnumSortCategoryItem categoryItem = sortableItem.getItemCategory(itemStack.getItemDamage());
            if (!CommonRegisterHelper.SORT_MAP_ITEMS.containsKey(categoryItem)) {
                CommonRegisterHelper.SORT_MAP_ITEMS.put(categoryItem, new ArrayList<>());
            }
            CommonRegisterHelper.SORT_MAP_ITEMS.get(categoryItem).add(new StackSorted(itemStack.getItem(), itemStack.getItemDamage()));
        }
    } else if (item.getCreativeTab() == MorePlanetsCore.ITEM_TAB) {
        throw new RuntimeException(item.getClass() + " must inherit " + ISortableItem.class.getSimpleName() + "!");
    }
}
Also used : ISortableItem(stevekung.mods.moreplanets.util.items.ISortableItem) EnumSortCategoryItem(stevekung.mods.moreplanets.util.items.EnumSortCategoryItem) StackSorted(micdoodle8.mods.galacticraft.core.util.StackSorted) ItemStack(net.minecraft.item.ItemStack)

Aggregations

StackSorted (micdoodle8.mods.galacticraft.core.util.StackSorted)1 ItemStack (net.minecraft.item.ItemStack)1 EnumSortCategoryItem (stevekung.mods.moreplanets.util.items.EnumSortCategoryItem)1 ISortableItem (stevekung.mods.moreplanets.util.items.ISortableItem)1