#priority 5 import crafttweaker.item.IItemStack; import crafttweaker.item.IIngredient; import crafttweaker.oredict.IOreDictEntry; import crafttweaker.data.IData; import crafttweaker.block.IBlock; #MC Eternal Scripts print("--- loading GlobalFuncs.zs ---"); global getFTBCrate as function(string) IItemStack = function (id as string) as IItemStack { return .withTag({type: id as IData}); }; global addMultilineLocalizedTooltip as function(IItemStack, string) void = function (item as IItemStack, key as string) as void { for line in game.localize(key).split("
") { item.addTooltip(format.gold(line)); } }; //Get an IItemStack from an IIngredient // returns as IItemStack if the IIngredient is an IItemStack, or the first entry in the oredict entry if it is an IOreDictEntry. // mainly used to allow a function (see below) to produce a Thermal Expansion Alloy Smelter recipe from an IIngredient set of parameters // aswell as generate Copy-pastable XML data for EnderIO's Alloy Smelter and Advanced Rocketry's Arc Furnace global getIngredientItemstack as function(IIngredient) IItemStack = function (ingredient as IIngredient) as IItemStack { if(ingredient instanceof IOreDictEntry){ val oreDictEntry as IOreDictEntry = ingredient; val castedIngredient as IItemStack = oreDictEntry.firstItem; return castedIngredient; } else { val castedIngredient as IItemStack = ingredient; return castedIngredient; } }; global alloyingBaseStats as int[string] = { "IESmelterTime": 200, "IEArcEnergy": 512, "thermalInductionEnergy": 4000, "NCFurnaceTime": 400, "NCFurnaceEnergy": 10, "TRSmelterTime": 200, "TRSmelterEnergy": 20, //The XML siblings "ARArcTime": 10, "ARArcEnergy": 10000, "EIOSmelterEnergy": 10000 }; //Simultaneously add an Alloying recipe to various Alloying machines /* Adds recipes to: IE's Arc Furnace Thermal's Induction Smelter Nuclearcraft's Alloy Furnace TechReborn's Alloy Furnace/Smelter // Generates XML Data for: EnderIO's Alloy Smeltery Advanced Rocketry's Arc Furnace */ global addUniversalAlloyRecipe as function(IItemStack, IIngredient[], string, bool, int[string][string]) void = function (result as IItemStack, ingredients as IIngredient[], recipeID as string, enableXMLPrint as bool, parameterMap as int[string][string]) as void { //IE Arc Furnace if(!isNull(parameterMap.IEArc) && !isNull(parameterMap.IEArc.enabled) ? parameterMap.IEArc.enabled == 1 : true){ var ingredientArrayWithoutFirst as IIngredient[] = []; for entry in ingredients { if(!(ingredients[0] in entry)) ingredientArrayWithoutFirst += entry; } mods.immersiveengineering.ArcFurnace.addRecipe(result, ingredients[0], null, (!isNull(parameterMap.IEArc) && !isNull(parameterMap.IEArc.time) ? parameterMap.IEArc.time : alloyingBaseStats.IESmelterTime), (!isNull(parameterMap.IEArc) && !isNull(parameterMap.IEArc.energy) ? parameterMap.IEArc.energy : alloyingBaseStats.IEArcEnergy), ingredientArrayWithoutFirst ); } if(enableXMLPrint){ var ARXMLIngredients as string = ""; var EIOXMLIngredients as string = ""; for ing in ingredients { val typedIngredient = getIngredientItemstack(ing); ARXMLIngredients += typedIngredient instanceof IItemStack ? ' '+ typedIngredient.definition.id +';'+ typedIngredient.amount +';'+ typedIngredient.metadata +'' : ' '+ typedIngredient.name +';'+ typedIngredient.amount +''; EIOXMLIngredients += typedIngredient instanceof IItemStack ? ' ' : ' '; } //AR Electric Arc Furnace XML Printing print("AR XML for "+ result.definition.id); print( ' '+ ARXMLIngredients +' '+ result.definition.id +';'+ result.amount +';'+ result.metadata +' ' ); if(ingredients.length < 4){ //EnderIO Alloy Smelter XML Printing print("EIO XML for "+ result.definition.id); print( ' '+ EIOXMLIngredients +' ' ); } } if(ingredients.length < 3){ //Thermal Induction Smelter if(!isNull(parameterMap.thermalInduction) && !isNull(parameterMap.thermalInduction.enabled) ? parameterMap.thermalInduction.enabled == 1 : true) mods.thermalexpansion.InductionSmelter.addRecipe(result, getIngredientItemstack(ingredients[0]), getIngredientItemstack(ingredients[1]), (!isNull(parameterMap.thermalInduction) && !isNull(parameterMap.thermalInduction.energy) ? parameterMap.thermalInduction.energy : alloyingBaseStats.thermalInductionEnergy) ); //Nuclearcraft Alloy Furnace if(!isNull(parameterMap.NCFurnace) && !isNull(parameterMap.NCFurnace.enabled) ? parameterMap.NCFurnace.enabled == 1 : true) mods.nuclearcraft.alloy_furnace.addRecipe([ingredients[0], ingredients[1], result, (!isNull(parameterMap.NCFurnace) && !isNull(parameterMap.NCFurnace.time) ? parameterMap.NCFurnace.time : alloyingBaseStats.NCFurnaceTime) / 400, (!isNull(parameterMap.NCFurnace) && !isNull(parameterMap.NCFurnace.energy) ? parameterMap.NCFurnace.energy : alloyingBaseStats.NCFurnaceEnergy) / 10 ]); //TechReborn Alloy Smelter if(!isNull(parameterMap.TRSmelter) && !isNull(parameterMap.TRSmelter.enabled) ? parameterMap.TRSmelter.enabled == 1 : true) mods.techreborn.alloySmelter.addRecipe(result, ingredients[0], ingredients[1], (!isNull(parameterMap.TRSmelter) && !isNull(parameterMap.TRSmelter.time) ? parameterMap.TRSmelter.time : alloyingBaseStats.TRSmelterTime), (!isNull(parameterMap.TRSmelter) && !isNull(parameterMap.TRSmelter.energy) ? parameterMap.TRSmelter.energy : alloyingBaseStats.TRSmelterEnergy) ); //Immersive Engineering Alloy Kiln if(!isNull(parameterMap.IEKiln) && !isNull(parameterMap.IEKiln.enabled) ? parameterMap.IEKiln.enabled == 1 : true) mods.immersiveengineering.AlloySmelter.addRecipe(result, ingredients[0], ingredients[1], (!isNull(parameterMap.IEKiln) && !isNull(parameterMap.IEKiln.time) ? parameterMap.IEKiln.time : alloyingBaseStats.IESmelterTime) ); } }; //Fetch a Tinkers' tool part's ID as a string by using a shorthand name global tconPart as string[string] = { "binding": "tconstruct:binding", "toolrod": "tconstruct:tool_rod", "handguard": "tconstruct:hand_guard", "knifeblade": "tconstruct:knife_blade", "wideguard": "tconstruct:wide_guard", "crossguard": "tconstruct:cross_guard", "armortrim": "conarm:armor_trim", "arrowhead": "tconstruct:arrow_head", "sharpeningkit": "tconstruct:sharpening_kit", "axehead": "tconstruct:axe_head", "shovelhead": "tconstruct:shovel_head", "kamahead": "tconstruct:kama_head", "swordblade": "tconstruct:sword_blade", "pickhead": "tconstruct:pick_head", "bowlimb": "tconstruct:bow_limb", "signhead": "tconstruct:sign_head", "toughrod": "tconstruct:tough_tool_rod", "toughbind": "tconstruct:tough_binding", "armorplate": "conarm:armor_plate", "armorplate": "tconstruct:pan_head", "helmcore": "conarm:helmet_core", "bootscore": "conarm:boots_core", "legscore": "conarm:leggings_core", "chestcore": "conarm:chest_core", "scythehead": "tconstruct:scythe_head", "largeblade": "tconstruct:large_sword_blade", "largeplate": "tconstruct:large_plate", "hammerhead": "tconstruct:hammer_head", "excavatorhead": "tconstruct:excavator_head", "broadaxehead": "tconstruct:broad_axe_head" }; //Fetch a Tinkers' part of a specified material using the shorthand map name and material name global getTconPart as function(string, string) IItemStack = function (part as string, mat as string) as IItemStack { return itemUtils.getItem(tconPart[part]).withTag({Material: mat}); }; //Fetch an AE resource's IItemStack from a shorthand name, instead of a magic number global AEMaterials as IItemStack[string] = { "engCircuit": , "logicCircuit": , "calcCircuit": , "1kComponent": , "4kComponent": , "16kComponent": , "64kComponent": , "1kFluid": , "4kFluid": , "16kFluid": , "64kFluid": , "printEng": , "printCalc": , "printLogic": , "printSil": , "pressEng": , "pressCalc": , "pressLogic": , "pressSil": , "coveredCable": , "quartzFiber": , "glassCable": , "denseCable": , "vibrantQuartzGlass": , "quartzGlass": , "coreAnnihil": , "coreFormation": }; //Get Botania flower with its String ID global getBotaniaFlower as function(string) IItemStack = function (flowerName as string) as IItemStack { return .withTag({type: flowerName}); }; //Simple function to remove an item's Crafting table recipes and add a "disabled" tooltip to it global basicDisable as function(IItemStack, string, bool, bool) void = function (item as IItemStack, recipeID as string, removeByRecipeID as bool, isChallengeOnly as bool) as void { val tooltipType = isChallengeOnly ? "mce.generic.tip.challengemode_disabled" : "mce.generic.tip.disabled"; item.addTooltip(format.red(game.localize(tooltipType))); if(removeByRecipeID){ recipes.removeByRecipeName(recipeID); } else { recipes.remove(item); } }; //"Simple" function to simultaneously add a Salis Mundus conversion, and add a tooltip to the Result item global addSalisMundusConversion as function(IItemStack, IIngredient, bool) void = function (result as IItemStack, input as IIngredient, isInputOredict as bool) as void { val debugThis = false; var tooltipString as string = "mce.generic.tip.salis_mundus_craft"; var inputStack as IItemStack = ; var inputDict as IOreDictEntry = ; if(!isInputOredict){ inputStack = getIngredientItemstack(input); tooltipString = game.localize(tooltipString +".specific_mod_block").replace("%s", inputStack.displayName).replace("%m", game.localize("itemGroup."+ inputStack.definition.owner)); } else if(input instanceof IOreDictEntry){ val inputTemp as IOreDictEntry = input; inputDict = inputTemp; tooltipString = game.localize(tooltipString).replace("%s", inputDict.name); } for line in tooltipString.split("
") { result.addTooltip(format.gold(line)); } if(debugThis){ print("Information for Salis Mundus conversion to "+ result.displayName); print("Input is Oredict: "+ isInputOredict); print("Tooltip: "+ tooltipString); print("Input Block: "+ isInputOredict ? inputDict.name : inputStack.commandString); } if(!isInputOredict){ mods.thaumcraft.SalisMundus.addSingleConversion(inputStack, result); } else if(isInputOredict){ mods.thaumcraft.SalisMundus.addSingleConversion(inputDict, result); } if(.matches(inputStack)){ print("Salis Mundus Conversion for "+ result.displayName +" has an input of Stone, is this intentional, or did the fallback activate?"); } }; //Fetch an Astral Sorcery Marble variant by a shorthand name, instead of a magic number global blockMarble as IItemStack[string] = { "normal": , "brick": , "pillar": , "arch": , "chiseled": , "engraved": , "runed": , "normalSooty": , "brickSooty": , "pillarSooty": , "archSooty": , "chiseledSooty": , "engravedSooty": , "runedSooty": }; //Fetch one of a handful of Botania materials by a shorthand name, instead of a magic number global manaResource as IItemStack[string] = { "manaString": , "manaCloth": , "manaNugget": , "manasteel": , "manasteelBlock": , "manaPearl": , "manaDiamond": , "manaDiamondBlock": , "manaPowder": , "elementiumNugget": , "elementium": , "elementiumBlock": , "pixieDust": , "dragonstone": , "dragonstoneBlock": , "terrasteelNugget": , "terrasteel": , "terrasteelBlock": , "gaiaSpirit": , "gaiaIngot": }; global MAEssenceTier as int[string] = { "prosperity": -1, "inferium": 0, "prudentium": 1, "intermedium": 2, "superium": 3, "supremium": 4 }; global MAResourceMap as int[string] = { "ingot": 33, "essence": 0, "souliumDust": 29, "souliumIngot": 38 }; global getMAResource as function(string, int) IItemStack = function (resourceType as string, tier as int) as IItemStack { return itemUtils.getItem("mysticalagriculture:crafting", MAResourceMap[resourceType] + tier); }; //Fetch an EnderIO material by a shorthand name, instead of a magic number global EIOMaterial as IItemStack[string] = { "chassisSimple": , "chassisMachine": , "chassisSoul": , "chassisEndsteel": , "chassisEnhanced": , "chassisSoulless": , "organicDyeGreen": , "organicDyeBrown": , "organicDyeBlack": , "industrialDye": , "soulDye": , "enhancedDye": , "grainsPrescience": , "grainsVibrant": , "grainsPulsating": , "grainsEnd": , "capacitorBasic": , "capacitorEnhanced": , "capacitorOctadic": }; //Fetch an Immersive Engineering item by a shorthand name, instead of a magic number global IEItem as IItemStack[string] = { "redstoneEngineeringBlock": , "lightEngineeringBlock": , "heavyEngineeringBlock": , "generatorBlock": , "radiatorBlock": , "capacitorLV": , "capacitorMV": , "capacitorHV": , "redstoneBreaker": , "ironMechComponent": , "steelMechComponent": }; global AAItem as IItemStack[string] = { "ironCasing": , "woodCasing": , "blockVoid": , "blockPalis": , "blockRestonia": , "blockEnori": , "blockDiamatine": , "blockEmeradic": , "crystalVoid": , "crystalPalis": , "crystalRestonia": , "crystalEnori": , "crystalDiamatine": , "crystalEmeradic": }; //Space-related NBT items global skyScarabCrest as IItemStack = .withTag({skyScarab: true}).withDisplayName(game.localize("item.mce.atum_sky_scarab_crest.name")).withLore(game.localize("item.mce.atum_sky_scarab_crest.desc").split("
")); global kikokuStick as IItemStack = .withTag({kikokuStick: true}).withDisplayName(game.localize("item.mce.kikoku_stick.name")).withLore(game.localize("item.mce.kikoku_stick.desc").split("
")); print("--- GlobalFuncs.zs initalized ---");