Search in sources :

Example 1 with ISortableBlock

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

Example 2 with ISortableBlock

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