33import java .util .Optional ;
44import java .util .Set ;
55import java .util .stream .Collectors ;
6+ import com .alcatrazescapee .mcjunitlib .framework .IntegrationTest ;
7+ import com .alcatrazescapee .mcjunitlib .framework .IntegrationTestClass ;
8+ import com .alcatrazescapee .mcjunitlib .framework .IntegrationTestHelper ;
69import com .google .gson .JsonElement ;
710import com .mojang .serialization .JsonOps ;
811import dev .compactmods .crafting .api .field .MiniaturizationFieldSize ;
1114import dev .compactmods .crafting .recipes .layers .FilledComponentRecipeLayer ;
1215import dev .compactmods .crafting .tests .recipes .util .RecipeTestUtil ;
1316import dev .compactmods .crafting .tests .util .FileHelper ;
14- import dev .compactmods .crafting .tests .world .TestBlockReader ;
1517import dev .compactmods .crafting .util .BlockSpaceUtil ;
1618import net .minecraft .util .math .AxisAlignedBB ;
1719import net .minecraft .util .math .BlockPos ;
1820import org .junit .jupiter .api .Assertions ;
1921import org .junit .jupiter .api .Tag ;
2022import org .junit .jupiter .api .Test ;
2123
24+ @ IntegrationTestClass ("layers" )
2225public class FilledLayerTests {
2326
2427 private FilledComponentRecipeLayer getLayerFromFile (String filename ) {
@@ -92,7 +95,6 @@ void CanFetchComponentByPosition() {
9295 });
9396 }
9497
95- @ Test
9698 @ Tag ("minecraft" )
9799 void ReturnsEmptyWhenFetchingOOBPosition () {
98100 final FilledComponentRecipeLayer layer = getLayerFromFile ("layers/filled/basic.json" );
@@ -103,15 +105,13 @@ void ReturnsEmptyWhenFetchingOOBPosition() {
103105 Assertions .assertFalse (componentForPosition .isPresent ());
104106 }
105107
106- @ Test
107108 @ Tag ("minecraft" )
108- void FilledLayerMatchesWorldInExactMatchScenario () {
109- final TestBlockReader reader = RecipeTestUtil . getBlockReader ( "worlds/single_layer_medium_filled_G.json" );
109+ @ IntegrationTest ( "medium_glass_filled" )
110+ void FilledLayerMatchesWorldInExactMatchScenario ( IntegrationTestHelper helper ) {
110111 final MiniaturizationRecipeComponents components = RecipeTestUtil .getComponentsFromRecipeFile ("worlds/single_layer_medium_filled_G.json" );
111112
112- Assertions .assertNotNull (reader );
113-
114- final RecipeLayerBlocks blocks = RecipeLayerBlocks .create (reader , components , BlockSpaceUtil .getLayerBounds (MiniaturizationFieldSize .MEDIUM , 0 ));
113+ final AxisAlignedBB bounds = BlockSpaceUtil .getLayerBounds (MiniaturizationFieldSize .MEDIUM , 0 ).move (helper .relativePos (BlockPos .ZERO ).orElse (BlockPos .ZERO ));
114+ final RecipeLayerBlocks blocks = RecipeLayerBlocks .create (helper .getWorld (), components , bounds );
115115
116116 // Set up a 5x5x1 filled layer, using "G" component
117117 final FilledComponentRecipeLayer layer = new FilledComponentRecipeLayer ("G" );
@@ -121,15 +121,12 @@ void FilledLayerMatchesWorldInExactMatchScenario() {
121121 Assertions .assertTrue (matched );
122122 }
123123
124- @ Test
125124 @ Tag ("minecraft" )
126- void FailsMatchIfAllBlocksNotIdentified () {
127- final TestBlockReader reader = RecipeTestUtil .getBlockReader ("worlds/basic_mixed_medium_iron.json" );
128- final MiniaturizationRecipeComponents components = RecipeTestUtil .getComponentsFromRecipeFile ("worlds/basic_mixed_medium_iron.json" );
129-
130- Assertions .assertNotNull (reader );
125+ @ IntegrationTest ("medium_glass_walls_obsidian_center" )
126+ void FailsMatchIfAllBlocksNotIdentified (IntegrationTestHelper helper ) {
127+ final MiniaturizationRecipeComponents components = RecipeTestUtil .getComponentsFromRecipeFile ("recipes/basic_mixed_medium_iron.json" );
131128
132- final RecipeLayerBlocks blocks = RecipeLayerBlocks .create (reader , components , BlockSpaceUtil .getLayerBounds (MiniaturizationFieldSize .MEDIUM , 0 ));
129+ final RecipeLayerBlocks blocks = RecipeLayerBlocks .create (helper . getWorld () , components , BlockSpaceUtil .getLayerBounds (MiniaturizationFieldSize .MEDIUM , 0 ));
133130
134131 // Set up a 5x5x1 filled layer, using "G" component
135132 final FilledComponentRecipeLayer layer = new FilledComponentRecipeLayer ("G" );
@@ -139,15 +136,12 @@ void FailsMatchIfAllBlocksNotIdentified() {
139136 Assertions .assertFalse (matched );
140137 }
141138
142- @ Test
143139 @ Tag ("minecraft" )
144- void FailsMatchIfMoreThanOneBlockFound () {
145- final TestBlockReader reader = RecipeTestUtil . getBlockReader ( "worlds/basic_harness_allmatched_5x.json" );
140+ @ IntegrationTest ( "medium_glass_walls_obsidian_center" )
141+ void FailsMatchIfMoreThanOneBlockFound ( IntegrationTestHelper helper ) {
146142 final MiniaturizationRecipeComponents components = RecipeTestUtil .getComponentsFromRecipeFile ("worlds/basic_harness_allmatched_5x.json" );
147143
148- Assertions .assertNotNull (reader );
149-
150- final RecipeLayerBlocks blocks = RecipeLayerBlocks .create (reader , components , BlockSpaceUtil .getLayerBounds (MiniaturizationFieldSize .MEDIUM , 0 ));
144+ final RecipeLayerBlocks blocks = RecipeLayerBlocks .create (helper .getWorld (), components , BlockSpaceUtil .getLayerBounds (MiniaturizationFieldSize .MEDIUM , 0 ));
151145
152146 // Set up a 5x5x1 filled layer, using "G" component
153147 final FilledComponentRecipeLayer layer = new FilledComponentRecipeLayer ("G" );
@@ -157,21 +151,19 @@ void FailsMatchIfMoreThanOneBlockFound() {
157151 Assertions .assertFalse (matched );
158152 }
159153
160- @ Test
161154 @ Tag ("minecraft" )
162- void FailsMatchIfComponentKeyNotFound () {
163- final TestBlockReader reader = RecipeTestUtil . getBlockReader ( "worlds/basic_filled_medium_glass_A.json" );
155+ @ IntegrationTest ( "medium_glass_filled" )
156+ void FailsMatchIfComponentKeyNotFound ( IntegrationTestHelper helper ) {
164157 final MiniaturizationRecipeComponents components = RecipeTestUtil .getComponentsFromRecipeFile ("worlds/basic_filled_medium_glass_A.json" );
165158
166- Assertions .assertNotNull (reader );
167-
168- final RecipeLayerBlocks blocks = RecipeLayerBlocks .create (reader , components , BlockSpaceUtil .getLayerBounds (MiniaturizationFieldSize .MEDIUM , 0 ));
159+ final AxisAlignedBB bounds = RecipeTestUtil .getFloorLayerBounds (MiniaturizationFieldSize .MEDIUM , helper );
160+ final RecipeLayerBlocks blocks = RecipeLayerBlocks .create (helper .getWorld (), components , bounds );
169161
170162 // Set up a 5x5x1 filled layer, using "G" component
171163 final FilledComponentRecipeLayer layer = new FilledComponentRecipeLayer ("G" );
172164 layer .setRecipeDimensions (MiniaturizationFieldSize .MEDIUM );
173165
174166 boolean matched = Assertions .assertDoesNotThrow (() -> layer .matches (components , blocks ));
175- Assertions . assertFalse ( matched );
167+ helper . assertTrue (() -> ! matched , "Layer matched despite not having the required component defined." );
176168 }
177169}
0 commit comments