Something went wrong. Try again.
the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
Something went wrong. Try again.
28 kB · 1329 lines
C++
at master
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329#include "stdafx.h"#include "Container.h"#include "AbstractContainerMenu.h"#include "CraftingContainer.h"#include "CoalItem.h"#include "Item.h"#include "ItemInstance.h"#include "net.minecraft.world.level.tile.h"#include "net.minecraft.world.item.crafting.h"
Recipes *Recipes::instance = NULL;ArmorRecipes *Recipes::pArmorRecipes=NULL;ClothDyeRecipes *Recipes::pClothDyeRecipes=NULL;FoodRecipies *Recipes::pFoodRecipies=NULL;OreRecipies *Recipes::pOreRecipies=NULL;StructureRecipies *Recipes::pStructureRecipies=NULL;ToolRecipies *Recipes::pToolRecipies=NULL;WeaponRecipies *Recipes::pWeaponRecipies=NULL;FireworksRecipe *Recipes::pFireworksRecipes=NULL;
void Recipes::staticCtor(){ Recipes::instance = new Recipes();
}
void Recipes::_init(){ // 4J Jev: instance = new Recipes(); recipies = new RecipyList();}
Recipes::Recipes() { int iCount=0; _init();
pArmorRecipes = new ArmorRecipes; pClothDyeRecipes = new ClothDyeRecipes; pFoodRecipies = new FoodRecipies; pOreRecipies = new OreRecipies; pStructureRecipies = new StructureRecipies; pToolRecipies = new ToolRecipies; pWeaponRecipies = new WeaponRecipies;
// 4J Stu - These just don't work with our crafting menu //recipies->push_back(new ArmorDyeRecipe()); //recipies->add(new MapCloningRecipe()); //recipies->add(new MapExtendingRecipe()); //recipies->add(new FireworksRecipe()); pFireworksRecipes = new FireworksRecipe();
addShapedRecipy(new ItemInstance(Tile::wood, 4, 0), // L"sczg", L"#", //
L'#', new ItemInstance(Tile::treeTrunk, 1, 0), L'S');
// TU9 - adding coloured wood addShapedRecipy(new ItemInstance(Tile::wood, 4, TreeTile::BIRCH_TRUNK), // L"sczg", L"#", //
L'#', new ItemInstance(Tile::treeTrunk, 1, TreeTile::BIRCH_TRUNK), L'S'); addShapedRecipy(new ItemInstance(Tile::wood, 4, TreeTile::DARK_TRUNK), // L"sczg", L"#", //
L'#', new ItemInstance(Tile::treeTrunk, 1, TreeTile::DARK_TRUNK), L'S');
addShapedRecipy(new ItemInstance(Tile::wood, 4, TreeTile::JUNGLE_TRUNK), // L"sczg", L"#", //
L'#', new ItemInstance(Tile::treeTrunk, 1, TreeTile::JUNGLE_TRUNK), L'S');
addShapedRecipy(new ItemInstance(Item::stick, 4), // L"ssctg", L"#", // L"#", //
L'#', Tile::wood, L'S');
pToolRecipies->addRecipes(this); pFoodRecipies->addRecipes(this); pStructureRecipies->addRecipes(this);
// 4J-PB - changing the order to the way we want to have things in the crafting menu // bed addShapedRecipy(new ItemInstance(Item::bed, 1), // L"ssctctg", L"###", // L"XXX", // L'#', Tile::wool, L'X', Tile::wood, L'S');
addShapedRecipy(new ItemInstance(Tile::enchantTable, 1), // L"sssctcicig", L" B ", // L"D#D", // L"###", //
L'#', Tile::obsidian, L'B', Item::book, L'D', Item::diamond, L'S');
addShapedRecipy(new ItemInstance(Tile::anvil, 1), // L"sssctcig", L"III", // L" i ", // L"iii", //
L'I', Tile::ironBlock, L'i', Item::ironIngot, L'S');
// 4J Stu - Reordered for crafting menu addShapedRecipy(new ItemInstance(Tile::ladder, 3), // L"ssscig", L"# #", // L"###", // L"# #", //
L'#', Item::stick, L'S');
addShapedRecipy(new ItemInstance(Tile::fenceGate, 1), // L"sscictg", L"#W#", // L"#W#", //
L'#', Item::stick, L'W', Tile::wood, L'S'); addShapedRecipy(new ItemInstance(Tile::fence, 2), // L"sscig", L"###", // L"###", //
L'#', Item::stick, L'S'); addShapedRecipy(new ItemInstance(Tile::netherFence, 6), // L"ssctg", L"###", // L"###", //
L'#', Tile::netherBrick, L'S');
addShapedRecipy(new ItemInstance(Tile::ironFence, 16), // L"sscig", L"###", // L"###", //
L'#', Item::ironIngot, L'S');
addShapedRecipy(new ItemInstance(Tile::cobbleWall, 6, WallTile::TYPE_NORMAL), // L"ssctg", L"###", // L"###", //
L'#', Tile::cobblestone, L'S');
addShapedRecipy(new ItemInstance(Tile::cobbleWall, 6, WallTile::TYPE_MOSSY), // L"ssctg", L"###", // L"###", //
L'#', Tile::mossyCobblestone, L'S');
addShapedRecipy(new ItemInstance(Item::door_wood, 1), // L"sssctg", L"##", // L"##", // L"##", //
L'#', Tile::wood, L'S');
addShapedRecipy(new ItemInstance(Item::door_iron, 1), // L"ssscig", L"##", // L"##", // L"##", //
L'#', Item::ironIngot, L'S');
addShapedRecipy(new ItemInstance(Tile::stairs_wood, 4), // L"sssczg", L"# ", // L"## ", // L"###", //
L'#', new ItemInstance(Tile::wood, 1, 0), L'S');
addShapedRecipy(new ItemInstance(Tile::trapdoor, 2), // L"ssctg", L"###", // L"###", //
L'#', Tile::wood, L'S'); addShapedRecipy(new ItemInstance(Tile::stairs_stone, 4), // L"sssctg", L"# ", // L"## ", // L"###", //
L'#', Tile::cobblestone, L'S');
addShapedRecipy(new ItemInstance(Tile::stairs_bricks, 4), // L"sssctg", L"# ", // L"## ", // L"###", //
L'#', Tile::redBrick, L'S');
addShapedRecipy(new ItemInstance(Tile::stairs_stoneBrickSmooth, 4), // L"sssctg", L"# ", // L"## ", // L"###", //
L'#', Tile::cobblestone, L'S');
addShapedRecipy(new ItemInstance(Tile::stairs_netherBricks, 4), // L"sssctg", L"# ", // L"## ", // L"###", //
L'#', Tile::netherBrick, L'S');
addShapedRecipy(new ItemInstance(Tile::stairs_sandstone, 4), // L"sssctg", L"# ", // L"## ", // L"###", //
L'#', Tile::sandStone, L'S');
addShapedRecipy(new ItemInstance(Tile::woodStairsBirch, 4), // L"sssczg", L"# ", // L"## ", // L"###", //
L'#', new ItemInstance(Tile::wood, 1, TreeTile::BIRCH_TRUNK), L'S');
addShapedRecipy(new ItemInstance(Tile::woodStairsDark, 4), // L"sssczg", L"# ", // L"## ", // L"###", //
L'#', new ItemInstance(Tile::wood, 1, TreeTile::DARK_TRUNK), L'S');
addShapedRecipy(new ItemInstance(Tile::woodStairsJungle, 4), // L"sssczg", L"# ", // L"## ", // L"###", //
L'#', new ItemInstance(Tile::wood, 1, TreeTile::JUNGLE_TRUNK), L'S');
addShapedRecipy(new ItemInstance(Tile::stairs_quartz, 4), // L"sssctg", L"# ", // L"## ", // L"###", //
L'#', Tile::quartzBlock, L'S');
pArmorRecipes->addRecipes(this); //iCount=getRecipies()->size();
pClothDyeRecipes->addRecipes(this);
addShapedRecipy(new ItemInstance(Tile::snow, 1), // L"sscig", L"##", // L"##", //
L'#', Item::snowBall, L'S');
addShapedRecipy(new ItemInstance(Tile::topSnow, 6), // L"sctg", L"###", //
L'#', Tile::snow, L'S');
addShapedRecipy(new ItemInstance(Tile::clay, 1), // L"sscig", L"##", // L"##", //
L'#', Item::clay, L'S');
addShapedRecipy(new ItemInstance(Tile::redBrick, 1), // L"sscig", L"##", // L"##", //
L'#', Item::brick, L'S');
addShapedRecipy(new ItemInstance(Tile::wool, 1), // L"sscig", L"##", // L"##", //
L'#', Item::string, L'D');
addShapedRecipy(new ItemInstance(Tile::tnt, 1), // L"ssscictg", L"X#X", // L"#X#", // L"X#X", //
L'X', Item::gunpowder,// L'#', Tile::sand, L'T');
addShapedRecipy(new ItemInstance(Tile::stoneSlabHalf, 6, StoneSlabTile::SAND_SLAB), // L"sctg", L"###", //
L'#', Tile::sandStone, L'S');
addShapedRecipy(new ItemInstance(Tile::stoneSlabHalf, 6, StoneSlabTile::STONE_SLAB), // L"sctg", L"###", //
L'#', Tile::stone, L'S'); addShapedRecipy(new ItemInstance(Tile::stoneSlabHalf, 6, StoneSlabTile::COBBLESTONE_SLAB), // L"sctg", L"###", //
L'#', Tile::cobblestone, L'S'); addShapedRecipy(new ItemInstance(Tile::stoneSlabHalf, 6, StoneSlabTile::BRICK_SLAB), // L"sctg", L"###", //
L'#', Tile::redBrick, L'S');
addShapedRecipy(new ItemInstance(Tile::stoneSlabHalf, 6, StoneSlabTile::SMOOTHBRICK_SLAB), // L"sctg", L"###", //
L'#', Tile::stoneBrick, L'S');
addShapedRecipy(new ItemInstance(Tile::stoneSlabHalf, 6, StoneSlabTile::NETHERBRICK_SLAB), // L"sctg", L"###", //
L'#', Tile::netherBrick, L'S');
addShapedRecipy(new ItemInstance(Tile::stoneSlabHalf, 6, StoneSlabTile::QUARTZ_SLAB), // L"sctg", L"###", //
L'#', Tile::quartzBlock, L'S');
addShapedRecipy(new ItemInstance(Tile::woodSlabHalf, 6, 0), // L"sczg", L"###", //
L'#', new ItemInstance(Tile::wood, 1, 0), L'S'); // TU9 - adding wood slabs
addShapedRecipy(new ItemInstance(Tile::woodSlabHalf, 6, TreeTile::BIRCH_TRUNK), // L"sczg", L"###", //
L'#', new ItemInstance(Tile::wood, 1, TreeTile::BIRCH_TRUNK), L'S');
addShapedRecipy(new ItemInstance(Tile::woodSlabHalf, 6, TreeTile::DARK_TRUNK), // L"sczg", L"###", //
L'#', new ItemInstance(Tile::wood, 1, TreeTile::DARK_TRUNK), L'S');
addShapedRecipy(new ItemInstance(Tile::woodSlabHalf, 6, TreeTile::JUNGLE_TRUNK), // L"sczg", L"###", //
L'#', new ItemInstance(Tile::wood, 1, TreeTile::JUNGLE_TRUNK), L'S');
//iCount=getRecipies()->size();
addShapedRecipy(new ItemInstance(Item::cake, 1), // L"ssscicicicig", L"AAA", // L"BEB", // L"CCC", //
L'A', Item::bucket_milk,// L'B', Item::sugar,// L'C', Item::wheat, L'E', Item::egg, L'F');
addShapedRecipy(new ItemInstance(Item::sugar, 1), // L"scig", L"#", //
L'#', Item::reeds, L'F');
addShapedRecipy(new ItemInstance(Tile::rail, 16), // L"ssscicig", L"X X", // L"X#X", // L"X X", //
L'X', Item::ironIngot,// L'#', Item::stick, L'V');
addShapedRecipy(new ItemInstance(Tile::goldenRail, 6), // L"ssscicicig", L"X X", // L"X#X", // L"XRX", //
L'X', Item::goldIngot,// L'R', Item::redStone,// L'#', Item::stick, L'V');
addShapedRecipy(new ItemInstance(Tile::activatorRail, 6), // L"ssscictcig", L"XSX", // L"X#X", // L"XSX", //
L'X', Item::ironIngot,// L'#', Tile::redstoneTorch_on,// L'S', Item::stick, L'V');
addShapedRecipy(new ItemInstance(Tile::detectorRail, 6), // L"ssscicictg", L"X X", // L"X#X", // L"XRX", //
L'X', Item::ironIngot,// L'R', Item::redStone,// L'#', Tile::pressurePlate_stone, L'V');
addShapedRecipy(new ItemInstance(Item::minecart, 1), // L"sscig", L"# #", // L"###", //
L'#', Item::ironIngot, L'V');
addShapedRecipy(new ItemInstance(Item::minecart_chest, 1), // L"ssctcig", L"A", // L"B", //
L'A', Tile::chest, L'B', Item::minecart, L'V');
addShapedRecipy(new ItemInstance(Item::minecart_furnace, 1), // L"ssctcig", L"A", // L"B", //
L'A', Tile::furnace, L'B', Item::minecart, L'V');
addShapedRecipy(new ItemInstance(Item::minecart_tnt, 1), // L"ssctcig", L"A", // L"B", //
L'A', Tile::tnt, L'B', Item::minecart, L'V');
addShapedRecipy(new ItemInstance(Item::minecart_hopper, 1), // L"ssctcig", L"A", // L"B", //
L'A', Tile::hopper, L'B', Item::minecart, L'V');
addShapedRecipy(new ItemInstance(Item::boat, 1), // L"ssctg", L"# #", // L"###", //
L'#', Tile::wood, L'V');
addShapedRecipy(new ItemInstance((Item *)Item::fishingRod, 1), // L"ssscicig", L" #", // L" #X", // L"# X", //
L'#', Item::stick, L'X', Item::string, L'T');
addShapedRecipy(new ItemInstance(Item::carrotOnAStick, 1), // L"sscicig", L"# ", // L" X", //
L'#', Item::fishingRod, L'X', Item::carrots, L'T')->keepTag();
addShapedRecipy(new ItemInstance(Item::flintAndSteel, 1), // L"sscicig", L"A ", // L" B", //
L'A', Item::ironIngot, L'B', Item::flint, L'T');
addShapedRecipy(new ItemInstance(Item::bread, 1), // L"scig", L"###", //
L'#', Item::wheat, L'F');
// Moved bow and arrow in from weapons to avoid stacking on the group name display addShapedRecipy(new ItemInstance((Item *)Item::bow, 1), // L"ssscicig", L" #X", // L"# X", // L" #X", //
L'X', Item::string,// L'#', Item::stick, L'T');
addShapedRecipy(new ItemInstance(Item::arrow, 4), // L"ssscicicig", L"X", // L"#", // L"Y", //
L'Y', Item::feather,// L'X', Item::flint,// L'#', Item::stick, L'T');
pWeaponRecipies->addRecipes(this);
addShapedRecipy(new ItemInstance(Item::bucket_empty, 1), // L"sscig", L"# #", // L" # ", //
L'#', Item::ironIngot, L'T');
addShapedRecipy(new ItemInstance(Item::bowl, 4), // L"ssctg", L"# #", // L" # ", //
L'#', Tile::wood, L'T');
addShapedRecipy(new ItemInstance(Item::glassBottle, 3), // L"ssctg", L"# #", // L" # ", //
L'#', Tile::glass, L'T');
addShapedRecipy(new ItemInstance(Item::flowerPot, 1), // L"sscig", L"# #", // L" # ", //
L'#', Item::brick, L'D');
// torch made of charcoal - moved to be the default due to the tutorial using it addShapedRecipy(new ItemInstance(Tile::torch, 4), // L"ssczcig", L"X", // L"#", //
L'X', new ItemInstance(Item::coal, 1, CoalItem::CHAR_COAL),// L'#', Item::stick, L'T');
addShapedRecipy(new ItemInstance(Tile::torch, 4), // L"ssczcig", L"X", // L"#", // L'X', new ItemInstance(Item::coal, 1, CoalItem::STONE_COAL),// L'#', Item::stick, L'T');
addShapedRecipy(new ItemInstance(Tile::glowstone, 1), // L"sscig", L"##", // L"##", //
L'#', Item::yellowDust, L'T');
addShapedRecipy(new ItemInstance(Tile::quartzBlock, 1), // L"sscig", L"##", // L"##", //
L'#', Item::netherQuartz, L'S');
addShapedRecipy(new ItemInstance(Tile::lever, 1), // L"ssctcig", L"X", // L"#", //
L'#', Tile::cobblestone, L'X', Item::stick, L'M');
addShapedRecipy(new ItemInstance(Tile::tripWireSource, 2), // L"sssctcicig", L"I", // L"S", // L"#", //
L'#', Tile::wood, L'S', Item::stick, L'I', Item::ironIngot, L'M');
addShapedRecipy(new ItemInstance(Tile::redstoneTorch_on, 1), // L"sscicig", L"X", // L"#", //
L'#', Item::stick, L'X', Item::redStone, L'M');
addShapedRecipy(new ItemInstance(Item::repeater, 1), // L"ssctcictg", L"#X#", // L"III", //
L'#', Tile::redstoneTorch_on, L'X', Item::redStone, L'I', Tile::stone, L'M');
addShapedRecipy(new ItemInstance(Item::comparator, 1), // L"sssctcictg", L" # ", // L"#X#", // L"III", //
L'#', Tile::redstoneTorch_on, L'X', Item::netherQuartz, L'I', Tile::stone, L'M');
addShapedRecipy(new ItemInstance(Tile::daylightDetector), L"sssctcictg", L"GGG", L"QQQ", L"WWW",
L'G', Tile::glass, L'Q', Item::netherQuartz, L'W', Tile::woodSlabHalf, L'M');
addShapedRecipy(new ItemInstance(Tile::hopper), L"ssscictg", L"I I", // L"ICI", // L" I ", //
L'I', Item::ironIngot, L'C', Tile::chest, L'M');
addShapedRecipy(new ItemInstance(Item::clock, 1), // L"ssscicig", L" # ", // L"#X#", // L" # ", // L'#', Item::goldIngot, L'X', Item::redStone, L'T');
addShapelessRecipy(new ItemInstance(Item::eyeOfEnder, 1), // L"iig", Item::enderPearl, Item::blazePowder, L'T');
addShapelessRecipy(new ItemInstance(Item::fireball, 3), // L"iiig", Item::gunpowder, Item::blazePowder,Item::coal, L'T');
addShapelessRecipy(new ItemInstance(Item::fireball, 3), // L"iizg", Item::gunpowder, Item::blazePowder,new ItemInstance(Item::coal, 1, CoalItem::CHAR_COAL), L'T');
addShapedRecipy(new ItemInstance(Item::lead, 2), // L"ssscicig", L"~~ ", // L"~O ", // L" ~", // L'~', Item::string, L'O', Item::slimeBall, L'T');
addShapedRecipy(new ItemInstance(Item::compass, 1), // L"ssscicig", L" # ", // L"#X#", // L" # ", //
L'#', Item::ironIngot, L'X', Item::redStone, L'T');
addShapedRecipy(new ItemInstance(Item::map, 1), // L"ssscicig", L"###", // L"#X#", // L"###", //
L'#', Item::paper, L'X', Item::compass, L'T'); addShapedRecipy(new ItemInstance(Tile::button, 1), // L"sctg", L"#", //
L'#', Tile::stone, L'M');
addShapedRecipy(new ItemInstance(Tile::button_wood, 1), // L"sctg", L"#", //
L'#', Tile::wood, L'M');
addShapedRecipy(new ItemInstance(Tile::pressurePlate_wood, 1), // L"sctg", L"##", // L'#', Tile::wood, L'M');
addShapedRecipy(new ItemInstance(Tile::pressurePlate_stone, 1), // L"sctg", L"##", // L'#', Tile::stone, L'M');
addShapedRecipy(new ItemInstance(Tile::weightedPlate_heavy, 1), // L"scig", L"##", //
L'#', Item::ironIngot, L'M');
addShapedRecipy(new ItemInstance(Tile::weightedPlate_light, 1), // L"scig", L"##", //
L'#', Item::goldIngot, L'M');
addShapedRecipy(new ItemInstance(Tile::dispenser, 1), // L"sssctcicig", L"###", // L"#X#", // L"#R#", // L'#', Tile::cobblestone, L'X', Item::bow, L'R', Item::redStone, L'M');
addShapedRecipy(new ItemInstance(Tile::dropper, 1), // L"sssctcig", L"###", // L"# #", // L"#R#", //
L'#', Tile::cobblestone, L'R', Item::redStone, L'M');
addShapedRecipy(new ItemInstance(Item::cauldron, 1), // L"ssscig", L"# #", // L"# #", // L"###", //
L'#', Item::ironIngot, L'T');
addShapedRecipy(new ItemInstance(Item::brewingStand, 1), // L"ssctcig", L" B ", // L"###", //
L'#', Tile::cobblestone, L'B', Item::blazeRod, L'S');
addShapedRecipy(new ItemInstance(Tile::litPumpkin, 1), // L"ssctctg", L"A", // L"B", //
L'A', Tile::pumpkin, L'B', Tile::torch, L'T');
addShapedRecipy(new ItemInstance(Tile::jukebox, 1), // L"sssctcig", L"###", // L"#X#", // L"###", //
L'#', Tile::wood, L'X', Item::diamond, 'D');
addShapedRecipy(new ItemInstance(Item::paper, 3), // L"scig", L"###", //
L'#', Item::reeds, L'D');
addShapelessRecipy(new ItemInstance(Item::book, 1), L"iiiig", Item::paper, Item::paper, Item::paper, Item::leather, L'D');
//addShapelessRecipy(new ItemInstance(Item.writingBook, 1), // // Item.book, new ItemInstance(Item.dye_powder, 1, DyePowderItem.BLACK), Item.feather);
addShapedRecipy(new ItemInstance(Tile::noteblock, 1), // L"sssctcig", L"###", // L"#X#", // L"###", //
L'#', Tile::wood, L'X', Item::redStone, L'M');
addShapedRecipy(new ItemInstance(Tile::bookshelf, 1), // L"sssctcig", L"###", // L"XXX", // L"###", //
L'#', Tile::wood, L'X', Item::book, L'D');
addShapedRecipy(new ItemInstance(Item::painting, 1), // L"ssscictg", L"###", // L"#X#", // L"###", //
L'#', Item::stick, L'X', Tile::wool, L'D');
addShapedRecipy(new ItemInstance(Item::frame, 1), // L"ssscicig", L"###", // L"#X#", // L"###", //
L'#', Item::stick, L'X', Item::leather, L'D');
pOreRecipies->addRecipes(this);
addShapedRecipy(new ItemInstance(Item::goldIngot), // L"ssscig", L"###", // L"###", // L"###", //
L'#', Item::goldNugget, L'D');
addShapedRecipy(new ItemInstance(Item::goldNugget, 9), // L"scig", L"#", // L'#', Item::goldIngot, L'D');
// 4J-PB - moving into decorations to make the structures list smaller addShapedRecipy(new ItemInstance(Item::sign, 3), // L"sssctcig", L"###", // L"###", // L" X ", //
L'#', Tile::wood, L'X', Item::stick, L'D');
// 4J - TODO - put these new 1.7.3 items in required place within recipes addShapedRecipy(new ItemInstance((Tile *)Tile::pistonBase, 1), // L"sssctcicictg", L"TTT", // L"#X#", // L"#R#", //
L'#', Tile::cobblestone, L'X', Item::ironIngot, L'R', Item::redStone, L'T', Tile::wood, L'M');
addShapedRecipy(new ItemInstance((Tile *)Tile::pistonStickyBase, 1), // L"sscictg", L"S", // L"P", //
L'S', Item::slimeBall, L'P', Tile::pistonBase, L'M');
// 4J Stu - Added some dummy firework recipes to allow us to navigate forward to the fireworks scene addShapedRecipy(new ItemInstance(Item::fireworks, 1), // L"sscicig", L" P ", // L" G ", //
L'P', Item::paper, L'G', Item::gunpowder, L'D');
addShapedRecipy(new ItemInstance(Item::fireworksCharge,1), // L"sscicig", L" D ", // L" G ", //
L'D', Item::dye_powder, L'G', Item::gunpowder, L'D');
addShapedRecipy(new ItemInstance(Item::fireworksCharge,1), // L"sscicig", L" D ", // L" C ", //
L'D', Item::dye_powder, L'C', Item::fireworksCharge, L'D');
// Sort so the largest recipes get checked first! /* 4J-PB - TODO Collections.sort(recipies, new Comparator<Recipy>() { public: int compare(Recipy r0, Recipy r1) {
// shapeless recipes are put in the back of the list if (r0 instanceof ShapelessRecipy && r1 instanceof ShapedRecipy) { return 1; } if (r1 instanceof ShapelessRecipy && r0 instanceof ShapedRecipy) { return -1; }
if (r1.size() < r0.size()) return -1; if (r1.size() > r0.size()) return 1; return 0; } }); */
// 4J-PB removed System.out.println(recipies->size() + L" recipes");
// 4J-PB - build the array of ingredients required per recipe buildRecipeIngredientsArray();}
// 4J-PB - this function has been substantially changed due to the differences with a va_list of classes in C++ and JavaShapedRecipy *Recipes::addShapedRecipy(ItemInstance *result, ...){ wstring map = L""; int p = 0; int width = 0; int height = 0; int group = ShapedRecipy::eGroupType_Decoration; va_list vl; wchar_t *wchTypes; wchar_t *pwchString; wstring wString; wstring *wStringA; ItemInstance *pItemInstance; Tile *pTile; Item *pItem; wchar_t wchFrom; int iCount; ItemInstance **ids = NULL;
myMap *mappings = new unordered_map<wchar_t, ItemInstance *>();
va_start(vl,result); // 4J-PB - second argument is a list of the types // s - string // w - string array // a - char * // c - char // z - ItemInstance * // i - Item * // t - Tile * // g - group [wt] - which group does the item created by the recipe belong in. Set a default until all recipes have a group
wchTypes = va_arg(vl,wchar_t *);
for(int i = 0; wchTypes[i] != L'\0'; ++i ) { if(wchTypes[i+1]==L'\0' && wchTypes[i]!=L'g') { app.DebugPrintf("Missing group type\n"); }
switch(wchTypes[i]) { case L'a': pwchString=va_arg(vl,wchar_t *); wString=pwchString; height++; width = (int)wString.length(); map += wString; break; case L's': pwchString=va_arg(vl,wchar_t *); wString=pwchString; height++; width = (int)wString.length(); map += wString; break; case L'w': wStringA=va_arg(vl,wstring *); iCount=0; do { wString=wStringA[iCount++]; if(!wString.empty()) { height++; width = (int)wString.length(); map += wString; } } while(!wString.empty());
break; case L'c': wchFrom=va_arg(vl,wchar_t); break; case L'z': pItemInstance=va_arg(vl,ItemInstance *); mappings->insert(myMap::value_type(wchFrom,pItemInstance)); break; case L'i': pItem=va_arg(vl,Item *); pItemInstance= new ItemInstance(pItem,1,ANY_AUX_VALUE); mappings->insert(myMap::value_type(wchFrom,pItemInstance)); break; case L't': pTile=va_arg(vl,Tile *); pItemInstance= new ItemInstance(pTile,1,ANY_AUX_VALUE); mappings->insert(myMap::value_type(wchFrom,pItemInstance)); break; case L'g': wchFrom=va_arg(vl,wchar_t); switch(wchFrom) {// case L'W':// group=ShapedRecipy::eGroupType_Weapon;// break; case L'T': group=ShapedRecipy::eGroupType_Tool; break; case L'A': group=ShapedRecipy::eGroupType_Armour; break; case L'S': group=ShapedRecipy::eGroupType_Structure; break; case L'V': group=ShapedRecipy::eGroupType_Transport; break; case L'M': group=ShapedRecipy::eGroupType_Mechanism; break; case L'F': group=ShapedRecipy::eGroupType_Food; break; case L'D': default: group=ShapedRecipy::eGroupType_Decoration; break;
} break;
}
ids = new ItemInstance *[width * height];
for (int j = 0; j < width * height; j++) { wchar_t ch = map[j]; myMap::iterator it=mappings->find(ch); if (it != mappings->end()) { ids[j] =it->second; } else { ids[j] = NULL; } } }
va_end(vl);
ShapedRecipy *recipe = new ShapedRecipy(width, height, ids, result, group); recipies->push_back(recipe); return recipe;}
void Recipes::addShapelessRecipy(ItemInstance *result,... ) { va_list vl; wchar_t *szTypes; wstring String; ItemInstance *pItemInstance; Tile *pTile; Item *pItem; Recipy::_eGroupType group = Recipy::eGroupType_Decoration; wchar_t wchFrom; vector <ItemInstance *> *ingredients = new vector<ItemInstance *>();
va_start(vl,result); // 4J-PB - second argument is a list of the types // z - ItemInstance * // i - Item * // t - Tile * szTypes = va_arg(vl,wchar_t *);
for(int i = 0; szTypes[i] != L'\0'; ++i ) { switch(szTypes[i]) { case L'z': pItemInstance=va_arg(vl,ItemInstance *); // 4J-PB - original code copies the item instance, copy the pointer isnt the same... // TODO ingredients->push_back(pItemInstance->copy_not_shared()); break; case L'i': pItem=va_arg(vl,Item *); pItemInstance= new ItemInstance(pItem); ingredients->push_back(pItemInstance); break; case L't': pTile=va_arg(vl,Tile *); ingredients->push_back(new ItemInstance(pTile)); break; case L'g': wchFrom=va_arg(vl,wchar_t); switch(wchFrom) {
case L'T': group=Recipy::eGroupType_Tool; break; case L'A': group=Recipy::eGroupType_Armour; break; case L'S': group=Recipy::eGroupType_Structure; break; case L'V': group=Recipy::eGroupType_Transport; break; case L'M': group=Recipy::eGroupType_Mechanism; break; case L'F': group=Recipy::eGroupType_Food; break; case L'D': default: group=Recipy::eGroupType_Decoration; break;
} break; } }
recipies->push_back(new ShapelessRecipy(result, ingredients, group)); }
shared_ptr<ItemInstance> Recipes::getItemFor(shared_ptr<CraftingContainer> craftSlots, Level *level, Recipy *recipesClass /*= NULL*/) { int count = 0; shared_ptr<ItemInstance> first = nullptr; shared_ptr<ItemInstance> second = nullptr; for (int i = 0; i < craftSlots->getContainerSize(); i++) { shared_ptr<ItemInstance> item = craftSlots->getItem(i); if (item != NULL) { if (count == 0) first = item; if (count == 1) second = item; count++; } }
if (count == 2 && first->id == second->id && first->count == 1 && second->count == 1 && Item::items[first->id]->canBeDepleted()) { Item *item = Item::items[first->id]; int remaining1 = item->getMaxDamage() - first->getDamageValue(); int remaining2 = item->getMaxDamage() - second->getDamageValue(); int remaining = (remaining1 + remaining2) + item->getMaxDamage() * 5 / 100; int resultDamage = item->getMaxDamage() - remaining; if (resultDamage < 0) resultDamage = 0; return shared_ptr<ItemInstance>( new ItemInstance(first->id, 1, resultDamage) ); }
if(recipesClass != NULL) { if (recipesClass->matches(craftSlots, level)) return recipesClass->assemble(craftSlots); } else { AUTO_VAR(itEnd, recipies->end()); for (AUTO_VAR(it, recipies->begin()); it != itEnd; it++) { Recipy *r = *it; //recipies->at(i); if (r->matches(craftSlots, level)) return r->assemble(craftSlots); } } return nullptr;}
vector <Recipy *> *Recipes::getRecipies() { return recipies;}
// 4J-PB - added to deal with Xb0x 'crafting'shared_ptr<ItemInstance> Recipes::getItemForRecipe(Recipy *r) { return r->assemble(nullptr);}
// 4J-PB - build the required ingredients for recipesvoid Recipes::buildRecipeIngredientsArray(void){ //RecipyList *recipes = ((Recipes *)Recipes::getInstance())->getRecipies();
int iRecipeC=(int)recipies->size();
m_pRecipeIngredientsRequired= new Recipy::INGREDIENTS_REQUIRED [iRecipeC];
int iCount=0; AUTO_VAR(itEndRec, recipies->end()); for (AUTO_VAR(it, recipies->begin()); it != itEndRec; it++) { Recipy *recipe = *it; //wprintf(L"RECIPE - [%d] is %w\n",iCount,recipe->getResultItem()->getItem()->getName()); recipe->requires(&m_pRecipeIngredientsRequired[iCount++]); }
//printf("Total recipes in buildRecipeIngredientsArray - %d",iCount);}
Recipy::INGREDIENTS_REQUIRED *Recipes::getRecipeIngredientsArray(void){ return m_pRecipeIngredientsRequired;}