package gregtech.api.util;
import static gregtech.api.enums.GT_Values.D2;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import org.jetbrains.annotations.Contract;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.ModContainer;
import gregtech.GT_Mod;
import gregtech.api.GregTech_API;
import gregtech.api.enums.ItemList;
import gregtech.api.enums.Materials;
import gregtech.api.logic.FluidInventoryLogic;
import gregtech.api.logic.ItemInventoryLogic;
import gregtech.api.objects.GT_ItemStack;
import gregtech.api.recipe.RecipeCategory;
import gregtech.api.recipe.RecipeMap;
import gregtech.api.recipe.RecipeMaps;
import gregtech.api.recipe.RecipeMetadataKey;
import gregtech.api.recipe.metadata.EmptyRecipeMetadataStorage;
import gregtech.api.recipe.metadata.IRecipeMetadataStorage;
import gregtech.api.util.extensions.ArrayExt;
import gregtech.api.util.item.ItemHolder;
import ic2.core.Ic2Items;
public class GT_Recipe implements Comparable<GT_Recipe> {
/**
* If you want to change the Output, feel free to modify or even replace the whole ItemStack Array, for Inputs,
* please add a new Recipe, because of the HashMaps.
*/
public ItemStack[] mInputs, mOutputs;
/**
* If you want to change the Output, feel free to modify or even replace the whole ItemStack Array, for Inputs,
* please add a new Recipe, because of the HashMaps.
*/
public FluidStack[] mFluidInputs, mFluidOutputs;
/**
* If you changed the amount of Array-Items inside the Output Array then the length of this Array must be larger or
* equal to the Output Array. A chance of 10000 equals 100%
*/
public int[] mChances;
/**
* An Item that needs to be inside the Special Slot, like for example the Copy Slot inside the Printer. This is only
* useful for Fake Recipes in NEI, since findRecipe() and containsInput() don't give a shit about this Field. Lists
* are also possible.
*/
public Object mSpecialItems;
public int mDuration, mEUt, mSpecialValue;
/**
* Use this to just disable a specific Recipe, but the Configuration enables that already for every single Recipe.
*/
public boolean mEnabled = true;
/**
* If this Recipe is hidden from NEI
*/
public boolean mHidden = false;
/**
* If this Recipe is Fake and therefore doesn't get found by the findRecipe Function (It is still in the HashMaps,
* so that containsInput does return T on those fake Inputs)
*/
public boolean mFakeRecipe = false;
/**
* If this Recipe can be stored inside a Machine in order to make Recipe searching more Efficient by trying the
* previously used Recipe first. In case you have a Recipe Map overriding things and returning one time use Recipes,
* you have to set this to F.
*/
public boolean mCanBeBuffered = true;
/**
* If this Recipe needs the Output Slots to be completely empty. Needed in case you have randomised Outputs
*/
public boolean mNeedsEmptyOutput = false;
/**
* If this is set to true, NBT equality is required for recipe check.
*/
public boolean isNBTSensitive = false;
/**
* Used for describing recipes that do not fit the default recipe pattern (for example Large Boiler Fuels)
*/
private String[] neiDesc = null;
/**
* Holds a set of metadata for this recipe.
*/
@Nonnull
private final IRecipeMetadataStorage metadataStorage;
/**
* Category this recipe belongs to. Recipes belonging to recipemap are forced to have non-null category when added,
* otherwise it can be null.
*/
private RecipeCategory recipeCategory;
/**
* Stores which mod added this recipe
*/
public List<ModContainer> owners = new ArrayList<>();
/**
* Stores stack traces where this recipe was added
*/
// BW wants to overwrite it, so no final
public List<List<String>> stackTraces = new ArrayList<>();
private GT_Recipe(GT_Recipe aRecipe, boolean shallow) {
mInputs = shallow ? aRecipe.mInputs : GT_Utility.copyItemArray(aRecipe.mInputs);
mOutputs = shallow ? aRecipe.mOutputs : GT_Utility.copyItemArray(aRecipe.mOutputs);
mSpecialItems = aRecipe.mSpecialItems;
mChances = aRecipe.mChances;
mFluidInputs = shallow ? aRecipe.mFluidInputs : GT_Utility.copyFluidArray(aRecipe.mFluidInputs);
mFluidOutputs = shallow ? aRecipe.mFluidOutputs : GT_Utility.copyFluidArray(aRecipe.mFluidOutputs);
mDuration = aRecipe.mDuration;
mSpecialValue = aRecipe.mSpecialValue;
mEUt = aRecipe.mEUt;
mNeedsEmptyOutput = aRecipe.mNeedsEmptyOutput;
isNBTSensitive = aRecipe.isNBTSensitive;
mCanBeBuffered = aRecipe.mCanBeBuffered;
mFakeRecipe = aRecipe.mFakeRecipe;
mEnabled = aRecipe.mEnabled;
mHidden = aRecipe.mHidden;
metadataStorage = EmptyRecipeMetadataStorage.INSTANCE;
owners = new ArrayList<>(aRecipe.owners);
reloadOwner();
}
/**
* Only for {@link GT_RecipeBuilder}.
*/
GT_Recipe(ItemStack[] mInputs, ItemStack[] mOutputs, FluidStack[] mFluidInputs, FluidStack[] mFluidOutputs,
int[] mChances,