forked from gardenappl/DyeEasy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DyeEasy.cs
68 lines (60 loc) · 1.6 KB
/
DyeEasy.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
using System;
using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace DyeEasy
{
public class DyeEasy : Mod
{
List<int> changedRecipes = new List<int>();
List<int> originalStack = new List<int>();
public override void AddRecipes()
{
for(int i = 0; i < Main.recipe.Length; i++)
{
var recipe = Main.recipe[i];
if(recipe.createItem.dye != 0)
{
int dyeIngredients = 0;
var foundDyeTypes = new List<int>();
bool foundBottledWater = false;
foreach(var item in recipe.requiredItem)
{
if(item != null)
{
if(item.dye != 0)
{
dyeIngredients += item.stack;
foundDyeTypes.Add(item.type);
}
else if(item.type == ItemID.BottledWater)
foundBottledWater = true;
}
}
originalStack.Add(recipe.createItem.stack);
//Lunar dyes (ignore)
if (foundBottledWater)
continue;
//Basic dyes
if(dyeIngredients == 0)
recipe.createItem.stack = 3;
//Compound dyes
else if(foundDyeTypes.Count > 1)
recipe.createItem.stack = dyeIngredients;
changedRecipes.Add(i);
}
}
}
public override void Unload() //Reverting changes
{
foreach(int recipeIndex in changedRecipes)
if(recipeIndex < Main.recipe.Length) //You never know
Main.recipe[recipeIndex].createItem.stack = originalStack[recipeIndex];
}
//Hamstar's Mod Helpers integration
public static string GithubUserName { get { return "goldenapple3"; } }
public static string GithubProjectName { get { return "DyeEasy"; } }
}
}