-
Notifications
You must be signed in to change notification settings - Fork 755
/
LiquidCasting.java
178 lines (164 loc) · 5.48 KB
/
LiquidCasting.java
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
package tconstruct.library.crafting;
import java.util.ArrayList;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import tconstruct.library.client.FluidRenderProperties;
/* Melting becomes hardened */
public class LiquidCasting
{
// public static LiquidCasting instance = new LiquidCasting();
private final ArrayList<CastingRecipe> casts = new ArrayList<CastingRecipe>();
private boolean contains (CastingRecipe recipe)
{
for (CastingRecipe c : casts)
{
if (c.matches(recipe.castingMetal, recipe.cast))
return true;
}
return false;
}
/**
* Adds a casting recipe
*
* @param output
* Result of the cast
* @param metal
* Liquid to be used in casting. This also decides how much metal
* is consumed
* @param cast
* The empty item to cast with. ex Ingot Cast
* @param consume
* Whether the item should be consumed while casting
* @param delay
* Time to cast in ticks
* @param props
* The rendering properties for the casting fluid (may be null)
*/
public void addCastingRecipe (ItemStack output, FluidStack metal, ItemStack cast, boolean consume, int delay, FluidRenderProperties props)
{
CastingRecipe cr = new CastingRecipe(output, metal, cast, consume, delay, props);
if (!contains(cr))
casts.add(cr);
}
/**
* Adds a casting recipe
*
* @param output
* Result of the cast
* @param metal
* Liquid to be used in casting. This also decides how much metal
* is consumed
* @param cast
* The empty item to cast with. ex Ingot Cast
* @param consume
* Whether the item should be consumed while casting
* @param delay
* Time to cast in ticks
*/
public void addCastingRecipe (ItemStack output, FluidStack metal, ItemStack cast, boolean consume, int delay)
{
addCastingRecipe(output, metal, cast, consume, delay, null);
}
/**
* Adds a casting recipe. Does not consume the cast
*
* @param output
* Result of the cast
* @param metal
* Liquid to be used in casting. This also decides how much metal
* is consumed
* @param cast
* The empty item to cast with. ex Ingot Cast
* @param delay
* Time to cast in ticks
* @param props
* The rendering properties for the casting fluid (may be null)
*/
public void addCastingRecipe (ItemStack output, FluidStack metal, ItemStack cast, int delay, FluidRenderProperties props)
{
addCastingRecipe(output, metal, cast, false, delay, props);
}
/**
* Adds a casting recipe. Does not consume the cast
*
* @param output
* Result of the cast
* @param metal
* Liquid to be used in casting. This also decides how much metal
* is consumed
* @param cast
* The empty item to cast with. ex Ingot Cast
* @param delay
* Time to cast in ticks
*/
public void addCastingRecipe (ItemStack output, FluidStack metal, ItemStack cast, int delay)
{
addCastingRecipe(output, metal, cast, false, delay, null);
}
/**
* Adds a casting recipe. Does not consume the cast or have an item to cast
* against
*
* @param output
* Result of the cast
* @param metal
* Liquid to be used in casting. This also decides how much metal
* is consumed
* @param delay
* Time to cast in ticks
* @param props
* The rendering properties for the casting fluid (may be null)
*/
public void addCastingRecipe (ItemStack output, FluidStack metal, int delay, FluidRenderProperties props)
{
addCastingRecipe(output, metal, null, false, delay, props);
}
/**
* Adds a casting recipe. Does not consume the cast or have an item to cast
* against
*
* @param output
* Result of the cast
* @param metal
* Liquid to be used in casting. This also decides how much metal
* is consumed
* @param delay
* Time to cast in ticks
*/
public void addCastingRecipe (ItemStack output, FluidStack metal, int delay)
{
addCastingRecipe(output, metal, null, false, delay, null);
}
public void addCustomCastingRecipe (CastingRecipe recipe)
{
casts.add(recipe);
}
public int getCastingDelay (FluidStack metal, ItemStack cast)
{
CastingRecipe recipe = getCastingRecipe(metal, cast);
if (recipe != null)
return recipe.coolTime;
return -1;
}
public int getCastingAmount (FluidStack metal, ItemStack cast)
{
CastingRecipe recipe = getCastingRecipe(metal, cast);
if (recipe != null)
return recipe.castingMetal.amount;
return 0;
}
public CastingRecipe getCastingRecipe (FluidStack metal, ItemStack cast)
{
for (CastingRecipe recipe : casts)
{
if (recipe.matches(metal, cast))
return recipe;
}
return null;
}
// Getter for public viewing
public ArrayList<CastingRecipe> getCastingRecipes ()
{
return casts;
}
}