-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCraftingManager.java
More file actions
295 lines (281 loc) · 12.6 KB
/
CraftingManager.java
File metadata and controls
295 lines (281 loc) · 12.6 KB
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
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
package net.minecraft.src;
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) braces deadcode
import java.io.PrintStream;
import java.util.*;
public class CraftingManager
{
public static final CraftingManager getInstance()
{
return instance;
}
private CraftingManager()
{
recipes = new ArrayList();
(new RecipesTools()).addRecipes(this);
(new RecipesWeapons()).addRecipes(this);
(new RecipesIngots()).addRecipes(this);
(new RecipesFood()).addRecipes(this);
(new RecipesCrafting()).addRecipes(this);
(new RecipesArmor()).addRecipes(this);
(new RecipesDyes()).addRecipes(this);
addRecipe(new ItemStack(Item.paper, 3), new Object[] {
"###", Character.valueOf('#'), Item.reed
});
addRecipe(new ItemStack(Item.book, 1), new Object[] {
"#", "#", "#", Character.valueOf('#'), Item.paper
});
addRecipe(new ItemStack(Block.fence, 2), new Object[] {
"###", "###", Character.valueOf('#'), Item.stick
});
addRecipe(new ItemStack(Block.jukebox, 1), new Object[] {
"###", "#X#", "###", Character.valueOf('#'), Block.planks, Character.valueOf('X'), Item.diamond
});
addRecipe(new ItemStack(Block.musicBlock, 1), new Object[] {
"###", "#X#", "###", Character.valueOf('#'), Block.planks, Character.valueOf('X'), Item.redstone
});
addRecipe(new ItemStack(Block.bookShelf, 1), new Object[] {
"###", "XXX", "###", Character.valueOf('#'), Block.planks, Character.valueOf('X'), Item.book
});
addRecipe(new ItemStack(Block.blockSnow, 1), new Object[] {
"##", "##", Character.valueOf('#'), Item.snowball
});
addRecipe(new ItemStack(Block.blockClay, 1), new Object[] {
"##", "##", Character.valueOf('#'), Item.clay
});
addRecipe(new ItemStack(Block.brick, 1), new Object[] {
"##", "##", Character.valueOf('#'), Item.brick
});
addRecipe(new ItemStack(Block.lightStone, 1), new Object[] {
"###", "###", "###", Character.valueOf('#'), Item.lightStoneDust
});
addRecipe(new ItemStack(Block.cloth, 1), new Object[] {
"###", "###", "###", Character.valueOf('#'), Item.silk
});
addRecipe(new ItemStack(Block.tnt, 1), new Object[] {
"X#X", "#X#", "X#X", Character.valueOf('X'), Item.gunpowder, Character.valueOf('#'), Block.sand
});
addRecipe(new ItemStack(Block.stairSingle, 3, 3), new Object[] {
"###", Character.valueOf('#'), Block.cobblestone
});
addRecipe(new ItemStack(Block.stairSingle, 3, 0), new Object[] {
"###", Character.valueOf('#'), Block.stone
});
addRecipe(new ItemStack(Block.stairSingle, 3, 1), new Object[] {
"###", Character.valueOf('#'), Block.sandStone
});
addRecipe(new ItemStack(Block.stairSingle, 3, 2), new Object[] {
"###", Character.valueOf('#'), Block.planks
});
addRecipe(new ItemStack(Block.ladder, 1), new Object[] {
"# #", "###", "# #", Character.valueOf('#'), Item.stick
});
addRecipe(new ItemStack(Item.doorWood, 1), new Object[] {
"##", "##", "##", Character.valueOf('#'), Block.planks
});
addRecipe(new ItemStack(Item.doorSteel, 1), new Object[] {
"##", "##", "##", Character.valueOf('#'), Item.ingotIron
});
addRecipe(new ItemStack(Item.sign, 1), new Object[] {
"###", "###", " X ", Character.valueOf('#'), Block.planks, Character.valueOf('X'), Item.stick
});
addRecipe(new ItemStack(Item.cake, 1), new Object[] {
"AAA", "BEB", "CCC", Character.valueOf('A'), Item.bucketMilk, Character.valueOf('B'), Item.sugar, Character.valueOf('C'), Item.wheat, Character.valueOf('E'),
Item.egg
});
addRecipe(new ItemStack(Item.sugar, 1), new Object[] {
"#", Character.valueOf('#'), Item.reed
});
addRecipe(new ItemStack(Block.planks, 4), new Object[] {
"#", Character.valueOf('#'), Block.wood
});
addRecipe(new ItemStack(Item.stick, 4), new Object[] {
"#", "#", Character.valueOf('#'), Block.planks
});
addRecipe(new ItemStack(Block.torchWood, 4), new Object[] {
"X", "#", Character.valueOf('X'), Item.coal, Character.valueOf('#'), Item.stick
});
addRecipe(new ItemStack(Block.torchWood, 4), new Object[] {
"X", "#", Character.valueOf('X'), new ItemStack(Item.coal, 1, 1), Character.valueOf('#'), Item.stick
});
addRecipe(new ItemStack(Item.bowlEmpty, 4), new Object[] {
"# #", " # ", Character.valueOf('#'), Block.planks
});
addRecipe(new ItemStack(Block.minecartTrack, 16), new Object[] {
"X X", "X#X", "X X", Character.valueOf('X'), Item.ingotIron, Character.valueOf('#'), Item.stick
});
addRecipe(new ItemStack(Item.minecartEmpty, 1), new Object[] {
"# #", "###", Character.valueOf('#'), Item.ingotIron
});
addRecipe(new ItemStack(Block.pumpkinLantern, 1), new Object[] {
"A", "B", Character.valueOf('A'), Block.pumpkin, Character.valueOf('B'), Block.torchWood
});
addRecipe(new ItemStack(Item.minecartCrate, 1), new Object[] {
"A", "B", Character.valueOf('A'), Block.crate, Character.valueOf('B'), Item.minecartEmpty
});
addRecipe(new ItemStack(Item.minecartPowered, 1), new Object[] {
"A", "B", Character.valueOf('A'), Block.stoneOvenIdle, Character.valueOf('B'), Item.minecartEmpty
});
addRecipe(new ItemStack(Item.boat, 1), new Object[] {
"# #", "###", Character.valueOf('#'), Block.planks
});
addRecipe(new ItemStack(Item.bucketEmpty, 1), new Object[] {
"# #", " # ", Character.valueOf('#'), Item.ingotIron
});
addRecipe(new ItemStack(Item.flintAndSteel, 1), new Object[] {
"A ", " B", Character.valueOf('A'), Item.ingotIron, Character.valueOf('B'), Item.flint
});
addRecipe(new ItemStack(Item.bread, 1), new Object[] {
"###", Character.valueOf('#'), Item.wheat
});
addRecipe(new ItemStack(Block.stairCompactPlanks, 4), new Object[] {
"# ", "## ", "###", Character.valueOf('#'), Block.planks
});
addRecipe(new ItemStack(Item.fishingRod, 1), new Object[] {
" #", " #X", "# X", Character.valueOf('#'), Item.stick, Character.valueOf('X'), Item.silk
});
addRecipe(new ItemStack(Block.stairCompactCobblestone, 4), new Object[] {
"# ", "## ", "###", Character.valueOf('#'), Block.cobblestone
});
addRecipe(new ItemStack(Item.painting, 1), new Object[] {
"###", "#X#", "###", Character.valueOf('#'), Item.stick, Character.valueOf('X'), Block.cloth
});
addRecipe(new ItemStack(Item.appleGold, 1), new Object[] {
"###", "#X#", "###", Character.valueOf('#'), Block.blockGold, Character.valueOf('X'), Item.appleRed
});
addRecipe(new ItemStack(Block.lever, 1), new Object[] {
"X", "#", Character.valueOf('#'), Block.cobblestone, Character.valueOf('X'), Item.stick
});
addRecipe(new ItemStack(Block.torchRedstoneActive, 1), new Object[] {
"X", "#", Character.valueOf('#'), Item.stick, Character.valueOf('X'), Item.redstone
});
addRecipe(new ItemStack(Item.field_22018_aZ, 1), new Object[] {
"#X#", "III", Character.valueOf('#'), Block.torchRedstoneActive, Character.valueOf('X'), Item.redstone, Character.valueOf('I'), Block.stone
});
addRecipe(new ItemStack(Item.pocketSundial, 1), new Object[] {
" # ", "#X#", " # ", Character.valueOf('#'), Item.ingotGold, Character.valueOf('X'), Item.redstone
});
addRecipe(new ItemStack(Item.compass, 1), new Object[] {
" # ", "#X#", " # ", Character.valueOf('#'), Item.ingotIron, Character.valueOf('X'), Item.redstone
});
addRecipe(new ItemStack(Block.button, 1), new Object[] {
"#", "#", Character.valueOf('#'), Block.stone
});
addRecipe(new ItemStack(Block.pressurePlateStone, 1), new Object[] {
"##", Character.valueOf('#'), Block.stone
});
addRecipe(new ItemStack(Block.pressurePlatePlanks, 1), new Object[] {
"##", Character.valueOf('#'), Block.planks
});
addRecipe(new ItemStack(Block.dispenser, 1), new Object[] {
"###", "#X#", "#R#", Character.valueOf('#'), Block.cobblestone, Character.valueOf('X'), Item.bow, Character.valueOf('R'), Item.redstone
});
addRecipe(new ItemStack(Item.field_22019_aY, 1), new Object[] {
"###", "XXX", Character.valueOf('#'), Block.cloth, Character.valueOf('X'), Block.planks
});
Collections.sort(recipes, new RecipeSorter(this));
System.out.println((new StringBuilder()).append(recipes.size()).append(" recipes").toString());
}
void addRecipe(ItemStack itemstack, Object aobj[])
{
String s = "";
int i = 0;
int j = 0;
int k = 0;
if(aobj[i] instanceof String[])
{
String as[] = (String[])aobj[i++];
for(int l = 0; l < as.length; l++)
{
String s2 = as[l];
k++;
j = s2.length();
s = (new StringBuilder()).append(s).append(s2).toString();
}
} else
{
while(aobj[i] instanceof String)
{
String s1 = (String)aobj[i++];
k++;
j = s1.length();
s = (new StringBuilder()).append(s).append(s1).toString();
}
}
HashMap hashmap = new HashMap();
for(; i < aobj.length; i += 2)
{
Character character = (Character)aobj[i];
ItemStack itemstack1 = null;
if(aobj[i + 1] instanceof Item)
{
itemstack1 = new ItemStack((Item)aobj[i + 1]);
} else
if(aobj[i + 1] instanceof Block)
{
itemstack1 = new ItemStack((Block)aobj[i + 1], 1, -1);
} else
if(aobj[i + 1] instanceof ItemStack)
{
itemstack1 = (ItemStack)aobj[i + 1];
}
hashmap.put(character, itemstack1);
}
ItemStack aitemstack[] = new ItemStack[j * k];
for(int i1 = 0; i1 < j * k; i1++)
{
char c = s.charAt(i1);
if(hashmap.containsKey(Character.valueOf(c)))
{
aitemstack[i1] = ((ItemStack)hashmap.get(Character.valueOf(c))).copy();
} else
{
aitemstack[i1] = null;
}
}
recipes.add(new ShapedRecipes(j, k, aitemstack, itemstack));
}
void addShapelessRecipe(ItemStack itemstack, Object aobj[])
{
ArrayList arraylist = new ArrayList();
Object aobj1[] = aobj;
int i = aobj1.length;
for(int j = 0; j < i; j++)
{
Object obj = aobj1[j];
if(obj instanceof ItemStack)
{
arraylist.add(((ItemStack)obj).copy());
continue;
}
if(obj instanceof Item)
{
arraylist.add(new ItemStack((Item)obj));
continue;
}
if(obj instanceof Block)
{
arraylist.add(new ItemStack((Block)obj));
} else
{
throw new RuntimeException("Invalid shapeless recipy!");
}
}
recipes.add(new ShapelessRecipes(itemstack, arraylist));
}
public ItemStack findMatchingRecipe(InventoryCrafting inventorycrafting)
{
for(int i = 0; i < recipes.size(); i++)
{
IRecipe irecipe = (IRecipe)recipes.get(i);
if(irecipe.func_21135_a(inventorycrafting))
{
return irecipe.func_21136_b(inventorycrafting);
}
}
return null;
}
private static final CraftingManager instance = new CraftingManager();
private List recipes;
}