package gregtech.api.util;
import cpw.mods.fml.common.event.FMLInterModComms;
import cpw.mods.fml.common.registry.GameRegistry;
import gregtech.api.GregTech_API;
import gregtech.api.enums.*;
import gregtech.api.interfaces.IDamagableItem;
import gregtech.api.interfaces.IItemContainer;
import gregtech.api.interfaces.internal.IGT_CraftingRecipe;
import gregtech.api.objects.GT_HashSet;
import gregtech.api.objects.GT_ItemStack;
import gregtech.api.objects.ItemData;
import ic2.api.item.IBoxable;
import ic2.api.item.IC2Items;
import ic2.api.item.IElectricItem;
import ic2.api.reactor.IReactorComponent;
import ic2.api.recipe.IRecipeInput;
import ic2.api.recipe.RecipeInputItemStack;
import ic2.api.recipe.RecipeOutput;
import net.minecraft.block.Block;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.*;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntityFurnace;
import net.minecraft.world.World;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.oredict.ShapedOreRecipe;
import net.minecraftforge.oredict.ShapelessOreRecipe;
import java.util.*;
import java.util.Map.Entry;
import static gregtech.api.enums.GT_Values.*;
/**
* NEVER INCLUDE THIS FILE IN YOUR MOD!!!
*
* This is the Interface I use for interacting with other Mods.
*
* Due to the many imports, this File can cause compile Problems if not all the APIs are installed
*/
public class GT_ModHandler {
public static final List sSingleNonBlockDamagableRecipeList = new ArrayList(1000);
private static final Map sIC2ItemMap = new HashMap();
private static final List sAllRecipeList = Collections.synchronizedList(new ArrayList(5000)), sBufferRecipeList = new ArrayList(1000);
public static volatile int VERSION = 509;
public static Collection sNativeRecipeClasses = new HashSet(), sSpecialRecipeClasses = new HashSet();
public static GT_HashSet sNonReplaceableItems = new GT_HashSet();
public static Object sBoxableWrapper = GT_Utility.callConstructor("gregtechmod.api.util.GT_IBoxableWrapper", 0, null, false);
private static Map sExtractorRecipes = new HashMap();
private static Map sMaceratorRecipes = new HashMap();
private static Map sCompressorRecipes = new HashMap();
private static Map sOreWashingRecipes = new HashMap();
private static Map sThermalCentrifugeRecipes = new HashMap();
private static Map sMassfabRecipes = new HashMap();
private static boolean sBufferCraftingRecipes = true;
static {
sNativeRecipeClasses.add(ShapedRecipes.class.getName());
sNativeRecipeClasses.add(ShapedOreRecipe.class.getName());
sNativeRecipeClasses.add(GT_Shaped_Recipe.class.getName());
sNativeRecipeClasses.add(ShapelessRecipes.class.getName());
sNativeRecipeClasses.add(ShapelessOreRecipe.class.getName());
sNativeRecipeClasses.add(GT_Shapeless_Recipe.class.getName());
sNativeRecipeClasses.add(ic2.core.AdvRecipe.class.getName());
sNativeRecipeClasses.add(ic2.core.AdvShapelessRecipe.class.getName());
sNativeRecipeClasses.add("appeng.recipes.game.ShapedRecipe");
sNativeRecipeClasses.add("appeng.recipes.game.ShapelessRecipe");
sNativeRecipeClasses.add("forestry.core.utils.ShapedRecipeCustom");
// Recipe Classes, which should never be removed.
sSpecialRecipeClasses.add(net.minecraft.item.crafting.RecipeFireworks.class.getName());
sSpecialRecipeClasses.add(net.minecraft.item.crafting.RecipesArmorDyes.class.getName());
sSpecialRecipeClasses.add(net.minecraft.item.crafting.RecipeBookCloning.class.getName());
sSpecialRecipeClasses.add(net.minecraft.item.crafting.RecipesMapCloning.class.getName());
sSpecialRecipeClasses.add(net.minecraft.item.crafting.RecipesMapExtending.class.getName());
sSpecialRecipeClasses.add("jds.bibliocraft.BiblioSpecialRecipes");
sSpecialRecipeClasses.add("dan200.qcraft.shared.EntangledQBlockRecipe");
sSpecialRecipeClasses.add("dan200.qcraft.shared.EntangledQuantumComputerRecipe");
sSpecialRecipeClasses.add("dan200.qcraft.shared.QBlockRecipe");
sSpecialRecipeClasses.add("appeng.recipes.game.FacadeRecipe");
sSpecialRecipeClasses.add("appeng.recipes.game.DisassembleRecipe");
sSpecialRecipeClasses.add("mods.railcraft.common.carts.LocomotivePaintingRecipe");
sSpecialRecipeClasses.add("mods.railcraft.common.util.crafting.RotorRepairRecipe");
sSpecialRecipeClasses.add("mods.railcraft.common.util.crafting.RoutingTableCopyRecipe");
sSpecialRecipeClasses.add("mods.railcraft.common.util.crafting.RoutingTicketCopyRecipe");
sSpecialRecipeClasses.add("mods.railcraft.common.util.crafting.TankCartFilterRecipe");
sSpecialRecipeClasses.add("mods.railcraft.common.emblems.LocomotiveEmblemRecipe");
sSpecialRecipeClasses.add("mods.railcraft.common.emblems.EmblemPostColorRecipe");
sSpecialRecipeClasses.add("mods.railcraft.common.emblems.EmblemPostEmblemRecipe");
sSpecialRecipeClasses.add("mods.immibis.redlogic.interaction.RecipeDyeLumarButton");
sSpecialRecipeClasses.add("thaumcraft.common.items.armor.RecipesRobeArmorDyes");
sSpecialRecipeClasses.add("thaumcraft.common.items.armor.RecipesVoidRobeArmorDyes");
sSpecialRecipeClasses.add("thaumcraft.common.lib.crafting.ShapelessNBTOreRecipe");
sSpecialRecipeClasses.add("twilightforest.item.TFMapCloningRecipe");
sSpecialRecipeClasses.add("forestry.lepidopterology.MatingRecipe");
sSpecialRecipeClasses.add("micdoodle8.mods.galacticraft.planets.asteroids.recipe.CanisterRecipes");
sSpecialRecipeClasses.add("shedar.mods.ic2.nuclearcontrol.StorageArrayRecipe");
}
/**
* Returns if that Liquid is Water or Distilled Water
*/
public static boolean isWater(FluidStack aFluid) {
if (aFluid == null) return false;
return aFluid.isFluidEqual(getWater(1)) || aFluid.isFluidEqual(getDistilledWater(1));
}
/**
* Returns a Liquid Stack with given amount of Water.
*/
public static FluidStack getWater(long aAmount) {
return FluidRegistry.getFluidStack("water", (int) aAmount);
}
/**
* Returns a Liquid Stack with given amount of distilled Water.
*/
public static FluidStack getDistilledWater(long aAmount) {
return FluidRegistry.getFluidStack("ic2distilledwater", (int) aAmount);
}
/**
* Returns if that Liquid is Lava
*/
public static boolean isLava(FluidStack aFluid) {
if (aFluid == null) return false;
return aFluid.isFluidEqual(getLava(1));
}
/**
* Returns a Liquid Stack with given amount of Lava.
*/
public static FluidStack getLava(long aAmount) {
return FluidRegistry.getFluidStack("lava", (int) aAmount);
}
/**
* Returns if that Liquid is Steam
*/
public static boolean isSteam(FluidStack aFluid) {
if (aFluid == null) return false;
return aFluid.isFluidEqual(getSteam(1));
}
/**
* Returns a Liquid Stack with given amount of Steam.
*/
public static FluidStack getSteam(long aAmount) {
return FluidRegistry.getFluidStack("steam", (int) aAmount);
}
/**
* Returns if that Liquid is Milk
*/
public static boolean isMilk(FluidStack aFluid) {
if (aFluid == null) return false;
return aFluid.isFluidEqual(getMilk(1));
}
/**
* Returns a Liquid Stack with given amount of Milk.
*/
public static FluidStack getMilk(long aAmount) {
return FluidRegistry.getFluidStack("milk", (int) aAmount);
}
public static ItemStack getEmptyFuelCan(long aAmount) {
return ItemList.IC2_Fuel_Can_Empty.get(aAmount);
}
public static ItemStack getEmptyCell(long aAmount) {
return ItemList.Cell_Empty.get(aAmount);
}
public static ItemStack getAirCell(long aAmount) {
return ItemList.Cell_Air.get(aAmount);
}
public static ItemStack getWaterCell(long aAmount) {
return ItemList.Cell_Water.get(aAmount);
}
public static ItemStack getLavaCell(long aAmount) {
return ItemList.Cell_Lava.get(aAmount);
}
/**
* @param aValue the Value of this Stack, when burning inside a Furnace (200 = 1 Burn Process = 500 EU, max = 32767 (that is 81917.5 EU)), limited to Short because the vanilla Furnace otherwise can't handle it properly, stupid Mojang...
*/
public static ItemStack setFuelValue(ItemStack aStack, short aValue) {
aStack.setTagCompound(GT_Utility.getNBTContainingShort(aStack.getTagCompound(), "GT.ItemFuelValue", aValue));
return aStack;
}
/**
* @return the Value of this Stack, when burning inside a Furnace (200 = 1 Burn Process = 500 EU, max = 32767 (that is 81917.5 EU)), limited to Short because the vanilla Furnace otherwise can't handle it properly, stupid Mojang...
*/
public static short getFuelValue(ItemStack aStack) {
return (short) TileEntityFurnace.getItemBurnTime(aStack);
}
/**
* @param aValue Fuel value in EU
*/
public static ItemStack getFuelCan(int aValue) {
if (aValue < 5) return ItemList.IC2_Fuel_Can_Empty.get(1);
ItemStack rFuelCanStack = ItemList.IC2_Fuel_Can_Filled.get(1);
if (rFuelCanStack == null) return null;
NBTTagCompound tNBT = new NBTTagCompound();
tNBT.setInteger("value", aValue / 5);
rFuelCanStack.setTagCompound(tNBT);
return rFuelCanStack;
}
/**
* @param aFuelCan the Item you want to check
* @return the exact Value in EU the Fuel Can is worth if its even a Fuel Can.
*/
public static int getFuelCanValue(ItemStack aFuelCan) {
if (GT_Utility.isStackInvalid(aFuelCan) || !ItemList.IC2_Fuel_Can_Filled.isStackEqual(aFuelCan, false, true))
return 0;
NBTTagCompound tNBT = aFuelCan.getTagCompound();
return tNBT == null ? 0 : tNBT.getInteger("value") * 5;
}
/**
* Gets an Item from IndustrialCraft, and returns a Replacement Item if not possible
*/
public static ItemStack getIC2Item(String aItem, long aAmount, ItemStack aReplacement) {
if (GT_Utility.isStringInvalid(aItem) || !GregTech_API.sPreloadStarted) return null;
//if (D1) GT_Log.out.println("Requested the Item '" + aItem + "' from the IC2-API");
if (!sIC2ItemMap.containsKey(aItem)) try {
ItemStack tStack = IC2Items.getItem(aItem);
sIC2ItemMap.put(aItem, tStack);
if (tStack == null && D1) GT_Log.err.println(aItem + " is not found in the IC2 Items!");
} catch (Throwable e) {/*Do nothing*/}
return GT_Utility.copyAmount(aAmount, sIC2ItemMap.get(aItem), aReplacement);
}
/**
* Gets an Item from IndustrialCraft, but the Damage Value can be specified, and returns a Replacement Item with the same Damage if not possible
*/
public static ItemStack getIC2Item(String aItem, long aAmount, int aMeta, ItemStack aReplacement) {
ItemStack rStack = getIC2Item(aItem, aAmount, aReplacement);
if (rStack == null) return null;
Items.feather.setDamage(rStack, aMeta);
return rStack;
}
/**
* Gets an Item from IndustrialCraft, but the Damage Value can be specified
*/
public static ItemStack getIC2Item(String aItem, long aAmount, int aMeta) {
return getIC2Item(aItem, aAmount, aMeta, null);
}
/**
* Gets an Item from IndustrialCraft
*/
public static ItemStack getIC2Item(String aItem, long aAmount) {
return getIC2Item(aItem, aAmount, null);
}
/**
* Gets an Item from RailCraft
*/
public static ItemStack getModItem(String aModID, String aItem, long aAmount) {
return getModItem(aModID, aItem, aAmount, null);
}
/**
* Gets an Item from RailCraft, and returns a Replacement Item if not possible
*/
public static ItemStack getModItem(String aModID, String aItem, long aAmount, ItemStack aReplacement) {
if (GT_Utility.isStringInvalid(aItem) || !GregTech_API.sPreloadStarted) return null;
return GT_Utility.copyAmount(aAmount, GameRegistry.findItemStack(aModID, aItem, (int) aAmount), aReplacement);
}
/**
* Gets an Item from RailCraft, but the Damage Value can be specified
*/
public static ItemStack getModItem(String aModID, String aItem, long aAmount, int aMeta) {
ItemStack rStack = getModItem(aModID, aItem, aAmount);
if (rStack == null) return null;
Items.feather.setDamage(rStack, aMeta);
return rStack;
}
/**
* Gets an Item from RailCraft, but the Damage Value can be specified, and returns a Replacement Item with the same Damage if not possible
*/
public static ItemStack getModItem(String aModID, String aItem, long aAmount, int aMeta, ItemStack aReplacement) {
ItemStack rStack = getModItem(aModID, aItem, aAmount, aReplacement);
if (rStack == null) return null;
Items.feather.setDamage(rStack, aMeta);
return rStack;
}
/**
* OUT OF ORDER
*/
public static boolean getModeKeyDown(EntityPlayer aPlayer) {
return false;
}
/**
* OUT OF ORDER
*/
public static boolean getBoostKeyDown(EntityPlayer aPlayer) {
return false;
}
/**
* OUT OF ORDER
*/
public static boolean getJumpKeyDown(EntityPlayer aPlayer) {
return false;
}
/**
* Adds a Valuable Ore to the Miner
*/
public static boolean addValuableOre(Block aBlock, int aMeta, int aValue) {
if (aValue <= 0) return false;
try {
Class.forName("ic2.core.IC2").getMethod("addValuableOre", IRecipeInput.class, int.class).invoke(null, new RecipeInputItemStack(new ItemStack(aBlock, 1, aMeta)), aValue);
} catch (Throwable e) {/*Do nothing*/}
return true;
}
/**
* Adds a Scrapbox Drop. Fails at April first for the "suddenly Hoes"-Feature of IC2
*/
public static boolean addScrapboxDrop(float aChance, ItemStack aOutput) {
aOutput = GT_OreDictUnificator.get(true, aOutput);
if (aOutput == null || aChance <= 0) return false;
aOutput.stackSize = 1;
if (GT_Config.troll && !GT_Utility.areStacksEqual(aOutput, new ItemStack(Items.wooden_hoe, 1, 0))) return false;
aChance = (float) GregTech_API.sRecipeFile.get(ConfigCategories.Machines.scrapboxdrops, aOutput, aChance);
if (aChance <= 0) return false;
try {
GT_Utility.callMethod(GT_Utility.getFieldContent("ic2.api.recipe.Recipes", "scrapboxDrops", true, true), "addDrop", true, false, true, GT_Utility.copy(aOutput), aChance);
GT_Utility.callMethod(GT_Utility.getFieldContent("ic2.api.recipe.Recipes", "scrapboxDrops", true, true), "addRecipe", true, true, false, GT_Utility.copy(aOutput), aChance);
} catch (Throwable e) {/*Do nothing*/}
return true;
}
/**
* Adds an Item to the Recycler Blacklist
*/
public static boolean addToRecyclerBlackList(ItemStack aRecycledStack) {
if (aRecycledStack == null) return false;
try {
ic2.api.recipe.Recipes.recyclerBlacklist.add(new RecipeInputItemStack(aRecycledStack));
} catch (Throwable e) {/*Do nothing*/}
return true;
}
/**
* Just simple Furnace smelting. Unbelievable how Minecraft fails at making a simple ItemStack->ItemStack mapping...
*/
public static boolean addSmeltingRecipe(ItemStack aInput, ItemStack aOutput) {
aOutput = GT_OreDictUnificator.get(true, aOutput);
if (aInput == null || aOutput == null || GT_Utility.getContainerItem(aInput, false) != null) return false;
if (!GregTech_API.sRecipeFile.get(ConfigCategories.Machines.smelting, aInput, true)) return false;
FurnaceRecipes.smelting().func_151394_a(aInput, GT_Utility.copy(aOutput), 0.0F);
return true;
}
/**
* Adds to Furnace AND Alloysmelter AND Induction Smelter
*/
public static boolean addSmeltingAndAlloySmeltingRecipe(ItemStack aInput, ItemStack aOutput, boolean hidden) {
if (aInput == null || aOutput == null) return false;
boolean temp = false;
if (aInput.stackSize == 1 && addSmeltingRecipe(aInput, aOutput)) temp = true;
if (RA.addAlloySmelterRecipe(aInput, OrePrefixes.ingot.contains(aOutput) ? ItemList.Shape_Mold_Ingot.get(0) : OrePrefixes.block.contains(aOutput) ? ItemList.Shape_Mold_Block.get(0) : OrePrefixes.nugget.contains(aOutput) ? ItemList.Shape_Mold_Nugget.get(0) : null, aOutput, 130, 3,hidden))
temp = true;
if (addInductionSmelterRecipe(aInput, null, aOutput, null, aOutput.stackSize * 1600, 0)) temp = true;
return temp;
}
/**
* LiquidTransposer Recipe for both directions
*/
public static boolean addLiquidTransposerRecipe(ItemStack aEmptyContainer, FluidStack aLiquid, ItemStack aFullContainer, int aMJ) {
aFullContainer = GT_OreDictUnificator.get(true, aFullContainer);
if (aEmptyContainer == null || aFullContainer == null || aLiquid == null) return false;
if (!GregTech_API.sRecipeFile.get(ConfigCategories.Machines.liquidtransposer, aFullContainer, true))
return false;
try {
ThermalExpansion.addTransposerFill(aMJ * 10, aEmptyContainer, aFullContainer, aLiquid, true);
} catch (Throwable e) {/*Do nothing*/}
return true;
}
/**
* LiquidTransposer Recipe for filling Containers
*/
public static boolean addLiquidTransposerFillRecipe(ItemStack aEmptyContainer, FluidStack aLiquid, ItemStack aFullContainer, int aMJ) {
aFullContainer = GT_OreDictUnificator.get(true, aFullContainer);
if (aEmptyContainer == null || aFullContainer == null || aLiquid == null) return false;
if (!GregTech_API.sRecipeFile.get(ConfigCategories.Machines.liquidtransposerfilling, aFullContainer, true))
return false;
try {
ThermalExpansion.addTransposerFill(aMJ * 10, aEmptyContainer, aFullContainer, aLiquid, false);
} catch (Throwable e) {/*Do nothing*/}
return true;
}
/**
* LiquidTransposer Recipe for emptying Containers
*/
public static boolean addLiquidTransposerEmptyRecipe(ItemStack aFullContainer, FluidStack aLiquid, ItemStack aEmptyContainer, int aMJ) {
aEmptyContainer = GT_OreDictUnificator.get(true, aEmptyContainer);
if (aFullContainer == null || aEmptyContainer == null || aLiquid == null) return false;
if (!GregTech_API.sRecipeFile.get(ConfigCategories.Machines.liquidtransposeremptying, aFullContainer, true))
return false;
try {
ThermalExpansion.addTransposerExtract(aMJ * 10, aFullContainer, aEmptyContainer, aLiquid, 100, false);
} catch (Throwable e) {/*Do nothing*/}
return true;
}
/**
* IC2-Extractor Recipe. Overloads old Recipes automatically
*/
public static boolean addExtractionRecipe(ItemStack aInput, ItemStack aOutput) {
aOutput = GT_OreDictUnificator.get(true, aOutput);
if (aInput == null || aOutput == null) return false;
GT_Utility.removeSimpleIC2MachineRecipe(aInput, getExtractorRecipeList(), null);
if (!GregTech_API.sRecipeFile.get(ConfigCategories.Machines.extractor, aInput, true)) return false;
GT_Utility.addSimpleIC2MachineRecipe(aInput, getExtractorRecipeList(), null, aOutput);
return true;
}
/**
* RC-BlastFurnace Recipes
*/
public static boolean addRCBlastFurnaceRecipe(ItemStack aInput, ItemStack aOutput, int aTime) {
aOutput = GT_OreDictUnificator.get(true, aOutput);
if (aInput == null || aOutput == null || aTime <= 0) return false;
if (!GregTech_API.sRecipeFile.get(ConfigCategories.Machines.rcblastfurnace, aInput, true)) return false;
aInput = GT_Utility.copy(aInput);
aOutput = GT_Utility.copy(aOutput);
try {
mods.railcraft.api.crafting.RailcraftCraftingManager.blastFurnace.addRecipe(aInput, true, false, aTime, aOutput);
} catch (Throwable e) {
return false;
}
return true;
}
public static boolean addPulverisationRecipe(ItemStack aInput, ItemStack aOutput1) {
return addPulverisationRecipe(aInput, aOutput1, null, 0, false);
}
public static boolean addPulverisationRecipe(ItemStack aInput, ItemStack aOutput1, ItemStack aOutput2) {
return addPulverisationRecipe(aInput, aOutput1, aOutput2, 100, false);
}
public static boolean addPulverisationRecipe(ItemStack aInput, ItemStack aOutput1, ItemStack aOutput2, int aChance) {
return addPulverisationRecipe(aInput, aOutput1, aOutput2, aChance, false);
}
public static boolean addPulverisationRecipe(ItemStack aInput, ItemStack aOutput1, boolean aOverwrite) {
return addPulverisationRecipe(aInput, aOutput1, null, 0, aOverwrite);
}
public static boolean addPulverisationRecipe(ItemStack aInput, ItemStack aOutput1, ItemStack aOutput2, boolean aOverwrite) {
return addPulverisationRecipe(aInput, aOutput1, aOutput2, 100, aOverwrite);
}
public static boolean addPulverisationRecipe(ItemStack aInput, ItemStack aOutput1, ItemStack aOutput2, int aChance, boolean aOverwrite) {
return addPulverisationRecipe(aInput, aOutput1, aOutput2, aChance, null, 0, aOverwrite);
}
/**
* Adds Several Pulverizer-Type Recipes.
*/
public static boolean addPulverisationRecipe(ItemStack aInput, ItemStack aOutput1, ItemStack aOutput2, int aChance2, ItemStack aOutput3, int aChance3, boolean aOverwrite) {
aOutput1 = GT_OreDictUnificator.get(true, aOutput1);
aOutput2 = GT_OreDictUnificator.get(true, aOutput2);
if (GT_Utility.isStackInvalid(aInput) || GT_Utility.isStackInvalid(aOutput1)) return false;
GT_Utility.removeSimpleIC2MachineRecipe(aInput, getMaceratorRecipeList(), null);
if (GT_Utility.getContainerItem(aInput, false) == null) {
if (GregTech_API.sRecipeFile.get(ConfigCategories.Machines.maceration, aInput, true)) {
GT_Utility.addSimpleIC2MachineRecipe(aInput, getMaceratorRecipeList(), null, aOutput1);
}
RA.addPulveriserRecipe(aInput, new ItemStack[]{aOutput1, aOutput2, aOutput3}, new int[]{10000, aChance2 <= 0 ? 1000 : 100 * aChance2, aChance3 <= 0 ? 1000 : 100 * aChance3}, 400, 2);
if (!OrePrefixes.log.contains(aInput)) {
if (Materials.Wood.contains(aOutput1)) {
if (GregTech_API.sRecipeFile.get(ConfigCategories.Machines.pulverization, aInput, true)) {
if (aOutput2 == null)
ThermalExpansion.addSawmillRecipe(32000, GT_Utility.copy(aInput), GT_Utility.copy(aOutput1));
else
ThermalExpansion.addSawmillRecipe(32000, GT_Utility.copy(aInput), GT_Utility.copy(aOutput1), GT_Utility.copy(aOutput2), aChance2 <= 0 ? 10 : aChance2);
}
} else {
if (GregTech_API.sRecipeFile.get(ConfigCategories.Machines.rockcrushing, aInput, true)) {
try {
if (GT_Utility.getBlockFromStack(aInput) != Blocks.obsidian && GT_Utility.getBlockFromStack(aInput) != Blocks.gravel) {
mods.railcraft.api.crafting.IRockCrusherRecipe tRecipe = mods.railcraft.api.crafting.RailcraftCraftingManager.rockCrusher.createNewRecipe(GT_Utility.copyAmount(1, aInput), aInput.getItemDamage() != W, false);
tRecipe.addOutput(GT_Utility.copy(aOutput1), 1.0F / aInput.stackSize);
if (aOutput2 != null)
tRecipe.addOutput(GT_Utility.copy(aOutput2), (0.01F * (aChance2 <= 0 ? 10 : aChance2)) / aInput.stackSize);
if (aOutput3 != null)
tRecipe.addOutput(GT_Utility.copy(aOutput3), (0.01F * (aChance3 <= 0 ? 10 : aChance3)) / aInput.stackSize);
}
} catch (Throwable e) {/*Do nothing*/}
}
if (GregTech_API.sRecipeFile.get(ConfigCategories.Machines.pulverization, aInput, true)) {
if (aOutput2 == null)
ThermalExpansion.addPulverizerRecipe(32000, GT_Utility.copy(aInput), GT_Utility.copy(aOutput1));
else
ThermalExpansion.addPulverizerRecipe(32000, GT_Utility.copy(aInput), GT_Utility.copy(aOutput1), GT_Utility.copy(aOutput2), aChance2 <= 0 ? 10 : aChance2);
}
}
}
}
return true;
}
/**
* Adds a Recipe to the Sawmills of GregTech and ThermalCraft
*/
public static boolean addSawmillRecipe(ItemStack aInput1, ItemStack aOutput1, ItemStack aOutput2) {
aOutput1 = GT_OreDictUnificator.get(true, aOutput1);
aOutput2 = GT_OreDictUnificator.get(true, aOutput2);
if (aInput1 == null || aOutput1 == null) return false;
if (!GregTech_API.sRecipeFile.get(ConfigCategories.Machines.sawmill, aInput1, true)) return false;
try {
ThermalExpansion.addSawmillRecipe(1600, aInput1, aOutput1, aOutput2, 100);
} catch (Throwable e) {/*Do nothing*/}
return true;
}
/**
* Induction Smelter Recipes and Alloy Smelter Recipes
*/
public static boolean addAlloySmelterRecipe(ItemStack aInput1, ItemStack aInput2, ItemStack aOutput1, int aDuration, int aEUt, boolean aAllowSecondaryInputEmpty) {
if (aInput1 == null || (aInput2 == null && !aAllowSecondaryInputEmpty) || aOutput1 == null) return false;
aOutput1 = GT_OreDictUnificator.get(true, aOutput1);
boolean temp = false;
if (RA.addAlloySmelterRecipe(aInput1, aInput2, aOutput1, aDuration, aEUt)) temp = true;
if (addInductionSmelterRecipe(aInput1, aInput2, aOutput1, null, aDuration * aEUt * 2, 0)) temp = true;
return temp;
}
/**
* Induction Smelter Recipes for TE
*/
public static boolean addInductionSmelterRecipe(ItemStack aInput1, ItemStack aInput2, ItemStack aOutput1, ItemStack aOutput2, int aEnergy, int aChance) {
aOutput1 = GT_OreDictUnificator.get(true, aOutput1);
aOutput2 = GT_OreDictUnificator.get(true, aOutput2);
if (aInput1 == null || aOutput1 == null || GT_Utility.getContainerItem(aInput1, false) != null) return false;
if (!GregTech_API.sRecipeFile.get(ConfigCategories.Machines.inductionsmelter, aInput2 == null ? aInput1 : aOutput1, true))
return false;
try {
ThermalExpansion.addSmelterRecipe(aEnergy * 10, GT_Utility.copy(aInput1), aInput2 == null ? new ItemStack(Blocks.sand, 1, 0) : aInput2, aOutput1, aOutput2, aChance);
} catch (Throwable e) {/*Do nothing*/}
return true;
}
/**
* Smelts Ores to Ingots
*/
public static boolean addOreToIngotSmeltingRecipe(ItemStack aInput, ItemStack aOutput) {
aOutput = GT_OreDictUnificator.get(true, aOutput);
if (aInput == null || aOutput == null) return false;
FurnaceRecipes.smelting().func_151394_a(aInput, GT_Utility.copy(aOutput), 0.0F);
return true;
}
public static Map getExtractorRecipeList() {
try {
return ic2.api.recipe.Recipes.extractor.getRecipes();
} catch (Throwable e) {/*Do nothing*/}
return sExtractorRecipes;
}
public static Map getCompressorRecipeList() {
try {
return ic2.api.recipe.Recipes.compressor.getRecipes();
} catch (Throwable e) {/*Do nothing*/}
return sCompressorRecipes;
}
public static Map getMaceratorRecipeList() {
try {
return ic2.api.recipe.Recipes.macerator.getRecipes();
} catch (Throwable e) {/*Do nothing*/}
return sMaceratorRecipes;
}
public static Map getThermalCentrifugeRecipeList() {
try {
return ic2.api.recipe.Recipes.centrifuge.getRecipes();
} catch (Throwable e) {/*Do nothing*/}
return sThermalCentrifugeRecipes;
}
public static Map getOreWashingRecipeList() {
try {
return ic2.api.recipe.Recipes.oreWashing.getRecipes();
} catch (Throwable e) {/*Do nothing*/}
return sOreWashingRecipes;
}
public static Map getMassFabricatorList() {
try {
return ic2.api.recipe.Recipes.matterAmplifier.getRecipes();
} catch (Throwable e) {/*Do nothing*/}
return sMassfabRecipes;
}
/**
* IC2-ThermalCentrifuge Recipe. Overloads old Recipes automatically
*/
public static boolean addThermalCentrifugeRecipe(ItemStack aInput, int aHeat, Object... aOutput) {
if (aInput == null || aOutput == null || aOutput.length <= 0 || aOutput[0] == null) return false;
GT_Utility.removeSimpleIC2MachineRecipe(aInput, getThermalCentrifugeRecipeList(), null);
if (!GregTech_API.sRecipeFile.get(ConfigCategories.Machines.thermalcentrifuge, aInput, true)) return false;
NBTTagCompound tNBT = new NBTTagCompound();
tNBT.setInteger("minHeat", aHeat);
GT_Utility.addSimpleIC2MachineRecipe(aInput, getThermalCentrifugeRecipeList(), tNBT, aOutput);
return true;
}
/**
* IC2-OreWasher Recipe. Overloads old Recipes automatically
*/
public static boolean addOreWasherRecipe(ItemStack aInput, int aWaterAmount, Object... aOutput) {
if (aInput == null || aOutput == null || aOutput.length <= 0 || aOutput[0] == null) return false;
GT_Utility.removeSimpleIC2MachineRecipe(aInput, getOreWashingRecipeList(), null);
if (!GregTech_API.sRecipeFile.get(ConfigCategories.Machines.orewashing, aInput, true)) return false;
NBTTagCompound tNBT = new NBTTagCompound();
tNBT.setInteger("amount", aWaterAmount);
GT_Utility.addSimpleIC2MachineRecipe(aInput, getOreWashingRecipeList(), tNBT, aOutput);
return true;
}
/**
* IC2-Compressor Recipe. Overloads old Recipes automatically
*/
public static boolean addCompressionRecipe(ItemStack aInput, ItemStack aOutput) {
aOutput = GT_OreDictUnificator.get(true, aOutput);
if (aInput == null || aOutput == null) return false;
GT_Utility.removeSimpleIC2MachineRecipe(aInput, getCompressorRecipeList(), null);
if (!GregTech_API.sRecipeFile.get(ConfigCategories.Machines.compression, aInput, true)) return false;
GT_Utility.addSimpleIC2MachineRecipe(aInput, getCompressorRecipeList(), null, aOutput);
return true;
}
/**
* @param aValue Scrap = 5000, Scrapbox = 45000, Diamond Dust 125000
*/
public static boolean addIC2MatterAmplifier(ItemStack aAmplifier, int aValue) {
if (aAmplifier == null || aValue <= 0) return false;
if (!GregTech_API.sRecipeFile.get(ConfigCategories.Machines.massfabamplifier, aAmplifier, true)) return false;
try {
NBTTagCompound tNBT = new NBTTagCompound();
tNBT.setInteger("amplification", aValue);
GT_Utility.callMethod(ic2.api.recipe.Recipes.matterAmplifier, "addRecipe", false, false, false, aAmplifier, tNBT);
} catch (Throwable e) {/*Do nothing*/}
return true;
}
/**
* Rolling Machine Crafting Recipe
*/
public static boolean addRollingMachineRecipe(ItemStack aResult, Object[] aRecipe) {
aResult = GT_OreDictUnificator.get(true, aResult);
if (aResult == null || aRecipe == null || aResult.stackSize <= 0) return false;
try {
mods.railcraft.api.crafting.RailcraftCraftingManager.rollingMachine.getRecipeList().add(new ShapedOreRecipe(GT_Utility.copy(aResult), aRecipe));
} catch (Throwable e) {
return addCraftingRecipe(GT_Utility.copy(aResult), aRecipe);
}
return true;
}
public static void stopBufferingCraftingRecipes() {
sBufferCraftingRecipes = false;
for (IRecipe tRecipe : sBufferRecipeList) GameRegistry.addRecipe(tRecipe);
sBufferRecipeList.clear();
}
/**
* Shapeless Crafting Recipes. Deletes conflicting Recipes too.
*/
public static boolean addCraftingRecipe(ItemStack aResult, Enchantment[] aEnchantmentsAdded, int[] aEnchantmentLevelsAdded, Object[] aRecipe) {
return addCraftingRecipe(aResult, aEnchantmentsAdded, aEnchantmentLevelsAdded, false, true, false, false, false, false, false, false, false, false, false, false, true, aRecipe);
}
/**
* Regular Crafting Recipes. Deletes conflicting Recipes too.
*
* You can insert instances of IItemContainer into the Recipe Input Array directly without having to call "get(1)" on them.
*
* Enums are automatically getting their "name()"-Method called in order to deliver an OreDict String.
*
* Lowercase Letters are reserved for Tools. They are as follows:
*
* 'b' ToolDictNames.craftingToolBlade
* 'c' ToolDictNames.craftingToolCrowbar,
* 'd' ToolDictNames.craftingToolScrewdriver,
* 'f' ToolDictNames.craftingToolFile,
* 'h' ToolDictNames.craftingToolHardHammer,
* 'i' ToolDictNames.craftingToolSolderingIron,
* 'j' ToolDictNames.craftingToolSolderingMetal,
* 'k' ToolDictNames.craftingToolKnive
* 'm' ToolDictNames.craftingToolMortar,
* 'p' ToolDictNames.craftingToolDrawplate,
* 'r' ToolDictNames.craftingToolSoftHammer,
* 's' ToolDictNames.craftingToolSaw,
* 'w' ToolDictNames.craftingToolWrench,
* 'x' ToolDictNames.craftingToolWireCutter,
*/
public static boolean addCraftingRecipe(ItemStack aResult, Object[] aRecipe) {
return addCraftingRecipe(aResult, 0, aRecipe);
}
/**
* Regular Crafting Recipes. Deletes conflicting Recipes too.
*
* You can insert instances of IItemContainer into the Recipe Input Array directly without having to call "get(1)" on them.
*
* Enums are automatically getting their "name()"-Method called in order to deliver an OreDict String.
*
* Lowercase Letters are reserved for Tools. They are as follows:
*
* 'b' ToolDictNames.craftingToolBlade
* 'c' ToolDictNames.craftingToolCrowbar,
* 'd' ToolDictNames.craftingToolScrewdriver,
* 'f' ToolDictNames.craftingToolFile,
* 'h' ToolDictNames.craftingToolHardHammer,
* 'i' ToolDictNames.craftingToolSolderingIron,
* 'j' ToolDictNames.craftingToolSolderingMetal,
* 'k' ToolDictNames.craftingToolKnive
* 'm' ToolDictNames.craftingToolMortar,
* 'p' ToolDictNames.craftingToolDrawplate,
* 'r' ToolDictNames.craftingToolSoftHammer,
* 's' ToolDictNames.craftingToolSaw,
* 'w' ToolDictNames.craftingToolWrench,
* 'x' ToolDictNames.craftingToolWireCutter,
*/
public static boolean addCraftingRecipe(ItemStack aResult, long aBitMask, Object[] aRecipe) {
return addCraftingRecipe(aResult, new Enchantment[0], new int[0], (aBitMask & RecipeBits.MIRRORED) != 0, (aBitMask & RecipeBits.BUFFERED) != 0, (aBitMask & RecipeBits.KEEPNBT) != 0, (aBitMask & RecipeBits.DISMANTLEABLE) != 0, (aBitMask & RecipeBits.NOT_REMOVABLE) == 0, (aBitMask & RecipeBits.REVERSIBLE) != 0, (aBitMask & RecipeBits.DELETE_ALL_OTHER_RECIPES) != 0, (aBitMask & RecipeBits.DELETE_ALL_OTHER_RECIPES_IF_SAME_NBT) != 0, (aBitMask & RecipeBits.DELETE_ALL_OTHER_SHAPED_RECIPES) != 0, (aBitMask & RecipeBits.DELETE_ALL_OTHER_NATIVE_RECIPES) != 0, (aBitMask & RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS) == 0, (aBitMask & RecipeBits.ONLY_ADD_IF_THERE_IS_ANOTHER_RECIPE_FOR_IT) != 0, (aBitMask & RecipeBits.ONLY_ADD_IF_RESULT_IS_NOT_NULL) != 0, aRecipe);
}
/**
* Internal realisation of the Crafting Recipe adding Process.
*/
private static boolean addCraftingRecipe(ItemStack aResult, Enchantment[] aEnchantmentsAdded, int[] aEnchantmentLevelsAdded, boolean aMirrored, boolean aBuffered, boolean aKeepNBT, boolean aDismantleable, boolean aRemovable, boolean aReversible, boolean aRemoveAllOthersWithSameOutput, boolean aRemoveAllOthersWithSameOutputIfTheyHaveSameNBT, boolean aRemoveAllOtherShapedsWithSameOutput, boolean aRemoveAllOtherNativeRecipes, boolean aCheckForCollisions, boolean aOnlyAddIfThereIsAnyRecipeOutputtingThis, boolean aOnlyAddIfResultIsNotNull, Object[] aRecipe) {
aResult = GT_OreDictUnificator.get(true, aResult);
if (aOnlyAddIfResultIsNotNull && aResult == null) return false;
if (aResult != null && Items.feather.getDamage(aResult) == W) Items.feather.setDamage(aResult, 0);
if (aRecipe == null || aRecipe.length <= 0) return false;
boolean tThereWasARecipe = false;
for (byte i = 0; i < aRecipe.length; i++) {
if (aRecipe[i] instanceof IItemContainer)
aRecipe[i] = ((IItemContainer) aRecipe[i]).get(1);
else if (aRecipe[i] instanceof Enum)
aRecipe[i] = ((Enum) aRecipe[i]).name();
else if (!(aRecipe[i] == null || aRecipe[i] instanceof ItemStack || aRecipe[i] instanceof ItemData || aRecipe[i] instanceof String || aRecipe[i] instanceof Character))
aRecipe[i] = aRecipe[i].toString();
}
try {
String shape = E;
int idx = 0;
if (aRecipe[idx] instanceof Boolean) {
throw new IllegalArgumentException();
}
ArrayList