Search in sources :

Example 1 with ItemStackHashSet

use of pl.asie.charset.lib.utils.ItemStackHashSet in project Charset by CharsetMC.

the class SubItemProviderRecipes method createItemSets.

@Override
protected List<List<ItemStack>> createItemSets() {
    List<List<ItemStack>> list = new ArrayList<>();
    Item item = itemSupplier.get();
    if (group == null) {
        group = item.getRegistryName().toString();
    }
    ItemStackHashSet stackSet = new ItemStackHashSet(false, true, true);
    for (IRecipe recipe : ForgeRegistries.RECIPES) {
        if ((group == null || group.equals(recipe.getGroup())) && !recipe.getRecipeOutput().isEmpty() && recipe.getRecipeOutput().getItem() == item) {
            if (recipe instanceof RecipeCharset) {
                for (ItemStack s : ((RecipeCharset) recipe).getAllRecipeOutputs()) {
                    if (stackSet.add(s)) {
                        List<ItemStack> stacks = createSetFor(s);
                        if (stacks != null && stacks.size() > 0)
                            list.add(stacks);
                    }
                }
            } else {
                ItemStack s = recipe.getRecipeOutput();
                if (stackSet.add(s)) {
                    List<ItemStack> stacks = createSetFor(s);
                    if (stacks != null && stacks.size() > 0)
                        list.add(stacks);
                }
            }
        }
    }
    return list;
}
Also used : Item(net.minecraft.item.Item) RecipeCharset(pl.asie.charset.lib.recipe.RecipeCharset) ItemStackHashSet(pl.asie.charset.lib.utils.ItemStackHashSet) IRecipe(net.minecraft.item.crafting.IRecipe) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack)

Example 2 with ItemStackHashSet

use of pl.asie.charset.lib.utils.ItemStackHashSet in project Charset by CharsetMC.

the class RecipeCharset method getAllRecipeOutputs.

public Collection<ItemStack> getAllRecipeOutputs() {
    InventoryCraftingIterator inventoryCrafting = new InventoryCraftingIterator(this, true);
    ItemStackHashSet stackSet = new ItemStackHashSet(true, true, true);
    List<ItemStack> stacks = new ArrayList<>();
    InventoryCraftingIterator it = inventoryCrafting;
    while (it.hasNext()) {
        InventoryCrafting ic = it.next();
        ItemStack stack = getCraftingResult(ic);
        if (!stack.isEmpty() && stackSet.add(stack)) {
            stacks.add(stack);
        }
    }
    return stacks;
}
Also used : ItemStackHashSet(pl.asie.charset.lib.utils.ItemStackHashSet) ItemStack(net.minecraft.item.ItemStack) InventoryCrafting(net.minecraft.inventory.InventoryCrafting)

Aggregations

ItemStack (net.minecraft.item.ItemStack)2 ItemStackHashSet (pl.asie.charset.lib.utils.ItemStackHashSet)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 InventoryCrafting (net.minecraft.inventory.InventoryCrafting)1 Item (net.minecraft.item.Item)1 IRecipe (net.minecraft.item.crafting.IRecipe)1 RecipeCharset (pl.asie.charset.lib.recipe.RecipeCharset)1