the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#include "stdafx.h"
2#include "Container.h"
3#include "AbstractContainerMenu.h"
4#include "CraftingContainer.h"
5#include "CoalItem.h"
6#include "Item.h"
7#include "ItemInstance.h"
8#include "net.minecraft.world.level.tile.h"
9#include "net.minecraft.world.item.crafting.h"
10
11Recipes *Recipes::instance = NULL;
12ArmorRecipes *Recipes::pArmorRecipes=NULL;
13ClothDyeRecipes *Recipes::pClothDyeRecipes=NULL;
14FoodRecipies *Recipes::pFoodRecipies=NULL;
15OreRecipies *Recipes::pOreRecipies=NULL;
16StructureRecipies *Recipes::pStructureRecipies=NULL;
17ToolRecipies *Recipes::pToolRecipies=NULL;
18WeaponRecipies *Recipes::pWeaponRecipies=NULL;
19FireworksRecipe *Recipes::pFireworksRecipes=NULL;
20
21void Recipes::staticCtor()
22{
23 Recipes::instance = new Recipes();
24
25}
26
27void Recipes::_init()
28{
29 // 4J Jev: instance = new Recipes();
30 recipies = new RecipyList();
31}
32
33Recipes::Recipes()
34{
35 int iCount=0;
36 _init();
37
38 pArmorRecipes = new ArmorRecipes;
39 pClothDyeRecipes = new ClothDyeRecipes;
40 pFoodRecipies = new FoodRecipies;
41 pOreRecipies = new OreRecipies;
42 pStructureRecipies = new StructureRecipies;
43 pToolRecipies = new ToolRecipies;
44 pWeaponRecipies = new WeaponRecipies;
45
46 // 4J Stu - These just don't work with our crafting menu
47 //recipies->push_back(new ArmorDyeRecipe());
48 //recipies->add(new MapCloningRecipe());
49 //recipies->add(new MapExtendingRecipe());
50 //recipies->add(new FireworksRecipe());
51 pFireworksRecipes = new FireworksRecipe();
52
53
54 addShapedRecipy(new ItemInstance(Tile::wood, 4, 0), //
55 L"sczg",
56 L"#", //
57
58 L'#', new ItemInstance(Tile::treeTrunk, 1, 0),
59 L'S');
60
61 // TU9 - adding coloured wood
62 addShapedRecipy(new ItemInstance(Tile::wood, 4, TreeTile::BIRCH_TRUNK), //
63 L"sczg",
64 L"#", //
65
66 L'#', new ItemInstance(Tile::treeTrunk, 1, TreeTile::BIRCH_TRUNK),
67 L'S');
68
69 addShapedRecipy(new ItemInstance(Tile::wood, 4, TreeTile::DARK_TRUNK), //
70 L"sczg",
71 L"#", //
72
73 L'#', new ItemInstance(Tile::treeTrunk, 1, TreeTile::DARK_TRUNK),
74 L'S');
75
76 addShapedRecipy(new ItemInstance(Tile::wood, 4, TreeTile::JUNGLE_TRUNK), //
77 L"sczg",
78 L"#", //
79
80 L'#', new ItemInstance(Tile::treeTrunk, 1, TreeTile::JUNGLE_TRUNK),
81 L'S');
82
83 addShapedRecipy(new ItemInstance(Item::stick, 4), //
84 L"ssctg",
85 L"#", //
86 L"#", //
87
88 L'#', Tile::wood,
89 L'S');
90
91 pToolRecipies->addRecipes(this);
92 pFoodRecipies->addRecipes(this);
93 pStructureRecipies->addRecipes(this);
94
95
96 // 4J-PB - changing the order to the way we want to have things in the crafting menu
97 // bed
98 addShapedRecipy(new ItemInstance(Item::bed, 1), //
99 L"ssctctg",
100 L"###", //
101 L"XXX", //
102 L'#', Tile::wool, L'X', Tile::wood,
103 L'S');
104
105 addShapedRecipy(new ItemInstance(Tile::enchantTable, 1), //
106 L"sssctcicig",
107 L" B ", //
108 L"D#D", //
109 L"###", //
110
111 L'#', Tile::obsidian, L'B', Item::book, L'D', Item::diamond,
112 L'S');
113
114 addShapedRecipy(new ItemInstance(Tile::anvil, 1), //
115 L"sssctcig",
116 L"III", //
117 L" i ", //
118 L"iii", //
119
120 L'I', Tile::ironBlock, L'i', Item::ironIngot,
121 L'S');
122
123 // 4J Stu - Reordered for crafting menu
124 addShapedRecipy(new ItemInstance(Tile::ladder, 3), //
125 L"ssscig",
126 L"# #", //
127 L"###", //
128 L"# #", //
129
130 L'#', Item::stick,
131 L'S');
132
133 addShapedRecipy(new ItemInstance(Tile::fenceGate, 1), //
134 L"sscictg",
135 L"#W#", //
136 L"#W#", //
137
138 L'#', Item::stick, L'W', Tile::wood,
139 L'S');
140
141 addShapedRecipy(new ItemInstance(Tile::fence, 2), //
142 L"sscig",
143 L"###", //
144 L"###", //
145
146 L'#', Item::stick,
147 L'S');
148
149 addShapedRecipy(new ItemInstance(Tile::netherFence, 6), //
150 L"ssctg",
151 L"###", //
152 L"###", //
153
154 L'#', Tile::netherBrick,
155 L'S');
156
157 addShapedRecipy(new ItemInstance(Tile::ironFence, 16), //
158 L"sscig",
159 L"###", //
160 L"###", //
161
162 L'#', Item::ironIngot,
163 L'S');
164
165 addShapedRecipy(new ItemInstance(Tile::cobbleWall, 6, WallTile::TYPE_NORMAL), //
166 L"ssctg",
167 L"###", //
168 L"###", //
169
170 L'#', Tile::cobblestone,
171 L'S');
172
173 addShapedRecipy(new ItemInstance(Tile::cobbleWall, 6, WallTile::TYPE_MOSSY), //
174 L"ssctg",
175 L"###", //
176 L"###", //
177
178 L'#', Tile::mossyCobblestone,
179 L'S');
180
181 addShapedRecipy(new ItemInstance(Item::door_wood, 1), //
182 L"sssctg",
183 L"##", //
184 L"##", //
185 L"##", //
186
187 L'#', Tile::wood,
188 L'S');
189
190 addShapedRecipy(new ItemInstance(Item::door_iron, 1), //
191 L"ssscig",
192 L"##", //
193 L"##", //
194 L"##", //
195
196 L'#', Item::ironIngot,
197 L'S');
198
199 addShapedRecipy(new ItemInstance(Tile::stairs_wood, 4), //
200 L"sssczg",
201 L"# ", //
202 L"## ", //
203 L"###", //
204
205 L'#', new ItemInstance(Tile::wood, 1, 0),
206 L'S');
207
208 addShapedRecipy(new ItemInstance(Tile::trapdoor, 2), //
209 L"ssctg",
210 L"###", //
211 L"###", //
212
213 L'#', Tile::wood,
214 L'S');
215 addShapedRecipy(new ItemInstance(Tile::stairs_stone, 4), //
216 L"sssctg",
217 L"# ", //
218 L"## ", //
219 L"###", //
220
221 L'#', Tile::cobblestone,
222 L'S');
223
224 addShapedRecipy(new ItemInstance(Tile::stairs_bricks, 4), //
225 L"sssctg",
226 L"# ", //
227 L"## ", //
228 L"###", //
229
230 L'#', Tile::redBrick,
231 L'S');
232
233 addShapedRecipy(new ItemInstance(Tile::stairs_stoneBrickSmooth, 4), //
234 L"sssctg",
235 L"# ", //
236 L"## ", //
237 L"###", //
238
239 L'#', Tile::cobblestone,
240 L'S');
241
242 addShapedRecipy(new ItemInstance(Tile::stairs_netherBricks, 4), //
243 L"sssctg",
244 L"# ", //
245 L"## ", //
246 L"###", //
247
248 L'#', Tile::netherBrick,
249 L'S');
250
251 addShapedRecipy(new ItemInstance(Tile::stairs_sandstone, 4), //
252 L"sssctg",
253 L"# ", //
254 L"## ", //
255 L"###", //
256
257 L'#', Tile::sandStone,
258 L'S');
259
260 addShapedRecipy(new ItemInstance(Tile::woodStairsBirch, 4), //
261 L"sssczg",
262 L"# ", //
263 L"## ", //
264 L"###", //
265
266 L'#', new ItemInstance(Tile::wood, 1, TreeTile::BIRCH_TRUNK),
267 L'S');
268
269 addShapedRecipy(new ItemInstance(Tile::woodStairsDark, 4), //
270 L"sssczg",
271 L"# ", //
272 L"## ", //
273 L"###", //
274
275 L'#', new ItemInstance(Tile::wood, 1, TreeTile::DARK_TRUNK),
276 L'S');
277
278 addShapedRecipy(new ItemInstance(Tile::woodStairsJungle, 4), //
279 L"sssczg",
280 L"# ", //
281 L"## ", //
282 L"###", //
283
284 L'#', new ItemInstance(Tile::wood, 1, TreeTile::JUNGLE_TRUNK),
285 L'S');
286
287 addShapedRecipy(new ItemInstance(Tile::stairs_quartz, 4), //
288 L"sssctg",
289 L"# ", //
290 L"## ", //
291 L"###", //
292
293 L'#', Tile::quartzBlock,
294 L'S');
295
296 pArmorRecipes->addRecipes(this);
297 //iCount=getRecipies()->size();
298
299 pClothDyeRecipes->addRecipes(this);
300
301
302 addShapedRecipy(new ItemInstance(Tile::snow, 1), //
303 L"sscig",
304 L"##", //
305 L"##", //
306
307 L'#', Item::snowBall,
308 L'S');
309
310 addShapedRecipy(new ItemInstance(Tile::topSnow, 6), //
311 L"sctg",
312 L"###", //
313
314 L'#', Tile::snow,
315 L'S');
316
317 addShapedRecipy(new ItemInstance(Tile::clay, 1), //
318 L"sscig",
319 L"##", //
320 L"##", //
321
322 L'#', Item::clay,
323 L'S');
324
325 addShapedRecipy(new ItemInstance(Tile::redBrick, 1), //
326 L"sscig",
327 L"##", //
328 L"##", //
329
330 L'#', Item::brick,
331 L'S');
332
333 addShapedRecipy(new ItemInstance(Tile::wool, 1), //
334 L"sscig",
335 L"##", //
336 L"##", //
337
338 L'#', Item::string,
339 L'D');
340
341 addShapedRecipy(new ItemInstance(Tile::tnt, 1), //
342 L"ssscictg",
343 L"X#X", //
344 L"#X#", //
345 L"X#X", //
346
347 L'X', Item::gunpowder,//
348 L'#', Tile::sand,
349 L'T');
350
351 addShapedRecipy(new ItemInstance(Tile::stoneSlabHalf, 6, StoneSlabTile::SAND_SLAB), //
352 L"sctg",
353 L"###", //
354
355 L'#', Tile::sandStone,
356 L'S');
357
358 addShapedRecipy(new ItemInstance(Tile::stoneSlabHalf, 6, StoneSlabTile::STONE_SLAB), //
359 L"sctg",
360 L"###", //
361
362 L'#', Tile::stone,
363 L'S');
364 addShapedRecipy(new ItemInstance(Tile::stoneSlabHalf, 6, StoneSlabTile::COBBLESTONE_SLAB), //
365 L"sctg",
366 L"###", //
367
368 L'#', Tile::cobblestone,
369 L'S');
370
371 addShapedRecipy(new ItemInstance(Tile::stoneSlabHalf, 6, StoneSlabTile::BRICK_SLAB), //
372 L"sctg",
373 L"###", //
374
375 L'#', Tile::redBrick,
376 L'S');
377
378 addShapedRecipy(new ItemInstance(Tile::stoneSlabHalf, 6, StoneSlabTile::SMOOTHBRICK_SLAB), //
379 L"sctg",
380 L"###", //
381
382 L'#', Tile::stoneBrick,
383 L'S');
384
385 addShapedRecipy(new ItemInstance(Tile::stoneSlabHalf, 6, StoneSlabTile::NETHERBRICK_SLAB), //
386 L"sctg",
387 L"###", //
388
389 L'#', Tile::netherBrick,
390 L'S');
391
392 addShapedRecipy(new ItemInstance(Tile::stoneSlabHalf, 6, StoneSlabTile::QUARTZ_SLAB), //
393 L"sctg",
394 L"###", //
395
396 L'#', Tile::quartzBlock,
397 L'S');
398
399 addShapedRecipy(new ItemInstance(Tile::woodSlabHalf, 6, 0), //
400 L"sczg",
401 L"###", //
402
403 L'#', new ItemInstance(Tile::wood, 1, 0),
404 L'S');
405 // TU9 - adding wood slabs
406
407 addShapedRecipy(new ItemInstance(Tile::woodSlabHalf, 6, TreeTile::BIRCH_TRUNK), //
408 L"sczg",
409 L"###", //
410
411 L'#', new ItemInstance(Tile::wood, 1, TreeTile::BIRCH_TRUNK),
412 L'S');
413
414
415 addShapedRecipy(new ItemInstance(Tile::woodSlabHalf, 6, TreeTile::DARK_TRUNK), //
416 L"sczg",
417 L"###", //
418
419 L'#', new ItemInstance(Tile::wood, 1, TreeTile::DARK_TRUNK),
420 L'S');
421
422 addShapedRecipy(new ItemInstance(Tile::woodSlabHalf, 6, TreeTile::JUNGLE_TRUNK), //
423 L"sczg",
424 L"###", //
425
426 L'#', new ItemInstance(Tile::wood, 1, TreeTile::JUNGLE_TRUNK),
427 L'S');
428
429
430
431
432
433 //iCount=getRecipies()->size();
434
435 addShapedRecipy(new ItemInstance(Item::cake, 1), //
436 L"ssscicicicig",
437 L"AAA", //
438 L"BEB", //
439 L"CCC", //
440
441 L'A', Item::bucket_milk,//
442 L'B', Item::sugar,//
443 L'C', Item::wheat, L'E', Item::egg,
444 L'F');
445
446 addShapedRecipy(new ItemInstance(Item::sugar, 1), //
447 L"scig",
448 L"#", //
449
450 L'#', Item::reeds,
451 L'F');
452
453 addShapedRecipy(new ItemInstance(Tile::rail, 16), //
454 L"ssscicig",
455 L"X X", //
456 L"X#X", //
457 L"X X", //
458
459 L'X', Item::ironIngot,//
460 L'#', Item::stick,
461 L'V');
462
463 addShapedRecipy(new ItemInstance(Tile::goldenRail, 6), //
464 L"ssscicicig",
465 L"X X", //
466 L"X#X", //
467 L"XRX", //
468
469 L'X', Item::goldIngot,//
470 L'R', Item::redStone,//
471 L'#', Item::stick,
472 L'V');
473
474 addShapedRecipy(new ItemInstance(Tile::activatorRail, 6), //
475 L"ssscictcig",
476 L"XSX", //
477 L"X#X", //
478 L"XSX", //
479
480 L'X', Item::ironIngot,//
481 L'#', Tile::redstoneTorch_on,//
482 L'S', Item::stick,
483 L'V');
484
485 addShapedRecipy(new ItemInstance(Tile::detectorRail, 6), //
486 L"ssscicictg",
487 L"X X", //
488 L"X#X", //
489 L"XRX", //
490
491 L'X', Item::ironIngot,//
492 L'R', Item::redStone,//
493 L'#', Tile::pressurePlate_stone,
494 L'V');
495
496 addShapedRecipy(new ItemInstance(Item::minecart, 1), //
497 L"sscig",
498 L"# #", //
499 L"###", //
500
501 L'#', Item::ironIngot,
502 L'V');
503
504 addShapedRecipy(new ItemInstance(Item::minecart_chest, 1), //
505 L"ssctcig",
506 L"A", //
507 L"B", //
508
509 L'A', Tile::chest, L'B', Item::minecart,
510 L'V');
511
512 addShapedRecipy(new ItemInstance(Item::minecart_furnace, 1), //
513 L"ssctcig",
514 L"A", //
515 L"B", //
516
517 L'A', Tile::furnace, L'B', Item::minecart,
518 L'V');
519
520 addShapedRecipy(new ItemInstance(Item::minecart_tnt, 1), //
521 L"ssctcig",
522 L"A", //
523 L"B", //
524
525 L'A', Tile::tnt, L'B', Item::minecart,
526 L'V');
527
528 addShapedRecipy(new ItemInstance(Item::minecart_hopper, 1), //
529 L"ssctcig",
530 L"A", //
531 L"B", //
532
533 L'A', Tile::hopper, L'B', Item::minecart,
534 L'V');
535
536 addShapedRecipy(new ItemInstance(Item::boat, 1), //
537 L"ssctg",
538 L"# #", //
539 L"###", //
540
541 L'#', Tile::wood,
542 L'V');
543
544 addShapedRecipy(new ItemInstance((Item *)Item::fishingRod, 1), //
545 L"ssscicig",
546 L" #", //
547 L" #X", //
548 L"# X", //
549
550 L'#', Item::stick, L'X', Item::string,
551 L'T');
552
553 addShapedRecipy(new ItemInstance(Item::carrotOnAStick, 1), //
554 L"sscicig",
555 L"# ", //
556 L" X", //
557
558 L'#', Item::fishingRod, L'X', Item::carrots,
559 L'T')->keepTag();
560
561 addShapedRecipy(new ItemInstance(Item::flintAndSteel, 1), //
562 L"sscicig",
563 L"A ", //
564 L" B", //
565
566 L'A', Item::ironIngot, L'B', Item::flint,
567 L'T');
568
569 addShapedRecipy(new ItemInstance(Item::bread, 1), //
570 L"scig",
571 L"###", //
572
573 L'#', Item::wheat,
574 L'F');
575
576 // Moved bow and arrow in from weapons to avoid stacking on the group name display
577 addShapedRecipy(new ItemInstance((Item *)Item::bow, 1), //
578 L"ssscicig",
579 L" #X", //
580 L"# X", //
581 L" #X", //
582
583 L'X', Item::string,//
584 L'#', Item::stick,
585 L'T');
586
587 addShapedRecipy(new ItemInstance(Item::arrow, 4), //
588 L"ssscicicig",
589 L"X", //
590 L"#", //
591 L"Y", //
592
593 L'Y', Item::feather,//
594 L'X', Item::flint,//
595 L'#', Item::stick,
596 L'T');
597
598 pWeaponRecipies->addRecipes(this);
599
600 addShapedRecipy(new ItemInstance(Item::bucket_empty, 1), //
601 L"sscig",
602 L"# #", //
603 L" # ", //
604
605 L'#', Item::ironIngot,
606 L'T');
607
608 addShapedRecipy(new ItemInstance(Item::bowl, 4), //
609 L"ssctg",
610 L"# #", //
611 L" # ", //
612
613 L'#', Tile::wood,
614 L'T');
615
616 addShapedRecipy(new ItemInstance(Item::glassBottle, 3), //
617 L"ssctg",
618 L"# #", //
619 L" # ", //
620
621 L'#', Tile::glass,
622 L'T');
623
624 addShapedRecipy(new ItemInstance(Item::flowerPot, 1), //
625 L"sscig",
626 L"# #", //
627 L" # ", //
628
629 L'#', Item::brick,
630 L'D');
631
632 // torch made of charcoal - moved to be the default due to the tutorial using it
633 addShapedRecipy(new ItemInstance(Tile::torch, 4), //
634 L"ssczcig",
635 L"X", //
636 L"#", //
637
638 L'X', new ItemInstance(Item::coal, 1, CoalItem::CHAR_COAL),//
639 L'#', Item::stick,
640 L'T');
641
642 addShapedRecipy(new ItemInstance(Tile::torch, 4), //
643 L"ssczcig",
644 L"X", //
645 L"#", //
646 L'X', new ItemInstance(Item::coal, 1, CoalItem::STONE_COAL),//
647 L'#', Item::stick,
648 L'T');
649
650 addShapedRecipy(new ItemInstance(Tile::glowstone, 1), //
651 L"sscig",
652 L"##", //
653 L"##", //
654
655 L'#', Item::yellowDust,
656 L'T');
657
658 addShapedRecipy(new ItemInstance(Tile::quartzBlock, 1), //
659 L"sscig",
660 L"##", //
661 L"##", //
662
663 L'#', Item::netherQuartz,
664 L'S');
665
666 addShapedRecipy(new ItemInstance(Tile::lever, 1), //
667 L"ssctcig",
668 L"X", //
669 L"#", //
670
671 L'#', Tile::cobblestone, L'X', Item::stick,
672 L'M');
673
674 addShapedRecipy(new ItemInstance(Tile::tripWireSource, 2), //
675 L"sssctcicig",
676 L"I", //
677 L"S", //
678 L"#", //
679
680 L'#', Tile::wood, L'S', Item::stick, L'I', Item::ironIngot,
681 L'M');
682
683 addShapedRecipy(new ItemInstance(Tile::redstoneTorch_on, 1), //
684 L"sscicig",
685 L"X", //
686 L"#", //
687
688 L'#', Item::stick, L'X', Item::redStone,
689 L'M');
690
691 addShapedRecipy(new ItemInstance(Item::repeater, 1), //
692 L"ssctcictg",
693 L"#X#", //
694 L"III", //
695
696 L'#', Tile::redstoneTorch_on, L'X', Item::redStone, L'I', Tile::stone,
697 L'M');
698
699 addShapedRecipy(new ItemInstance(Item::comparator, 1), //
700 L"sssctcictg",
701 L" # ", //
702 L"#X#", //
703 L"III", //
704
705 L'#', Tile::redstoneTorch_on, L'X', Item::netherQuartz, L'I', Tile::stone,
706 L'M');
707
708 addShapedRecipy(new ItemInstance(Tile::daylightDetector),
709 L"sssctcictg",
710 L"GGG",
711 L"QQQ",
712 L"WWW",
713
714 L'G', Tile::glass, L'Q', Item::netherQuartz, L'W', Tile::woodSlabHalf,
715 L'M');
716
717 addShapedRecipy(new ItemInstance(Tile::hopper),
718 L"ssscictg",
719 L"I I", //
720 L"ICI", //
721 L" I ", //
722
723 L'I', Item::ironIngot, L'C', Tile::chest,
724 L'M');
725
726 addShapedRecipy(new ItemInstance(Item::clock, 1), //
727 L"ssscicig",
728 L" # ", //
729 L"#X#", //
730 L" # ", //
731 L'#', Item::goldIngot, L'X', Item::redStone,
732 L'T');
733
734 addShapelessRecipy(new ItemInstance(Item::eyeOfEnder, 1), //
735 L"iig",
736 Item::enderPearl, Item::blazePowder,
737 L'T');
738
739 addShapelessRecipy(new ItemInstance(Item::fireball, 3), //
740 L"iiig",
741 Item::gunpowder, Item::blazePowder,Item::coal,
742 L'T');
743
744 addShapelessRecipy(new ItemInstance(Item::fireball, 3), //
745 L"iizg",
746 Item::gunpowder, Item::blazePowder,new ItemInstance(Item::coal, 1, CoalItem::CHAR_COAL),
747 L'T');
748
749 addShapedRecipy(new ItemInstance(Item::lead, 2), //
750 L"ssscicig",
751 L"~~ ", //
752 L"~O ", //
753 L" ~", //
754
755 L'~', Item::string, L'O', Item::slimeBall,
756 L'T');
757
758
759 addShapedRecipy(new ItemInstance(Item::compass, 1), //
760 L"ssscicig",
761 L" # ", //
762 L"#X#", //
763 L" # ", //
764
765 L'#', Item::ironIngot, L'X', Item::redStone,
766 L'T');
767
768 addShapedRecipy(new ItemInstance(Item::map, 1), //
769 L"ssscicig",
770 L"###", //
771 L"#X#", //
772 L"###", //
773
774 L'#', Item::paper, L'X', Item::compass,
775 L'T');
776
777 addShapedRecipy(new ItemInstance(Tile::button, 1), //
778 L"sctg",
779 L"#", //
780
781 L'#', Tile::stone,
782 L'M');
783
784 addShapedRecipy(new ItemInstance(Tile::button_wood, 1), //
785 L"sctg",
786 L"#", //
787
788 L'#', Tile::wood,
789 L'M');
790
791 addShapedRecipy(new ItemInstance(Tile::pressurePlate_wood, 1), //
792 L"sctg",
793 L"##", //
794 L'#', Tile::wood,
795 L'M');
796
797 addShapedRecipy(new ItemInstance(Tile::pressurePlate_stone, 1), //
798 L"sctg",
799 L"##", //
800 L'#', Tile::stone,
801 L'M');
802
803 addShapedRecipy(new ItemInstance(Tile::weightedPlate_heavy, 1), //
804 L"scig",
805 L"##", //
806
807 L'#', Item::ironIngot,
808 L'M');
809
810 addShapedRecipy(new ItemInstance(Tile::weightedPlate_light, 1), //
811 L"scig",
812 L"##", //
813
814 L'#', Item::goldIngot,
815 L'M');
816
817 addShapedRecipy(new ItemInstance(Tile::dispenser, 1), //
818 L"sssctcicig",
819 L"###", //
820 L"#X#", //
821 L"#R#", //
822 L'#', Tile::cobblestone, L'X', Item::bow, L'R', Item::redStone,
823 L'M');
824
825 addShapedRecipy(new ItemInstance(Tile::dropper, 1), //
826 L"sssctcig",
827 L"###", //
828 L"# #", //
829 L"#R#", //
830
831 L'#', Tile::cobblestone, L'R', Item::redStone,
832 L'M');
833
834 addShapedRecipy(new ItemInstance(Item::cauldron, 1), //
835 L"ssscig",
836 L"# #", //
837 L"# #", //
838 L"###", //
839
840 L'#', Item::ironIngot,
841 L'T');
842
843 addShapedRecipy(new ItemInstance(Item::brewingStand, 1), //
844 L"ssctcig",
845 L" B ", //
846 L"###", //
847
848 L'#', Tile::cobblestone, L'B', Item::blazeRod,
849 L'S');
850
851
852 addShapedRecipy(new ItemInstance(Tile::litPumpkin, 1), //
853 L"ssctctg",
854 L"A", //
855 L"B", //
856
857 L'A', Tile::pumpkin, L'B', Tile::torch,
858 L'T');
859
860
861 addShapedRecipy(new ItemInstance(Tile::jukebox, 1), //
862 L"sssctcig",
863 L"###", //
864 L"#X#", //
865 L"###", //
866
867 L'#', Tile::wood, L'X', Item::diamond,
868 'D');
869
870 addShapedRecipy(new ItemInstance(Item::paper, 3), //
871 L"scig",
872 L"###", //
873
874 L'#', Item::reeds,
875 L'D');
876
877 addShapelessRecipy(new ItemInstance(Item::book, 1),
878 L"iiiig",
879 Item::paper,
880 Item::paper,
881 Item::paper,
882 Item::leather,
883 L'D');
884
885 //addShapelessRecipy(new ItemInstance(Item.writingBook, 1), //
886 // Item.book, new ItemInstance(Item.dye_powder, 1, DyePowderItem.BLACK), Item.feather);
887
888 addShapedRecipy(new ItemInstance(Tile::noteblock, 1), //
889 L"sssctcig",
890 L"###", //
891 L"#X#", //
892 L"###", //
893
894 L'#', Tile::wood, L'X', Item::redStone,
895 L'M');
896
897 addShapedRecipy(new ItemInstance(Tile::bookshelf, 1), //
898 L"sssctcig",
899 L"###", //
900 L"XXX", //
901 L"###", //
902
903 L'#', Tile::wood, L'X', Item::book,
904 L'D');
905
906 addShapedRecipy(new ItemInstance(Item::painting, 1), //
907 L"ssscictg",
908 L"###", //
909 L"#X#", //
910 L"###", //
911
912 L'#', Item::stick, L'X', Tile::wool,
913 L'D');
914
915
916 addShapedRecipy(new ItemInstance(Item::frame, 1), //
917 L"ssscicig",
918 L"###", //
919 L"#X#", //
920 L"###", //
921
922 L'#', Item::stick, L'X', Item::leather,
923 L'D');
924
925 pOreRecipies->addRecipes(this);
926
927 addShapedRecipy(new ItemInstance(Item::goldIngot), //
928 L"ssscig",
929 L"###", //
930 L"###", //
931 L"###", //
932
933 L'#', Item::goldNugget,
934 L'D');
935
936 addShapedRecipy(new ItemInstance(Item::goldNugget, 9), //
937 L"scig",
938 L"#", //
939 L'#', Item::goldIngot,
940 L'D');
941
942 // 4J-PB - moving into decorations to make the structures list smaller
943 addShapedRecipy(new ItemInstance(Item::sign, 3), //
944 L"sssctcig",
945 L"###", //
946 L"###", //
947 L" X ", //
948
949 L'#', Tile::wood, L'X', Item::stick,
950 L'D');
951
952 // 4J - TODO - put these new 1.7.3 items in required place within recipes
953 addShapedRecipy(new ItemInstance((Tile *)Tile::pistonBase, 1), //
954 L"sssctcicictg",
955 L"TTT", //
956 L"#X#", //
957 L"#R#", //
958
959 L'#', Tile::cobblestone, L'X', Item::ironIngot, L'R', Item::redStone, L'T', Tile::wood,
960 L'M');
961
962 addShapedRecipy(new ItemInstance((Tile *)Tile::pistonStickyBase, 1), //
963 L"sscictg",
964 L"S", //
965 L"P", //
966
967 L'S', Item::slimeBall, L'P', Tile::pistonBase,
968 L'M');
969
970
971 // 4J Stu - Added some dummy firework recipes to allow us to navigate forward to the fireworks scene
972 addShapedRecipy(new ItemInstance(Item::fireworks, 1), //
973 L"sscicig",
974 L" P ", //
975 L" G ", //
976
977 L'P', Item::paper, L'G', Item::gunpowder,
978 L'D');
979
980 addShapedRecipy(new ItemInstance(Item::fireworksCharge,1), //
981 L"sscicig",
982 L" D ", //
983 L" G ", //
984
985 L'D', Item::dye_powder, L'G', Item::gunpowder,
986 L'D');
987
988 addShapedRecipy(new ItemInstance(Item::fireworksCharge,1), //
989 L"sscicig",
990 L" D ", //
991 L" C ", //
992
993 L'D', Item::dye_powder, L'C', Item::fireworksCharge,
994 L'D');
995
996
997 // Sort so the largest recipes get checked first!
998 /* 4J-PB - TODO
999 Collections.sort(recipies, new Comparator<Recipy>()
1000 {
1001 public: int compare(Recipy r0, Recipy r1)
1002 {
1003
1004 // shapeless recipes are put in the back of the list
1005 if (r0 instanceof ShapelessRecipy && r1 instanceof ShapedRecipy)
1006 {
1007 return 1;
1008 }
1009 if (r1 instanceof ShapelessRecipy && r0 instanceof ShapedRecipy)
1010 {
1011 return -1;
1012 }
1013
1014 if (r1.size() < r0.size()) return -1;
1015 if (r1.size() > r0.size()) return 1;
1016 return 0;
1017 }
1018 });
1019 */
1020
1021 // 4J-PB removed System.out.println(recipies->size() + L" recipes");
1022
1023 // 4J-PB - build the array of ingredients required per recipe
1024 buildRecipeIngredientsArray();
1025}
1026
1027// 4J-PB - this function has been substantially changed due to the differences with a va_list of classes in C++ and Java
1028ShapedRecipy *Recipes::addShapedRecipy(ItemInstance *result, ...)
1029{
1030 wstring map = L"";
1031 int p = 0;
1032 int width = 0;
1033 int height = 0;
1034 int group = ShapedRecipy::eGroupType_Decoration;
1035 va_list vl;
1036 wchar_t *wchTypes;
1037 wchar_t *pwchString;
1038 wstring wString;
1039 wstring *wStringA;
1040 ItemInstance *pItemInstance;
1041 Tile *pTile;
1042 Item *pItem;
1043 wchar_t wchFrom;
1044 int iCount;
1045 ItemInstance **ids = NULL;
1046
1047 myMap *mappings = new unordered_map<wchar_t, ItemInstance *>();
1048
1049 va_start(vl,result);
1050 // 4J-PB - second argument is a list of the types
1051 // s - string
1052 // w - string array
1053 // a - char *
1054 // c - char
1055 // z - ItemInstance *
1056 // i - Item *
1057 // t - Tile *
1058 // g - group [wt] - which group does the item created by the recipe belong in. Set a default until all recipes have a group
1059
1060 wchTypes = va_arg(vl,wchar_t *);
1061
1062 for(int i = 0; wchTypes[i] != L'\0'; ++i )
1063 {
1064 if(wchTypes[i+1]==L'\0' && wchTypes[i]!=L'g')
1065 {
1066 app.DebugPrintf("Missing group type\n");
1067 }
1068
1069 switch(wchTypes[i])
1070 {
1071 case L'a':
1072 pwchString=va_arg(vl,wchar_t *);
1073 wString=pwchString;
1074 height++;
1075 width = (int)wString.length();
1076 map += wString;
1077 break;
1078 case L's':
1079 pwchString=va_arg(vl,wchar_t *);
1080 wString=pwchString;
1081 height++;
1082 width = (int)wString.length();
1083 map += wString;
1084 break;
1085 case L'w':
1086 wStringA=va_arg(vl,wstring *);
1087 iCount=0;
1088 do
1089 {
1090 wString=wStringA[iCount++];
1091 if(!wString.empty())
1092 {
1093 height++;
1094 width = (int)wString.length();
1095 map += wString;
1096 }
1097 }
1098 while(!wString.empty());
1099
1100 break;
1101 case L'c':
1102 wchFrom=va_arg(vl,wchar_t);
1103 break;
1104 case L'z':
1105 pItemInstance=va_arg(vl,ItemInstance *);
1106 mappings->insert(myMap::value_type(wchFrom,pItemInstance));
1107 break;
1108 case L'i':
1109 pItem=va_arg(vl,Item *);
1110 pItemInstance= new ItemInstance(pItem,1,ANY_AUX_VALUE);
1111 mappings->insert(myMap::value_type(wchFrom,pItemInstance));
1112 break;
1113 case L't':
1114 pTile=va_arg(vl,Tile *);
1115 pItemInstance= new ItemInstance(pTile,1,ANY_AUX_VALUE);
1116 mappings->insert(myMap::value_type(wchFrom,pItemInstance));
1117 break;
1118 case L'g':
1119 wchFrom=va_arg(vl,wchar_t);
1120 switch(wchFrom)
1121 {
1122// case L'W':
1123// group=ShapedRecipy::eGroupType_Weapon;
1124// break;
1125 case L'T':
1126 group=ShapedRecipy::eGroupType_Tool;
1127 break;
1128 case L'A':
1129 group=ShapedRecipy::eGroupType_Armour;
1130 break;
1131 case L'S':
1132 group=ShapedRecipy::eGroupType_Structure;
1133 break;
1134 case L'V':
1135 group=ShapedRecipy::eGroupType_Transport;
1136 break;
1137 case L'M':
1138 group=ShapedRecipy::eGroupType_Mechanism;
1139 break;
1140 case L'F':
1141 group=ShapedRecipy::eGroupType_Food;
1142 break;
1143 case L'D':
1144 default:
1145 group=ShapedRecipy::eGroupType_Decoration;
1146 break;
1147
1148 }
1149 break;
1150
1151 }
1152
1153
1154 ids = new ItemInstance *[width * height];
1155
1156 for (int j = 0; j < width * height; j++)
1157 {
1158 wchar_t ch = map[j];
1159 myMap::iterator it=mappings->find(ch);
1160 if (it != mappings->end())
1161 {
1162 ids[j] =it->second;
1163 }
1164 else
1165 {
1166 ids[j] = NULL;
1167 }
1168 }
1169 }
1170
1171 va_end(vl);
1172
1173 ShapedRecipy *recipe = new ShapedRecipy(width, height, ids, result, group);
1174 recipies->push_back(recipe);
1175 return recipe;
1176}
1177
1178void Recipes::addShapelessRecipy(ItemInstance *result,... )
1179{
1180 va_list vl;
1181 wchar_t *szTypes;
1182 wstring String;
1183 ItemInstance *pItemInstance;
1184 Tile *pTile;
1185 Item *pItem;
1186 Recipy::_eGroupType group = Recipy::eGroupType_Decoration;
1187 wchar_t wchFrom;
1188 vector <ItemInstance *> *ingredients = new vector<ItemInstance *>();
1189
1190 va_start(vl,result);
1191 // 4J-PB - second argument is a list of the types
1192 // z - ItemInstance *
1193 // i - Item *
1194 // t - Tile *
1195 szTypes = va_arg(vl,wchar_t *);
1196
1197 for(int i = 0; szTypes[i] != L'\0'; ++i )
1198 {
1199 switch(szTypes[i])
1200 {
1201 case L'z':
1202 pItemInstance=va_arg(vl,ItemInstance *);
1203 // 4J-PB - original code copies the item instance, copy the pointer isnt the same...
1204 // TODO
1205 ingredients->push_back(pItemInstance->copy_not_shared());
1206 break;
1207 case L'i':
1208 pItem=va_arg(vl,Item *);
1209 pItemInstance= new ItemInstance(pItem);
1210 ingredients->push_back(pItemInstance);
1211 break;
1212 case L't':
1213 pTile=va_arg(vl,Tile *);
1214 ingredients->push_back(new ItemInstance(pTile));
1215 break;
1216 case L'g':
1217 wchFrom=va_arg(vl,wchar_t);
1218 switch(wchFrom)
1219 {
1220
1221 case L'T':
1222 group=Recipy::eGroupType_Tool;
1223 break;
1224 case L'A':
1225 group=Recipy::eGroupType_Armour;
1226 break;
1227 case L'S':
1228 group=Recipy::eGroupType_Structure;
1229 break;
1230 case L'V':
1231 group=Recipy::eGroupType_Transport;
1232 break;
1233 case L'M':
1234 group=Recipy::eGroupType_Mechanism;
1235 break;
1236 case L'F':
1237 group=Recipy::eGroupType_Food;
1238 break;
1239 case L'D':
1240 default:
1241 group=Recipy::eGroupType_Decoration;
1242 break;
1243
1244 }
1245 break; }
1246 }
1247
1248 recipies->push_back(new ShapelessRecipy(result, ingredients, group));
1249}
1250
1251shared_ptr<ItemInstance> Recipes::getItemFor(shared_ptr<CraftingContainer> craftSlots, Level *level, Recipy *recipesClass /*= NULL*/)
1252{
1253 int count = 0;
1254 shared_ptr<ItemInstance> first = nullptr;
1255 shared_ptr<ItemInstance> second = nullptr;
1256 for (int i = 0; i < craftSlots->getContainerSize(); i++)
1257 {
1258 shared_ptr<ItemInstance> item = craftSlots->getItem(i);
1259 if (item != NULL)
1260 {
1261 if (count == 0) first = item;
1262 if (count == 1) second = item;
1263 count++;
1264 }
1265 }
1266
1267 if (count == 2 && first->id == second->id && first->count == 1 && second->count == 1 && Item::items[first->id]->canBeDepleted())
1268 {
1269 Item *item = Item::items[first->id];
1270 int remaining1 = item->getMaxDamage() - first->getDamageValue();
1271 int remaining2 = item->getMaxDamage() - second->getDamageValue();
1272 int remaining = (remaining1 + remaining2) + item->getMaxDamage() * 5 / 100;
1273 int resultDamage = item->getMaxDamage() - remaining;
1274 if (resultDamage < 0) resultDamage = 0;
1275 return shared_ptr<ItemInstance>( new ItemInstance(first->id, 1, resultDamage) );
1276 }
1277
1278 if(recipesClass != NULL)
1279 {
1280 if (recipesClass->matches(craftSlots, level)) return recipesClass->assemble(craftSlots);
1281 }
1282 else
1283 {
1284 AUTO_VAR(itEnd, recipies->end());
1285 for (AUTO_VAR(it, recipies->begin()); it != itEnd; it++)
1286 {
1287 Recipy *r = *it; //recipies->at(i);
1288 if (r->matches(craftSlots, level)) return r->assemble(craftSlots);
1289 }
1290 }
1291 return nullptr;
1292}
1293
1294vector <Recipy *> *Recipes::getRecipies()
1295{
1296 return recipies;
1297}
1298
1299// 4J-PB - added to deal with Xb0x 'crafting'
1300shared_ptr<ItemInstance> Recipes::getItemForRecipe(Recipy *r)
1301{
1302 return r->assemble(nullptr);
1303}
1304
1305// 4J-PB - build the required ingredients for recipes
1306void Recipes::buildRecipeIngredientsArray(void)
1307{
1308 //RecipyList *recipes = ((Recipes *)Recipes::getInstance())->getRecipies();
1309
1310 int iRecipeC=(int)recipies->size();
1311
1312 m_pRecipeIngredientsRequired= new Recipy::INGREDIENTS_REQUIRED [iRecipeC];
1313
1314 int iCount=0;
1315 AUTO_VAR(itEndRec, recipies->end());
1316 for (AUTO_VAR(it, recipies->begin()); it != itEndRec; it++)
1317 {
1318 Recipy *recipe = *it;
1319 //wprintf(L"RECIPE - [%d] is %w\n",iCount,recipe->getResultItem()->getItem()->getName());
1320 recipe->requires(&m_pRecipeIngredientsRequired[iCount++]);
1321 }
1322
1323 //printf("Total recipes in buildRecipeIngredientsArray - %d",iCount);
1324}
1325
1326Recipy::INGREDIENTS_REQUIRED *Recipes::getRecipeIngredientsArray(void)
1327{
1328 return m_pRecipeIngredientsRequired;
1329}