use of stevekung.mods.moreplanets.util.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() + "!");
}
}
Aggregations