use of crafttweaker.mc1120.actions.ActionAddFurnaceRecipe in project CraftTweaker by CraftTweaker.
the class MCFurnaceManager method addRecipe.
@Override
public void addRecipe(IItemStack output, IIngredient input, @Optional double xp) {
List<IItemStack> items = input.getItems();
if (items == null) {
CraftTweakerAPI.logError("Cannot turn " + input.toString() + " into a furnace recipe");
return;
}
ItemStack[] items2 = getItemStacks(items);
ItemStack output2 = getItemStack(output);
recipesToAdd.add(new ActionAddFurnaceRecipe(input, items2, output2, xp));
}
use of crafttweaker.mc1120.actions.ActionAddFurnaceRecipe in project GregTech by GregTechCEu.
the class ModHandler method removeSmeltingEBFMetals.
/* Note: If a Furnace recipe is added through CT that is the exact same as one of the recipes that will be removed
then this recipe will not be added. Forge will prevent the duplicate smelting recipe from being added before we
remove the recipe added by another mod, therefore the CT recipe will fail. At this point, disable the config and
remove the recipes manually
*/
public static void removeSmeltingEBFMetals() {
boolean isCTLoaded = Loader.isModLoaded(GTValues.MODID_CT);
Field actionAddFurnaceRecipe$output = null;
Map<ItemStack, ItemStack> furnaceList = FurnaceRecipes.instance().getSmeltingList();
Iterator<Map.Entry<ItemStack, ItemStack>> recipeIterator = furnaceList.entrySet().iterator();
outer: while (recipeIterator.hasNext()) {
Map.Entry<ItemStack, ItemStack> recipe = recipeIterator.next();
ItemStack output = recipe.getValue();
ItemStack input = recipe.getKey();
MaterialStack ms = OreDictUnifier.getMaterial(output);
if (ms != null) {
Material material = ms.material;
if (material.hasProperty(PropertyKey.BLAST)) {
ItemStack dust = OreDictUnifier.get(OrePrefix.dust, material);
ItemStack ingot = OreDictUnifier.get(OrePrefix.ingot, material);
// Check if the inputs are actually dust -> ingot
if (ingot.isItemEqual(output) && dust.isItemEqual(input)) {
if (isCTLoaded) {
if (actionAddFurnaceRecipe$output == null) {
try {
actionAddFurnaceRecipe$output = ActionAddFurnaceRecipe.class.getDeclaredField("output");
actionAddFurnaceRecipe$output.setAccessible(true);
} catch (NoSuchFieldException e) {
e.printStackTrace();
}
}
for (ActionAddFurnaceRecipe aafr : MCFurnaceManager.recipesToAdd) {
try {
// ..was a cached stack in an existing ActionAddFurnaceRecipe as well
if (actionAddFurnaceRecipe$output.get(aafr) == output) {
if (ConfigHolder.misc.debug) {
GTLog.logger.info("Not removing Smelting Recipe for EBF material {} as it is added via CT", LocalizationUtils.format(material.getUnlocalizedName()));
}
continue outer;
}
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}
recipeIterator.remove();
if (ConfigHolder.misc.debug) {
GTLog.logger.info("Removing Smelting Recipe for EBF material {}", LocalizationUtils.format(material.getUnlocalizedName()));
}
}
}
}
}
}
Aggregations