@@ -440,7 +440,36 @@ public void testItemsCraftDeadBushTagReusable(GameTestHelper helper) {
440440 chestIn .setItem (1 , new ItemStack (Items .SPRUCE_SAPLING , 10 ));
441441
442442 // Add dead bush recipe with reusable shears to crafting interface
443- // Add iron ingot recipe with spaces to furnace
443+ createDeadBushTagReusableRecipe (helper , positions );
444+
445+ // Enable crafting aspect in crafting writer
446+ enableRecipeInWriter (helper , positions .writer (), new ItemStack (Items .DEAD_BUSH , 10 ));
447+
448+ helper .succeedWhen (() -> {
449+ // Check crafting interface state
450+ helper .assertTrue (positions .interfaceStates ().get (0 ).isRecipeSlotValid (0 ), "Recipe in crafting interface is not valid" );
451+
452+ // Check crafting writer state
453+ IPartStateWriter partStateWriter = (IPartStateWriter ) PartHelpers .getPart (PartPos .of (helper .getLevel (), helper .absolutePos (POS ), Direction .NORTH )).getState ();
454+ helper .assertFalse (partStateWriter .isDeactivated (), "Importer is deactivated" );
455+ helper .assertValueEqual (
456+ PartTypes .CRAFTING_WRITER .getBlockState (PartHelpers .getPartContainerChecked (PartPos .of (helper .getLevel (), helper .absolutePos (POS ), Direction .NORTH )), Direction .NORTH ).getValue (IgnoredBlockStatus .STATUS ),
457+ IgnoredBlockStatus .Status .ACTIVE ,
458+ "Block status is incorrect"
459+ );
460+ helper .assertValueEqual (partStateWriter .getActiveAspect (), CraftingAspects .Write .ITEMSTACK_CRAFT , "Active aspect is incorrect" );
461+ helper .assertTrue (partStateWriter .getErrors (CraftingAspects .Write .ITEMSTACK_CRAFT ).isEmpty (), "Active aspect has errors" );
462+
463+ // Check if items have been crafted
464+ helper .assertValueEqual (chestIn .getItem (0 ).getItem (), Items .DEAD_BUSH , "Slot 0 item is incorrect" );
465+ helper .assertValueEqual (chestIn .getItem (0 ).getCount (), 10 , "Slot 0 amount is incorrect" );
466+ helper .assertValueEqual (chestIn .getItem (1 ).getItem (), Items .SHEARS , "Slot 1 item is incorrect" );
467+ helper .assertValueEqual (chestIn .getItem (1 ).getCount (), 1 , "Slot 1 amount is incorrect" );
468+ });
469+ }
470+
471+ protected static void createDeadBushTagReusableRecipe (GameTestHelper helper , GameTestHelpersIntegratedCrafting .NetworkPositions positions ) {
472+ // Add dead bush recipe with reusable shears to crafting interface
444473 Map <IngredientComponent <?, ?>, List <IPrototypedIngredientAlternatives <?, ?>>> recipeIn = Maps .newIdentityHashMap ();
445474 List <IPrototypedIngredientAlternatives <?, ?>> alternatives = Lists .newArrayList ();
446475 Map <IngredientComponent <?, ?>, List <?>> recipeOut = Maps .newIdentityHashMap ();
@@ -454,13 +483,39 @@ public void testItemsCraftDeadBushTagReusable(GameTestHelper helper) {
454483 recipeOut .put (IngredientComponents .ITEMSTACK , Lists .newArrayList (new ItemStack (Items .DEAD_BUSH )));
455484 ItemStack variableRecipe = createVariableForValue (helper .getLevel (), ValueTypes .OBJECT_RECIPE , ValueObjectTypeRecipe .ValueRecipe .of (new RecipeDefinition (recipeIn , inputsReusable , new MixedIngredients (recipeOut ))));
456485 positions .interfaceStates ().get (0 ).getInventoryVariables ().setItem (0 , variableRecipe );
486+ }
487+
488+ @ GameTest (template = TEMPLATE_EMPTY , timeoutTicks = TIMEOUT )
489+ public void testItemsCraftDeadBushTagReusableAsDependency (GameTestHelper helper ) {
490+ GameTestHelpersIntegratedCrafting .NetworkPositions positions = createBasicNetwork (helper , POS , Blocks .CRAFTING_TABLE , Blocks .CRAFTING_TABLE );
491+
492+ // Insert items in interface chest
493+ ChestBlockEntity chestIn = helper .getBlockEntity (POS .east ());
494+ chestIn .setItem (0 , new ItemStack (Items .SHEARS , 1 ));
495+ chestIn .setItem (1 , new ItemStack (Items .SHEARS , 1 ));
496+ chestIn .setItem (2 , new ItemStack (Items .SPRUCE_SAPLING , 64 ));
497+ chestIn .setItem (3 , new ItemStack (Items .SPRUCE_SAPLING , 64 ));
498+ chestIn .setItem (4 , new ItemStack (Items .SPRUCE_SAPLING , 64 ));
499+ chestIn .setItem (5 , new ItemStack (Items .SPRUCE_SAPLING , 64 ));
500+ chestIn .setItem (6 , new ItemStack (Items .SPRUCE_SAPLING , 64 ));
501+
502+ // Add dead bush recipe with reusable shears to crafting interface
503+ createDeadBushTagReusableRecipe (helper , positions );
504+
505+ // Add dead bush to gold recipe
506+ positions .interfaceRecipeAdders ().get (1 ).accept (Triple .of (0 , RecipeType .CRAFTING , ResourceLocation .fromNamespaceAndPath ("integratedcrafting" , "special/dead_bush_to_gold" )));
507+
508+ // Speed up crafting interfaces, to craft once every tick
509+ GameTestHelpersIntegratedCrafting .setCraftingInterfaceUpdateInterval (positions .interfaces ().get (0 ), 1 );
510+ GameTestHelpersIntegratedCrafting .setCraftingInterfaceUpdateInterval (positions .interfaces ().get (1 ), 1 );
457511
458512 // Enable crafting aspect in crafting writer
459- enableRecipeInWriter (helper , positions .writer (), new ItemStack (Items .DEAD_BUSH , 10 ));
513+ enableRecipeInWriter (helper , positions .writer (), new ItemStack (Items .GOLD_INGOT , 64 * 5 ));
460514
461515 helper .succeedWhen (() -> {
462516 // Check crafting interface state
463517 helper .assertTrue (positions .interfaceStates ().get (0 ).isRecipeSlotValid (0 ), "Recipe in crafting interface is not valid" );
518+ helper .assertTrue (positions .interfaceStates ().get (1 ).isRecipeSlotValid (0 ), "Recipe in crafting interface is not valid" );
464519
465520 // Check crafting writer state
466521 IPartStateWriter partStateWriter = (IPartStateWriter ) PartHelpers .getPart (PartPos .of (helper .getLevel (), helper .absolutePos (POS ), Direction .NORTH )).getState ();
@@ -474,10 +529,18 @@ public void testItemsCraftDeadBushTagReusable(GameTestHelper helper) {
474529 helper .assertTrue (partStateWriter .getErrors (CraftingAspects .Write .ITEMSTACK_CRAFT ).isEmpty (), "Active aspect has errors" );
475530
476531 // Check if items have been crafted
477- helper .assertValueEqual (chestIn .getItem (0 ).getItem (), Items .DEAD_BUSH , "Slot 0 item is incorrect" );
478- helper .assertValueEqual (chestIn .getItem (0 ).getCount (), 10 , "Slot 0 amount is incorrect" );
479- helper .assertValueEqual (chestIn .getItem (1 ).getItem (), Items .SHEARS , "Slot 1 item is incorrect" );
480- helper .assertValueEqual (chestIn .getItem (1 ).getCount (), 1 , "Slot 1 amount is incorrect" );
532+ helper .assertValueEqual (chestIn .getItem (0 ).getItem (), Items .GOLD_INGOT , "Slot 0 item is incorrect" );
533+ helper .assertValueEqual (chestIn .getItem (0 ).getCount (), 64 , "Slot 0 amount is incorrect" );
534+ helper .assertValueEqual (chestIn .getItem (1 ).getItem (), Items .GOLD_INGOT , "Slot 1 item is incorrect" );
535+ helper .assertValueEqual (chestIn .getItem (1 ).getCount (), 64 , "Slot 1 amount is incorrect" );
536+ helper .assertValueEqual (chestIn .getItem (2 ).getItem (), Items .GOLD_INGOT , "Slot 2 item is incorrect" );
537+ helper .assertValueEqual (chestIn .getItem (2 ).getCount (), 64 , "Slot 2 amount is incorrect" );
538+ helper .assertValueEqual (chestIn .getItem (3 ).getItem (), Items .GOLD_INGOT , "Slot 3 item is incorrect" );
539+ helper .assertValueEqual (chestIn .getItem (3 ).getCount (), 64 , "Slot 3 amount is incorrect" );
540+ helper .assertValueEqual (chestIn .getItem (4 ).getItem (), Items .GOLD_INGOT , "Slot 4 item is incorrect" );
541+ helper .assertValueEqual (chestIn .getItem (4 ).getCount (), 64 , "Slot 4 amount is incorrect" );
542+ helper .assertValueEqual (chestIn .getItem (6 ).getItem (), Items .SHEARS , "Slot 6 item is incorrect" );
543+ helper .assertValueEqual (chestIn .getItem (6 ).getCount (), 1 , "Slot 6 amount is incorrect" );
481544 });
482545 }
483546
0 commit comments