Search in sources :

Example 1 with EnumSortCategoryItem

use of micdoodle8.mods.galacticraft.core.util.EnumSortCategoryItem in project Galacticraft by micdoodle8.

the class GCItems method finalizeSort.

public static void finalizeSort() {
    List<StackSorted> itemOrderListItems = Lists.newArrayList();
    for (EnumSortCategoryItem type : EnumSortCategoryItem.values()) {
        itemOrderListItems.addAll(sortMapItems.get(type));
    }
    Comparator<ItemStack> tabSorterItems = Ordering.explicit(itemOrderListItems).onResultOf(input -> new StackSorted(input.getItem(), input.getItemDamage()));
    GalacticraftCore.galacticraftItemsTab.setTabSorter(tabSorterItems);
}
Also used : EnumSortCategoryItem(micdoodle8.mods.galacticraft.core.util.EnumSortCategoryItem) StackSorted(micdoodle8.mods.galacticraft.core.util.StackSorted) ItemStack(net.minecraft.item.ItemStack)

Example 2 with EnumSortCategoryItem

use of micdoodle8.mods.galacticraft.core.util.EnumSortCategoryItem in project Galacticraft by micdoodle8.

the class GCItems method registerSorted.

public static void registerSorted(Item item) {
    if (item instanceof ISortableItem) {
        ISortableItem sortableItem = (ISortableItem) item;
        List<ItemStack> items = Lists.newArrayList();
        item.getSubItems(item, null, items);
        for (ItemStack stack : items) {
            EnumSortCategoryItem categoryItem = sortableItem.getCategory(stack.getItemDamage());
            if (!sortMapItems.containsKey(categoryItem)) {
                sortMapItems.put(categoryItem, new ArrayList<>());
            }
            sortMapItems.get(categoryItem).add(new StackSorted(stack.getItem(), stack.getItemDamage()));
        }
    } else if (item.getCreativeTab() == GalacticraftCore.galacticraftItemsTab) {
        throw new RuntimeException(item.getClass() + " must inherit " + ISortableItem.class.getSimpleName() + "!");
    }
}
Also used : EnumSortCategoryItem(micdoodle8.mods.galacticraft.core.util.EnumSortCategoryItem) StackSorted(micdoodle8.mods.galacticraft.core.util.StackSorted) ItemStack(net.minecraft.item.ItemStack)

Example 3 with EnumSortCategoryItem

use of micdoodle8.mods.galacticraft.core.util.EnumSortCategoryItem in project MorePlanets by SteveKunG.

the class CommonRegisterHelper method postRegisteredSortItem.

public static void postRegisteredSortItem() {
    List<StackSorted> itemOrderListItems = new ArrayList<>();
    for (EnumSortCategoryItem type : EnumSortCategoryItem.valuesCached()) {
        List<StackSorted> stackSorteds = CommonRegisterHelper.SORT_MAP_ITEMS.get(type);
        if (stackSorteds != null) {
            itemOrderListItems.addAll(stackSorteds);
        }
    }
    Comparator<ItemStack> tabSorterItems = Ordering.explicit(itemOrderListItems).onResultOf(input -> new StackSorted(input.getItem(), input.getItemDamage()));
    MorePlanetsCore.ITEM_TAB.setTabSorter(tabSorterItems);
}
Also used : EnumSortCategoryItem(stevekung.mods.moreplanets.util.items.EnumSortCategoryItem) StackSorted(micdoodle8.mods.galacticraft.core.util.StackSorted) ItemStack(net.minecraft.item.ItemStack)

Example 4 with EnumSortCategoryItem

use of micdoodle8.mods.galacticraft.core.util.EnumSortCategoryItem 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)4 ItemStack (net.minecraft.item.ItemStack)4 EnumSortCategoryItem (micdoodle8.mods.galacticraft.core.util.EnumSortCategoryItem)2 EnumSortCategoryItem (stevekung.mods.moreplanets.util.items.EnumSortCategoryItem)2 ISortableItem (stevekung.mods.moreplanets.util.items.ISortableItem)1