Search in sources :

Example 6 with StackSorted

use of micdoodle8.mods.galacticraft.core.util.StackSorted 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 7 with StackSorted

use of micdoodle8.mods.galacticraft.core.util.StackSorted 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)

Example 8 with StackSorted

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

the class GCBlocks method registerSorted.

public static void registerSorted(Block block) {
    if (block instanceof ISortableBlock) {
        ISortableBlock sortableBlock = (ISortableBlock) block;
        List<ItemStack> blocks = Lists.newArrayList();
        registeringSorted = true;
        block.getSubBlocks(Item.getItemFromBlock(block), null, blocks);
        registeringSorted = false;
        for (ItemStack stack : blocks) {
            EnumSortCategoryBlock categoryBlock = sortableBlock.getCategory(stack.getItemDamage());
            if (!sortMapBlocks.containsKey(categoryBlock)) {
                sortMapBlocks.put(categoryBlock, new ArrayList<>());
            }
            sortMapBlocks.get(categoryBlock).add(new StackSorted(stack.getItem(), stack.getItemDamage()));
        }
    } else if (block.getCreativeTabToDisplayOn() == GalacticraftCore.galacticraftBlocksTab) {
        throw new RuntimeException(block.getClass() + " must inherit " + ISortableBlock.class.getSimpleName() + "!");
    }
}
Also used : StackSorted(micdoodle8.mods.galacticraft.core.util.StackSorted) ItemStack(net.minecraft.item.ItemStack) EnumSortCategoryBlock(micdoodle8.mods.galacticraft.core.util.EnumSortCategoryBlock)

Aggregations

StackSorted (micdoodle8.mods.galacticraft.core.util.StackSorted)8 ItemStack (net.minecraft.item.ItemStack)8 EnumSortCategoryItem (stevekung.mods.moreplanets.util.items.EnumSortCategoryItem)3 EnumSortCategoryBlock (micdoodle8.mods.galacticraft.core.util.EnumSortCategoryBlock)2 EnumSortCategoryItem (micdoodle8.mods.galacticraft.core.util.EnumSortCategoryItem)2 EnumSortCategoryBlock (stevekung.mods.moreplanets.util.blocks.EnumSortCategoryBlock)2 ISortableItem (stevekung.mods.moreplanets.util.items.ISortableItem)2 IBehaviorDispenseItem (net.minecraft.dispenser.IBehaviorDispenseItem)1 Item (net.minecraft.item.Item)1 ISortableBlock (stevekung.mods.moreplanets.util.blocks.ISortableBlock)1