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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
|
package ihl.nei_integration;
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.lwjgl.opengl.GL11;
import codechicken.lib.gui.GuiDraw;
import codechicken.nei.NEIServerUtils;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.TemplateRecipeHandler;
import ic2.api.recipe.IRecipeInput;
import ic2.api.recipe.RecipeOutput;
import ic2.core.util.StackUtil;
import net.minecraft.item.ItemStack;
public abstract class IHLRecipeHandler extends TemplateRecipeHandler
{
protected int ticks;
@Override
public abstract String getRecipeName();
public abstract String getRecipeId();
@Override
public abstract String getGuiTexture();
@Override
public abstract String getOverlayIdentifier();
public abstract Map<IRecipeInput, RecipeOutput> getRecipeList();
@Override
public void drawBackground(int i)
{
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GuiDraw.changeTexture(this.getGuiTexture());
GuiDraw.drawTexturedModalRect(0, 0, 5, 11, 140, 65);
}
@Override
public void drawExtras(int i)
{
float f = this.ticks >= 20 ? (this.ticks - 20) % 20 / 20.0F : 0.0F;
this.drawProgressBar(74, 23, 176, 14, 25, 16, f, 0);
f = this.ticks <= 20 ? this.ticks / 20.0F : 1.0F;
this.drawProgressBar(51, 25, 176, 0, 14, 14, f, 3);
}
@Override
public void onUpdate()
{
super.onUpdate();
++this.ticks;
}
@Override
public void loadTransferRects()
{
this.transferRects.add(new RecipeTransferRect(new Rectangle(74, 23, 25, 16), this.getRecipeId(), new Object[0]));
}
@Override
public void loadCraftingRecipes(String outputId, Object ... results)
{
if (outputId.equals(this.getRecipeId()))
{
Iterator<Entry<IRecipeInput, RecipeOutput>> i$ = this.getRecipeList().entrySet().iterator();
while (i$.hasNext())
{
Entry<IRecipeInput, RecipeOutput> entry = i$.next();
this.arecipes.add(new IHLRecipeHandler.CachedIORecipe((IRecipeInput)entry.getKey(), (RecipeOutput)entry.getValue()));
}
}
else
{
super.loadCraftingRecipes(outputId, results);
}
}
@Override
public void loadCraftingRecipes(ItemStack result)
{
Iterator<Entry<IRecipeInput, RecipeOutput>> i$ = this.getRecipeList().entrySet().iterator();
while (i$.hasNext())
{
Entry<IRecipeInput, RecipeOutput> entry = i$.next();
Iterator<ItemStack> i$1 = ((RecipeOutput)entry.getValue()).items.iterator();
while (i$1.hasNext())
{
ItemStack output = i$1.next();
if (NEIServerUtils.areStacksSameTypeCrafting(output, result))
{
this.arecipes.add(new IHLRecipeHandler.CachedIORecipe((IRecipeInput)entry.getKey(), (RecipeOutput)entry.getValue()));
break;
}
}
}
}
@Override
public void loadUsageRecipes(ItemStack ingredient)
{
Iterator<Entry<IRecipeInput, RecipeOutput>> i$ = this.getRecipeList().entrySet().iterator();
while (i$.hasNext())
{
Entry<IRecipeInput, RecipeOutput> entry = i$.next();
if (((IRecipeInput)entry.getKey()).matches(ingredient))
{
this.arecipes.add(new IHLRecipeHandler.CachedIORecipe((IRecipeInput)entry.getKey(), (RecipeOutput)entry.getValue()));
}
}
}
protected int getInputPosX()
{
return 51;
}
protected int getInputPosY()
{
return 6;
}
protected int getOutputPosX()
{
return 111;
}
protected int getOutputPosY()
{
return 24;
}
protected boolean isOutputsVertical()
{
return true;
}
public class CachedIORecipe extends CachedRecipe
{
private final List<PositionedStack> ingredients = new ArrayList<PositionedStack>();
private final PositionedStack output;
private final List<PositionedStack> otherStacks = new ArrayList<PositionedStack>();
@Override
public List<PositionedStack> getIngredients()
{
return this.getCycledIngredients(IHLRecipeHandler.this.cycleticks / 20, this.ingredients);
}
@Override
public PositionedStack getResult()
{
return this.output;
}
@Override
public List<PositionedStack> getOtherStacks()
{
return this.otherStacks;
}
public CachedIORecipe(ItemStack input, ItemStack output1)
{
super();
if (input == null)
{
throw new NullPointerException("Input must not be null (recipe " + input + " -> " + output1 + ").");
}
else if (output1 == null)
{
throw new NullPointerException("Output must not be null (recipe " + input + " -> " + output1 + ").");
}
else
{
this.ingredients.add(new PositionedStack(input, IHLRecipeHandler.this.getInputPosX(), IHLRecipeHandler.this.getInputPosY()));
this.output = new PositionedStack(output1, IHLRecipeHandler.this.getOutputPosX(), IHLRecipeHandler.this.getOutputPosY());
}
}
public CachedIORecipe(IRecipeInput input, RecipeOutput output1)
{
super();
if (input == null)
{
throw new NullPointerException("Input must not be null (recipe " + input + " -> " + output1 + ").");
}
else if (output1 == null)
{
throw new NullPointerException("Output must not be null (recipe " + input + " -> " + output1 + ").");
}
else if (output1.items.isEmpty())
{
throw new IllegalArgumentException("Output must not be empty (recipe " + input + " -> " + output1 + ").");
}
else if (output1.items.contains((Object)null))
{
throw new IllegalArgumentException("Output must not contain null (recipe " + input + " -> " + output1 + ").");
}
else
{
ArrayList<ItemStack> items = new ArrayList<ItemStack>();
Iterator<ItemStack> i = input.getInputs().iterator();
while (i.hasNext())
{
ItemStack item = i.next();
items.add(StackUtil.copyWithSize(item, input.getAmount()));
}
this.ingredients.add(new PositionedStack(items, IHLRecipeHandler.this.getInputPosX(), IHLRecipeHandler.this.getInputPosY()));
this.output = new PositionedStack(output1.items.get(0), IHLRecipeHandler.this.getOutputPosX(), IHLRecipeHandler.this.getOutputPosY());
for (int var7 = 1; var7 < output1.items.size(); ++var7)
{
if (IHLRecipeHandler.this.isOutputsVertical())
{
this.otherStacks.add(new PositionedStack(output1.items.get(var7), IHLRecipeHandler.this.getOutputPosX(), IHLRecipeHandler.this.getOutputPosY() + var7 * 18));
}
else
{
this.otherStacks.add(new PositionedStack(output1.items.get(var7), IHLRecipeHandler.this.getOutputPosX() + var7 * 18, IHLRecipeHandler.this.getOutputPosY()));
}
}
}
}
}
}
|