package Ġnet . cy dh ra . tech n ocracy . foundation . craft ing Ċ Ċ import Ġcom . google . common . collect . Hash Multimap Ċ import Ġcom . google . common . collect . Multimap Ċ import Ġcom . google . gson . Gson Ċ import Ġcom . google . gson . JsonObject Ċ import Ġcom . google . gson . Json ParseException Ċ import Ġnet . cy dh ra . tech n ocracy . foundation . TC Foundation Ċ import Ġnet . cy dh ra . tech n ocracy . foundation . blocks . general .* Ċ import Ġnet . cy dh ra . tech n ocracy . foundation . craft ing . Recipe Manager . RE CI PE _ AS SETS _ FOLDER Ċ import Ġnet . cy dh ra . tech n ocracy . foundation . craft ing . types .* Ċ import Ġnet . cy dh ra . tech n ocracy . foundation . tile entity . Abstract TileEntity Ċ import Ġnet . cy dh ra . tech n ocracy . foundation . tile entity . Machine TileEntity Ċ import Ġnet . cy dh ra . tech n ocracy . foundation . tile entity . machines .* Ċ import Ġnet . minecraft . block . Block Ċ import Ġnet . minecraft . util . Json Utils Ċ import Ġnet . minecraftforge . common . craft ing . Craft ing Helper Ċ import Ġnet . minecraftforge . common . craft ing . Json Context Ċ import Ġnet . minecraftforge . fml . common . Loader Ċ import Ġorg . apache . commons . io . Filename Utils Ċ import Ġjava . nio . file . Files Ċ import Ġjava . nio . file . Path Ċ Ċ /** Ċ Ġ* ĠA Ġutility Ġclass Ġthat Ġloads Ġcustom Ġrecipe Ġtypes Ġfrom Ġ[ RE CI PE _ AS SETS _ FOLDER ] Ġand Ġcan Ġbe Ġqueried Ġfor Ġthem Ġlater . Ċ Ġ*/ Ċ object ĠRecipe Manager Ġ{ ĊĊĠĠĠ Ġ/** ĊĠĠĠĠ Ġ* ĠAssets Ġfolder Ġof Ġcustom Ġrecipe Ġtypes ĊĠĠĠĠ Ġ*/ ĊĠĠĠ Ġprivate Ġconst Ġval ĠRE CI PE _ AS SETS _ FOLDER Ġ= Ġ" t cre cipes " ĊĊĠĠĠ Ġ/** ĊĠĠĠĠ Ġ* ĠGson Ġinstance Ġfor Ġde serializing Ġof Ġthe Ġrecipes ĊĠĠĠĠ Ġ*/ ĊĠĠĠ Ġprivate Ġval Ġgson Ġ= ĠGson () ĊĊĠĠĠ Ġ/** ĊĠĠĠĠ Ġ* ĠJson Ġcontext Ġfor Ġde serialization ĊĠĠĠĠ Ġ*/ ĊĠĠĠ Ġprivate Ġval Ġjson Context Ġ= ĠJson Context ( TC Foundation . MOD ID ) ĊĊĠĠĠ Ġ/** ĊĠĠĠĠ Ġ* ĠAll Ġrecipes Ġloaded Ġby Ġtype ĊĠĠĠĠ Ġ*/ ĊĠĠĠ Ġprivate Ġval Ġloaded Recipes : ĠMult imap < Recipe Type , ĠI Machine Recipe > Ġ= ĠHash Multimap . create () ĊĊĠĠĠ Ġ/** ĊĠĠĠĠ Ġ* ĠCalled Ġupon Ġpost Ġinitialization Ġby Ġcommon Ġproxy . ĠAt tempts Ġto Ġload Ġrecipes Ġof Ġall Ġdifferent Ġmachine Ġtypes . ĊĠĠĠĠ Ġ*/ ĊĠĠĠ Ġfun Ġinitialize () Ġ{ ĊĠĠĠĠĠĠĠ Ġparse Machine Recipes (" al loy _ s mel tery ", ĠAl loy S mel tery Recipe Parser , ĠRecipe Manager . Recipe Type . AL LOY ) ĊĠĠĠĠĠĠĠ Ġparse Machine Recipes (" cent rif uge ", ĠCent rif uge Recipe Parser , ĠRecipe Manager . Recipe Type . C ENTR IF U GE ) ĊĠĠĠĠĠĠĠ Ġparse Machine Recipes (" che mical _ etch ing ", ĠChe mical Et ch ing Parser , ĠRecipe Manager . Recipe Type . CH EM ICAL _ ETCH ING ) ĊĠĠĠĠĠĠĠ Ġparse Machine Recipes (" che mical _ ox id izer ", ĠChe mical Ox id izer Recipe Parser , ĠRecipe Manager . Recipe Type . CH EM ICAL _ OX ID IZER ) ĊĠĠĠĠĠĠĠ Ġparse Machine Recipes (" che mical _ processing ", ĠChe mical Processing Parser , ĠRecipe Manager . Recipe Type . CH EM ICAL _ PROCESS ING ) ĊĠĠĠĠĠĠĠ Ġparse Machine Recipes (" che mical _ reaction ", ĠChe mical Reaction Recipe Parser , ĠRecipe Manager . Recipe Type . CH EM ICAL _ RE ACTION ) ĊĠĠĠĠĠĠĠ Ġparse Machine Recipes (" comp actor ", ĠComp actor Recipe Parser , ĠRecipe Manager . Recipe Type . COMP ACT OR ) ĊĠĠĠĠĠĠĠ Ġparse Machine Recipes (" crystal liz ation ", ĠCr ystal liz ation Recipe Parser , ĠRecipe Manager . Recipe Type . CR Y ST AL LI Z ATION ) ĊĠĠĠĠĠĠĠ Ġparse Machine Recipes (" dis solution ", ĠDis solution Recipe Parser , ĠRecipe Manager . Recipe Type . DIS SOL UTION ) ĊĠĠĠĠĠĠĠ Ġparse Machine Recipes (" electric _ f urn ace ", ĠE lectric F urn ace Recipe Parser , ĠRecipe Manager . Recipe Type . E LECT RIC _ F URN ACE ) ĊĠĠĠĠĠĠĠ Ġparse Machine Recipes (" elect ro ly sis ", ĠElect ro ly sis Recipe Parser , ĠRecipe Manager . Recipe Type . E LECT RO LY SIS ) ĊĠĠĠĠĠĠĠ Ġparse Machine Recipes (" k il n ", ĠK il n Recipe Parser , ĠRecipe Manager . Recipe Type . K IL N ) ĊĠĠĠĠĠĠĠ Ġparse Machine Recipes (" pul ver izer ", ĠP ul ver izer Recipe Parser , ĠRecipe Manager . Recipe Type . P UL VER IZER ) ĊĠĠĠĠĠĠĠ Ġparse Machine Recipes (" ref in ery ", ĠRe fin ery Recipe Parser , ĠRecipe Manager . Recipe Type . REF IN ERY ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ/** ĊĠĠĠĠ Ġ* ĠQuery Ġall Ġrecipes Ġof Ġa Ġspecific Ġtype ĊĠĠĠĠ Ġ* ĊĠĠĠĠ Ġ* Ġ@ param Ġtype Ġrequest Ġrecipe Ġtype ĊĠĠĠĠ Ġ* ĊĠĠĠĠ Ġ* Ġ@ return Ġan Ġimmutable Ġcollection Ġof Ġregistered Ġrecipes Ġof Ġthe Ġspecified Ġtype ĊĠĠĠĠ Ġ*/ ĊĠĠĠ Ġfun Ġget Recipes ByType ( type : ĠRecipe Type ): ĠCollection < IM achine Recipe >? Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġloaded Recipes [ type ] ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ/** ĊĠĠĠĠ Ġ* ĠAdd Ġa Ġrecipe Ġoutside Ġfrom Ġthe Ġrecipe Ġjson Ġmodel Ġdata . ĠBe Ġaware Ġthat Ġthe Ġusage Ġof Ġthis Ġfunction Ġis Ġunsafe , Ġas ĊĠĠĠĠ Ġ* Ġincompatible Ġrecipe Ġtypes Ġcan Ġbe Ġregistered , Ġwhich Ġwill Ġlater Ġcause Ġ[ Class CastException ] s Ġwhen Ġtrying Ġto Ġparse ĊĠĠĠĠ Ġ* Ġthem . ĊĠĠĠĠ Ġ* ĊĠĠĠĠ Ġ* Ġ@ param Ġtype Ġrecipe Ġtype ĊĠĠĠĠ Ġ* Ġ@ param Ġrecipe Ġrecipe Ġmodel ĊĠĠĠĠ Ġ*/ ĊĠĠĠ Ġfun Ġregister Recipe ( type : ĠRecipe Type , Ġrecipe : ĠI Machine Recipe ) Ġ{ ĊĠĠĠĠĠĠĠ Ġloaded Recipes . put ( type , Ġrecipe ) ĊĠĠĠ Ġ} ĊĊĊĠĠĠ Ġ/** ĊĠĠĠĠ Ġ* ĠLoad Ġa Ġrecipe Ġoff Ġa Ġpath Ġthat Ġhas Ġbeen Ġfound Ġby Ġthe Ġ[ Craft ing Helper ]. ĠThe Ġparsed Ġjson Ġobject Ġis Ġthen Ġh anded Ġto ĊĠĠĠĠ Ġ* Ġthe Ġgiven Ġ[ parser ] ĊĠĠĠĠ Ġ* ĊĠĠĠĠ Ġ* Ġ@ param Ġpath Ġpath Ġwhere Ġthe Ġfile Ġis Ġlocated ĊĠĠĠĠ Ġ* Ġ@ param Ġparser Ġthe Ġresponsible Ġparser Ġfor Ġthe Ġrecipe Ġfile ĊĠĠĠĠ Ġ* Ġ@ param Ġtype Ġrecipe Ġtype Ġthat Ġis Ġloaded ĊĠĠĠĠ Ġ* ĊĠĠĠĠ Ġ* Ġ@ return Ġtrue Ġif Ġthe Ġfile Ġhas Ġeither Ġbeen Ġloaded Ġsuccessfully Ġor Ġwas Ġnot Ġloaded Ġon Ġpurpose . ĠFalse Ġin Ġcase Ġof Ġan ĊĠĠĠĠ Ġ* Ġerror ĊĠĠĠĠ Ġ*/ ĊĠĠĠ Ġprivate Ġfun Ġload Recipe ( path : ĠPath , Ġparser : ĠRecipe Parser <* >, Ġtype : ĠRecipe Type ): ĠBoolean Ġ{ ĊĠĠĠĠĠĠĠ Ġif Ġ( Filename Utils . getExtension ( path . toString ()) Ġ!= Ġ" json ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn Ġtrue ĊĊĠĠĠĠĠĠĠ Ġval ĠjsonObject Ġ= Ġtry Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠFiles . new BufferedReader ( path ). use Ġ{ Ġreader Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠJson Utils . fromJson ( gson , Ġreader , ĠJsonObject :: class . java ) !! ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} Ġcatch Ġ( e : ĠJson ParseException ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠTC Foundation . logger . error (" JSON Ġparse Ġexception ", Ġe ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn Ġfalse ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġtry Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġrecipe Ġ= Ġparser . process ( jsonObject , Ġjson Context ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġloaded Recipes . put ( type , Ġrecipe ) ĊĠĠĠĠĠĠĠ Ġ} Ġcatch Ġ( e : ĠIllegalStateException ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠTC Foundation . logger . error (" Recipe Ġparse Ġexception ", Ġe ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn Ġfalse ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġreturn Ġtrue ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ/** ĊĠĠĠĠ Ġ* ĠParse Ġall Ġrecipes Ġlocated Ġat Ġa Ġgiven Ġendpoint Ġthat Ġare Ġmeant Ġfor Ġa Ġgiven Ġparser ĊĠĠĠĠ Ġ* ĊĠĠĠĠ Ġ* Ġ@ param Ġendpoint Ġsub folder Ġof Ġ[ RE CI PE _ AS SETS _ FOLDER ] Ġwhere Ġall Ġrecipes Ġfor Ġthe Ġgiven Ġparser Ġare Ġlocated ĊĠĠĠĠ Ġ* Ġ@ param Ġparser Ġparser Ġfor Ġrecipes Ġat Ġthe Ġgiven Ġendpoint ĊĠĠĠĠ Ġ* Ġ@ param Ġtype Ġtype Ġof Ġrecipe Ġthat Ġis Ġloaded ĊĠĠĠĠ Ġ*/ ĊĠĠĠ Ġprivate Ġfun Ġparse Machine Recipes ( endpoint : ĠString , Ġparser : ĠRecipe Parser <* >, Ġtype : ĠRecipe Type ) Ġ{ ĊĠĠĠĠĠĠĠ ĠLoader . instance (). indexed Mod List . forEach Ġ{ Ġ( mod Id , Ġmod Container ) Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ ĠCraft ing Helper . find Files ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġmod Container , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" assets /$ mod Id /$ RE CI PE _ AS SETS _ FOLDER /$ endpoint ", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ{ Ġtrue Ġ}, ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ{ Ġ_, Ġpath Ġ-> Ġthis . load Recipe ( path , Ġparser , Ġtype ) Ġ}, ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġtrue , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġtrue ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ/** ĊĠĠĠĠ Ġ* ĠAn Ġenumeration Ġof Ġall Ġcustom Ġrecipe Ġtypes Ġparsed Ġby Ġthe ĠRecipe Manager ĊĠĠĠĠ Ġ* Ġ@ param Ġmachine Block Ġused Ġfor Ġje i Ġintegration ; Ġmight Ġbe Ġnull Ġif Ġmachine Ġwhich Ġbelongs Ġto Ġthis Ġrecipe Ġtype Ġis Ġmanually Ġhandled Ġ( f . e . Ġref in ery ) ĊĠĠĠĠ Ġ* Ġ@ param Ġtile Entity Class Ġused Ġfor Ġje i Ġintegration ; Ġmight Ġbe Ġnull Ġif Ġmachine Ġwhich Ġbelongs Ġto Ġthis Ġrecipe Ġtype Ġis Ġmanually Ġhandled Ġ( f . e . Ġref in ery ) ĊĠĠĠĠ Ġ*/ ĊĠĠĠ Ġenum Ġclass ĠRecipe Type ( val Ġmachine Block : ĠBlock ?, Ġval Ġtile Entity Class : ĠClass < out ĠMachine TileEntity > ?) Ġ{ ĊĠĠĠĠĠĠĠ ĠAL LOY ( al loy S mel tery Block , ĠTile Entity Al loy S mel tery :: class . java ), ĊĠĠĠĠĠĠĠ ĠC ENTR IF U GE ( cent rif uge Block , ĠTile Entity Cent rif uge :: class . java ), ĊĠĠĠĠĠĠĠ ĠCHE M ICAL _ ETCH ING ( che mical Et ch ing Ch amber Block , ĠTile Entity Che mical Et ch ing Ch amber :: class . java ), ĊĠĠĠĠĠĠĠ ĠCHE M ICAL _ OX ID IZER ( che mical Ox id izer Block , ĠTile Entity Che mical Ox id izer :: class . java ), ĊĠĠĠĠĠĠĠ ĠCHE M ICAL _ PROCESS ING ( che mical Processing Ch amber Block , ĠTile Entity Che mical Processing Ch amber :: class . java ), ĊĠĠĠĠĠĠĠ ĠCHE M ICAL _ RE ACTION ( che mical Reaction Ch amber Block , ĠTile Entity Che mical Reaction Ch amber :: class . java ), ĊĠĠĠĠĠĠĠ ĠCOMP ACT OR ( comp actor Block , ĠTile Entity Comp actor :: class . java ), ĊĠĠĠĠĠĠĠ ĠCR Y ST AL LI Z ATION ( crystal liz ation Ch amber Block , ĠTile Entity Cr ystal liz ation Ch amber :: class . java ), ĊĠĠĠĠĠĠĠ ĠDIS SOL UTION ( dis solution Ch amber Block , ĠTile Entity Dis solution Ch amber :: class . java ), ĊĠĠĠĠĠĠĠ ĠE LECT RIC _ F URN ACE ( electric F urn ace Block , ĠTile Entity Electric F urn ace :: class . java ), ĊĠĠĠĠĠĠĠ ĠE LECT RO LY SIS ( elect ro ly sis Ch amber Block , ĠTile Entity Elect ro ly sis Ch amber :: class . java ), ĊĠĠĠĠĠĠĠ ĠK IL N ( k il n Block , ĠTile Entity K il n :: class . java ), ĊĠĠĠĠĠĠĠ ĠP UL VER IZER ( pul ver izer Block , ĠTile Entity Pul ver izer :: class . java ), ĊĊĠĠĠĠĠĠĠ ĠRE FIN ERY ( null , Ġnull ) ĊĠĠĠ Ġ} Ċ }