package org.cyclops.cyclopscore.recipe.custom.component;

import lombok.Getter;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;

import java.util.List;

/**
 * A {@link org.cyclops.cyclopscore.recipe.custom.api.IRecipe} component (input, output or properties) that holds an
 * oredictionary key.
 *
 * @author immortaleeb
 */
public class OreDictItemStackRecipeComponent extends ItemStackRecipeComponent {

    @Getter private final String key;
    @Getter(lazy=true) private final List<ItemStack> itemStacks = OreDictionary.getOres(getKey());

    public OreDictItemStackRecipeComponent(String key) {
        super(null);
        this.key = key;
    }

    @Override
    public boolean equals(Object object) {
        if (!(object instanceof ItemStackRecipeComponent)) return false;
        ItemStackRecipeComponent that = (ItemStackRecipeComponent)object;

        // To increase performance, first check if the comparing stack is not null before
        // potentially matching it with the whole oredict.
        if (that.getItemStack() != null) {
            for (ItemStack itemStack : getItemStacks()) {
                if (equals(itemStack, that.getItemStack())) {
                    return true;
                }
            }
        }

        return getItemStacks().isEmpty();
    }

    @Override
    public ItemStack getItemStack() {
        return getItemStacks().size() > 0 ? getItemStacks().get(0) : super.getItemStack();
    }

    @Override
    public int hashCode() {
        return key != null ? key.hashCode() + 876 : 0;
    }

}

@@ -163,30 +163,110 @@
 ry;%0A
-%0Aimport java.util.List
+import org.cyclops.cyclopscore.datastructure.Wrapper;%0A%0Aimport java.util.List;%0Aimport java.util.Objects
 ;%0A%0A/
@@ -563,27 +563,8 @@
 %0A   
- @Getter(lazy=true)
  pri
@@ -574,16 +574,24 @@
 e final 
+Wrapper%3C
 List%3CIte
@@ -597,16 +597,17 @@
 emStack%3E
+%3E
  itemSta
@@ -613,42 +613,8 @@
 acks
- = OreDictionary.getOres(getKey())
 ;%0A%0A 
@@ -710,24 +710,117 @@
 .key = key;%0A
+        this.itemStacks = new Wrapper%3C%3E(OreDictionary.getOres(Objects.requireNonNull(key)));%0A
     %7D%0A%0A    @
@@ -1598,32 +1598,131 @@
 Stack();%0A    %7D%0A%0A
+    @Override%0A    public List%3CItemStack%3E getItemStacks() %7B%0A        return itemStacks.get();%0A    %7D%0A%0A
     @Override%0A  

Add safety checks for avoiding null oredict entries