@@ -46,7 +46,7 @@ public boolean supportsRecipe(EmiRecipe recipe) {
4646 public boolean canCraft (EmiRecipe recipe , EmiCraftContext <StockKeeperRequestMenu > context ) {
4747 AbstractContainerScreen <StockKeeperRequestMenu > abstractContainerScreen = context .getScreen ();
4848 if (abstractContainerScreen instanceof StockKeeperRequestScreen screen ) {
49- return enoughIngredients (recipe .getInputs (),screen , context .getAmount (),context .getInventory (),null );
49+ return enoughIngredients (recipe .getOutputs (), recipe . getInputs (),screen , context .getAmount (),context .getInventory (),null );
5050 }
5151 return false ;
5252 }
@@ -56,7 +56,7 @@ public boolean craft(EmiRecipe recipe, EmiCraftContext<StockKeeperRequestMenu> c
5656 AbstractContainerScreen <StockKeeperRequestMenu > abstractContainerScreen = context .getScreen ();
5757 if (abstractContainerScreen instanceof StockKeeperRequestScreen screen ){
5858 List <BigItemStack > stacks = new ArrayList <>();
59- if (!enoughIngredients (recipe .getInputs (),screen , context .getAmount (), context .getInventory (),(ignore ,amount ,stack ) -> {
59+ if (!enoughIngredients (recipe .getOutputs (), recipe . getInputs (),screen , context .getAmount (), context .getInventory (),(ignore , amount , stack ) -> {
6060 if (amount <= 0 || stack == null )
6161 return ;
6262 Optional <BigItemStack > optional = stacks .stream ().filter (bigItemStack -> ItemStack .isSameItemSameComponents (bigItemStack .stack , stack .stack )).findFirst ();
@@ -102,8 +102,19 @@ protected boolean enoughIngredients(int requiredAmount,EmiPlayerInventory player
102102 return requiredAmount == Integer .MAX_VALUE ;
103103 }
104104
105- protected boolean enoughIngredients (List <EmiIngredient > ingredients ,StockKeeperRequestScreen screen ,int craftTimes ,EmiPlayerInventory playerInventory ,@ Nullable TriConsumer <EmiStack ,Long ,@ Nullable BigItemStack > action ){
105+ protected boolean enoughIngredients (List <EmiStack > outputs , List < EmiIngredient > ingredients , StockKeeperRequestScreen screen , int craftTimes , EmiPlayerInventory playerInventory , @ Nullable TriConsumer <EmiStack ,Long ,@ Nullable BigItemStack > action ){
106106 Map <EmiIngredient ,Integer > foundIngredients = new HashMap <>();
107+ if (!outputs .isEmpty ()){
108+ EmiStack output = outputs .getFirst ();
109+ for (List <BigItemStack > items : screen .displayedItems ){
110+ Optional <BigItemStack > optional = items .stream ().filter (bigItemStack -> bigItemStack .stack .is (output .getItemStack ().getItem ())).findFirst ();
111+ if (optional .isPresent ()){
112+ if (action != null )
113+ action .accept (output ,(long )optional .get ().count ,optional .get ());
114+ craftTimes -= optional .get ().count ;
115+ }
116+ }
117+ }
107118 for (EmiIngredient ingredient : ingredients ) {
108119 Optional <Map .Entry <EmiIngredient , Integer >> foundIngredient = foundIngredients .entrySet ().stream ()
109120 .filter (entry -> EmiIngredient .areEqual (ingredient , entry .getKey ()))
0 commit comments