package Ġpf ister . qu icker craft ing . client . craft ing Ċ Ċ import Ġkotlinx . coroutines . Coroutine Start Ċ import Ġkotlinx . coroutines . Experimental Cor outines Api Ċ import Ġkotlinx . coroutines . Global Scope Ċ import Ġkotlinx . coroutines . channels . Channel Ċ import Ġkotlinx . coroutines . channels . consume Each Ċ import Ġkotlinx . coroutines . launch Ċ import Ġnet . minecraft . client . util . Recipe Item Helper Ċ import Ġnet . minecraft . item . ItemStack Ċ import Ġnet . minecraft . item . craft ing . I Recipe Ċ import Ġpf ister . qu icker craft ing . client . gui . Displayed Recipe Filter Ċ import Ġpf ister . qu icker craft ing . common . craft ing . Recipe Graph Ċ import Ġpf ister . qu icker craft ing . common . util . account Set Ċ import Ġpf ister . qu icker craft ing . common . util . set Packed Ċ Ċ // ĠCreates Ġand Ġhandles Ġa Ġbackground Ġdaemon Ġcoroutine Ġthat Ġkeeps Ġtrack Ġof Ġthe Ġrecipes Ċ // Ġthe Ġplayer Ġcan Ġcraft Ġgiven Ġtheir Ġinventory Ċ object ĠRecipe Worker Ġ{ ĊĠĠĠ Ġ// ĠContains Ġall Ġthe Ġrecipes Ġthe Ġplayer Ġcan Ġcurrently Ġcraft ĊĠĠĠ Ġval ĠCraft able Recipes : ĠMutable Set < I Recipe > Ġ= ĠHashSet () ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġrecipe Graph : ĠRecipe Graph ĊĊĠĠĠ Ġprivate Ġval Ġrecipe Item Helper Ġ= ĠRecipe Item Helper () ĊĊĠĠĠ Ġ// ĠThe Ġchannel Ġthat Ġdata Ġis Ġsent Ġto ĠRE CI PE _ DA EM ON Ġthrough ĊĠĠĠ Ġprivate Ġval ĠRE CI PE _ CHANNEL : ĠChannel < Pair < Int , ĠInt >> Ġ= ĠChannel ( Channel . Factory . UN LIMIT ED ) ĊĊĠĠĠ Ġ// ĠThe Ġcoroutine Ġthat Ġdoes Ġthe Ġwork Ġof Ġkeeping Ġtrack Ġof Ġthe Ġrecipes , Ġdoes Ġnot Ġstart Ġuntil Ġstart Recipe Daemon Ġis Ġcalled ĊĠĠĠ Ġ@ Experimental Cor outines Api ĊĠĠĠ Ġprivate Ġval ĠRE CI PE _ DA EM ON Ġ= ĠGlobal Scope . launch ( start Ġ= ĠCor outine Start . LA ZY ) Ġ{ ĊĠĠĠĠĠĠĠ ĠRE CI PE _ CHANNEL . consume Each Ġ{ Ġ( packed Stack , Ġcount ) Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ// ĠDo Ġstuff Ġwith Ġpacked Ġstack ĊĠĠĠĠĠĠĠĠĠĠĠ Ġif Ġ( recipe Graph . contains Vertex ( packed Stack )) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġrecipes Ġ= Ġrecipe Graph . outgoing Edges Of ( packed Stack ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġrecipes . forEach Ġ{ Ġrecipe Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġif Ġ( recipe Item Helper . can Craft ( recipe , Ġnull )) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠCraft able Recipes . add ( recipe ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠDisplay ed Recipe Filter . CHANGED _ RE CI PE _ CHANNEL . send ( recipe Ġto Ġtrue ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ} Ġelse Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠCraft able Recipes . remove ( recipe ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠDisplay ed Recipe Filter . CHANGED _ RE CI PE _ CHANNEL . send ( recipe Ġto Ġfalse ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ// ĠStarts Ġthe Ġbackground Ġrecipe Ġdaemon ĊĠĠĠ Ġ@ Experimental Cor outines Api ĊĠĠĠ Ġfun Ġstart Recipe Daemon () Ġ{ ĊĠĠĠĠĠĠĠ ĠRE CI PE _ DA EM ON . start () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġbuild Recipe Graph () Ġ{ ĊĠĠĠĠĠĠĠ Ġif Ġ(! Recipe Worker :: recipe Graph . isInitialized ) Ġrecipe Graph Ġ= ĠRecipe Graph () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġsuspend Ġfun Ġsend ItemStack ( stack : ĠItemStack ) Ġ{ ĊĠĠĠĠĠĠĠ Ġif Ġ( stack Ġ== ĠItemStack . EMPTY ) Ġreturn ĊĠĠĠĠĠĠĠ Ġrecipe Item Helper . account Set ( stack ) ĊĠĠĠĠĠĠĠ ĠRE CI PE _ CHANNEL . send ( Recipe Item Helper . pack ( stack ) Ġto Ġstack . count ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġsuspend Ġfun Ġsend Packed ItemStack ( stack : ĠInt , Ġcount : ĠInt ) Ġ{ ĊĠĠĠĠĠĠĠ Ġif Ġ( stack Ġ== ĠRecipe Item Helper . pack ( ItemStack . EMPTY )) Ġreturn ĊĠĠĠĠĠĠĠ Ġrecipe Item Helper . set Packed ( stack , Ġcount ) ĊĠĠĠĠĠĠĠ ĠRE CI PE _ CHANNEL . send ( stack Ġto Ġcount ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġclear Recipes () Ġ{ ĊĠĠĠĠĠĠĠ Ġrecipe Item Helper . clear () ĊĠĠĠĠĠĠĠ ĠCraft able Recipes . clear () ĊĠĠĠ Ġ} ĊĊ Ċ }