for recipe in recipes.all { // 遍历游戏内所有注册配方 //用ICraftingRecipe的ingredients1D ZenGetter获取配方的材料,返回IIngredient[] if (recipe.ingredients1D has <minecraft:iron_ingot>) {recipes.removeByRecipeName(recipe.name); }}
例子二:根据OD对齿轮进行合成修改
import crafttweaker.item.IItemStack;import crafttweaker.item.IIngredient;import crafttweaker.oredict.IOreDictEntry;import crafttweaker.oredict.IOreDict;for ench in oreDict.entries /* oreDict.entries 在所有注册OD中循环 */ { var oreName as string = ench.name; var enchGear as IItemStack =ench.firstItem; // 获得OD的第一个物品 // 进行条件判断,第二个条件是当时魔改时,排除EIO充能合金齿轮等的干扰if (oreName.startsWith("gear") &&enchGear.definition.owner!="enderio") { var key as string =oreName.substring("gear".length); // 获取金属名 // 获取魔改需要的该金属的其他部件,杆和板 var stick as IOreDictEntry =oreDict.get("stick"~ key); var plate as IOreDictEntry =oreDict.get("plate"~ key); var ingot as IItemStack =oreDict.get("ingot"~ key).firstItem; // 排除空矿辞,排除木齿轮和石齿轮等的干扰if (!stick.empty&&!plate.empty) { // 经典合成修改recipes.remove(enchGear); mods.forestry.Carpenter.addRecipe(enchGear, [[stick,plate,stick], [plate,<contenttweaker:bushing>,plate], [stick,plate,stick]],6,<liquid:soldering>*72); mods.immersiveengineering.MetalPress.removeRecipe(enchGear);mods.thermalexpansion.Compactor.removeGearRecipe(ingot); mods.tconstruct.Casting.removeTableRecipe(enchGear); } }}
例子三:遍历游戏内所有物品
for mod in loadedMods { //遍历游戏内所有的模组,loadedMods一个全局关键词,包括游戏内所有模组(IMod[string])for item in mod.items { //再遍历一个模组的所有物品 recipes.remove(item); //这只是个例子!要删除游戏内所有物品的配方,用recipes.removeAll();就好了 }}