Search in sources :

Example 1 with StackSorted

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

the class CommonRegisterHelper method postRegisteredSortBlock.

public static void postRegisteredSortBlock() {
    List<StackSorted> itemOrderListBlocks = new ArrayList<>();
    for (EnumSortCategoryBlock type : EnumSortCategoryBlock.valuesCached()) {
        List<StackSorted> stackSorteds = CommonRegisterHelper.SORT_MAP_BLOCKS.get(type);
        if (stackSorteds != null) {
            itemOrderListBlocks.addAll(stackSorteds);
        }
    }
    Comparator<ItemStack> tabSorterBlocks = Ordering.explicit(itemOrderListBlocks).onResultOf(input -> new StackSorted(input.getItem(), input.getItemDamage()));
    MorePlanetsCore.BLOCK_TAB.setTabSorter(tabSorterBlocks);
}
Also used : StackSorted(micdoodle8.mods.galacticraft.core.util.StackSorted) EnumSortCategoryBlock(stevekung.mods.moreplanets.util.blocks.EnumSortCategoryBlock) ItemStack(net.minecraft.item.ItemStack)

Example 2 with StackSorted

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

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

the class GCBlocks method finalizeSort.

public static void finalizeSort() {
    List<StackSorted> itemOrderListBlocks = Lists.newArrayList();
    for (EnumSortCategoryBlock type : EnumSortCategoryBlock.values()) {
        if (!GalacticraftCore.isPlanetsLoaded && type == EnumSortCategoryBlock.EGG)
            continue;
        List<StackSorted> stackSorteds = sortMapBlocks.get(type);
        itemOrderListBlocks.addAll(stackSorteds);
    }
    Comparator<ItemStack> tabSorterBlocks = Ordering.explicit(itemOrderListBlocks).onResultOf(input -> new StackSorted(input.getItem(), input.getItemDamage()));
    GalacticraftCore.galacticraftBlocksTab.setTabSorter(tabSorterBlocks);
}
Also used : StackSorted(micdoodle8.mods.galacticraft.core.util.StackSorted) EnumSortCategoryBlock(micdoodle8.mods.galacticraft.core.util.EnumSortCategoryBlock) ItemStack(net.minecraft.item.ItemStack)

Example 4 with StackSorted

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

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

the class CommonRegisterHelper method registerSorted.

public static void registerSorted(Block block) {
    if (block instanceof ISortableBlock) {
        Item item = Item.getItemFromBlock(block);
        if (item == Items.AIR) {
            return;
        }
        ISortableBlock sortableBlock = (ISortableBlock) block;
        NonNullList<ItemStack> blocks = NonNullList.create();
        block.getSubBlocks(null, blocks);
        for (ItemStack itemStack : blocks) {
            EnumSortCategoryBlock categoryBlock = sortableBlock.getBlockCategory(itemStack.getItemDamage());
            if (!CommonRegisterHelper.SORT_MAP_BLOCKS.containsKey(categoryBlock)) {
                CommonRegisterHelper.SORT_MAP_BLOCKS.put(categoryBlock, new ArrayList<>());
            }
            CommonRegisterHelper.SORT_MAP_BLOCKS.get(categoryBlock).add(new StackSorted(itemStack.getItem(), itemStack.getItemDamage()));
        }
    } else if (block.getCreativeTabToDisplayOn() == MorePlanetsCore.BLOCK_TAB) {
        throw new RuntimeException(block.getClass() + " must inherit " + ISortableBlock.class.getSimpleName() + "!");
    }
}
Also used : Item(net.minecraft.item.Item) EnumSortCategoryItem(stevekung.mods.moreplanets.util.items.EnumSortCategoryItem) ISortableItem(stevekung.mods.moreplanets.util.items.ISortableItem) IBehaviorDispenseItem(net.minecraft.dispenser.IBehaviorDispenseItem) ISortableBlock(stevekung.mods.moreplanets.util.blocks.ISortableBlock) StackSorted(micdoodle8.mods.galacticraft.core.util.StackSorted) ItemStack(net.minecraft.item.ItemStack) EnumSortCategoryBlock(stevekung.mods.moreplanets.util.blocks.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