-
Notifications
You must be signed in to change notification settings - Fork 1
/
BettertakeaPowerTool.cs
123 lines (119 loc) · 4.46 KB
/
BettertakeaPowerTool.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using System.Collections.Generic;
namespace BettertakeaPowerTool
{
class BettertakeaPowerTool : Mod
{
public static string ConfigFileRelativePath
{
get { return "Mod Configs/BettertakeaPowerTool.json"; }
}
public static void ReloadConfigFromFile()
{
// Define implementation to reload your mod's config data from file
}
public static string GithubUserName { get { return "dennisw100"; } }
public static string GithubProjectName { get { return "Terraria-Better-take-a-Power-Tool"; } }
public BettertakeaPowerTool()
{//sets propeties of the mod
Properties = new ModProperties()
{
Autoload = true,
AutoloadGores = true,
AutoloadSounds = true
};
}
public override void Load()
{
Config.Load();
List<short> list = new List<short>(Extensions.LunarTools);
list.ForEach(x =>ItemID.Sets.Deprecated[x] = false);
}
public override void PostAddRecipes()
{
Mod tremor = ModLoader.GetMod("Tremor");
if (tremor != null && Config.DommhammerjackhammerSettings == 2)
{
RecipeFinder finder = new RecipeFinder(); // make a new RecipeFinder
finder.AddIngredient(ItemID.Pwnhammer); // add a new recipe group, in this case the vanilla one for iron or lead bars.
finder.AddIngredient(tremor.ItemType("DarkBulb"), 15);
finder.AddIngredient(ItemID.Bone, 100);
finder.AddTile(TileID.MythrilAnvil); // add a required tile, any anvil
finder.SetResult(tremor.ItemType("Squasher")); // set the result to be 10 chains
Recipe exactRecipe = finder.FindExactRecipe(); // try to find the exact recipe matching our criteria
bool isRecipeFound = exactRecipe != null; // if our recipe is not null, it means we found the exact recipe
if (isRecipeFound) // since our recipe is found, we can continue
{
RecipeEditor editor = new RecipeEditor(exactRecipe); // for our recipe, make a new RecipeEditor
editor.DeleteRecipe(); // delete the recipe
}
}
}
public override void AddRecipes()
{//adds crafting recepies
Extensions.DestroyRecipes();
Extensions.MakeSolarRecipes(this);
Extensions.MakeNebulaRecipes(this);
Extensions.MakeVortexRecipes(this);
Extensions.MakeStardustRecipes(this);
}
}
internal static class Extensions
{
public static short[] LunarTools =
{
ItemID.SolarFlareDrill,
ItemID.NebulaDrill,
ItemID.VortexDrill,
ItemID.StardustDrill,
};
public const short LunarBar = 3467;
public const short AncientManipulator = 412;
public static void MakeRecipe(ModRecipe recipe, short fragmentType, int fragmentAmount, int barAmount)
{
recipe.AddIngredient(fragmentType, fragmentAmount);
recipe.AddIngredient(LunarBar, barAmount);
recipe.AddTile(AncientManipulator);
}
public static void DestroyRecipes()
{
foreach (short lunarTool in LunarTools)
{
RecipeFinder finder = new RecipeFinder();
finder.SetResult(lunarTool);
List<Terraria.Recipe> recipes = finder.SearchRecipes();
recipes.ForEach(x => { var editor = new RecipeEditor(x); editor.DeleteRecipe();});
}
}
public static void MakeSolarRecipes(Mod mod)
{
ModRecipe recipe = new ModRecipe(mod);
MakeRecipe(recipe, ItemID.FragmentSolar, 12, 10);
recipe.SetResult(ItemID.SolarFlareDrill);
recipe.AddRecipe();
}
public static void MakeNebulaRecipes(Mod mod)
{
ModRecipe recipe = new ModRecipe(mod);
MakeRecipe(recipe, ItemID.FragmentNebula, 12, 10);
recipe.SetResult(ItemID.NebulaDrill);
recipe.AddRecipe();
}
public static void MakeVortexRecipes(Mod mod)
{
ModRecipe recipe = new ModRecipe(mod);
MakeRecipe(recipe, ItemID.FragmentVortex, 12, 10);
recipe.SetResult(ItemID.VortexDrill);
recipe.AddRecipe();
}
public static void MakeStardustRecipes(Mod mod)
{
ModRecipe recipe = new ModRecipe(mod);
MakeRecipe(recipe, ItemID.FragmentStardust, 12, 10);
recipe.SetResult(ItemID.StardustDrill);
recipe.AddRecipe();
}
}
}