use of micdoodle8.mods.galacticraft.core.util.EnumSortCategoryBlock 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);
}
use of micdoodle8.mods.galacticraft.core.util.EnumSortCategoryBlock 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);
}
use of micdoodle8.mods.galacticraft.core.util.EnumSortCategoryBlock 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() + "!");
}
}
use of micdoodle8.mods.galacticraft.core.util.EnumSortCategoryBlock 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() + "!");
}
}
Aggregations