66import java .util .Set ;
77import java .util .stream .Collectors ;
88import java .util .stream .Stream ;
9- import com .alcatrazescapee .mcjunitlib .framework .IntegrationTest ;
10- import com .alcatrazescapee .mcjunitlib .framework .IntegrationTestClass ;
11- import com .alcatrazescapee .mcjunitlib .framework .IntegrationTestHelper ;
129import dev .compactmods .crafting .CompactCrafting ;
1310import dev .compactmods .crafting .api .field .MiniaturizationFieldSize ;
1411import dev .compactmods .crafting .api .recipe .layers .IRecipeBlocks ;
1916import dev .compactmods .crafting .server .ServerConfig ;
2017import dev .compactmods .crafting .tests .recipes .util .RecipeTestUtil ;
2118import dev .compactmods .crafting .util .BlockSpaceUtil ;
22- import net .minecraft .block . BlockState ;
23- import net .minecraft .block . Blocks ;
24- import net .minecraft .item . ItemStack ;
25- import net .minecraft .item . crafting . IRecipeSerializer ;
26- import net .minecraft .item .crafting . IRecipeType ;
27- import net .minecraft .item .crafting .RecipeManager ;
28- import net .minecraft .util . ResourceLocation ;
29- import net .minecraft .util . math . BlockPos ;
30- import net .minecraftforge .fml . server .ServerLifecycleHooks ;
19+ import net .minecraft .core . BlockPos ;
20+ import net .minecraft .gametest . framework . GameTest ;
21+ import net .minecraft .gametest . framework . GameTestHelper ;
22+ import net .minecraft .resources . ResourceLocation ;
23+ import net .minecraft .world . item .ItemStack ;
24+ import net .minecraft .world . item .crafting .RecipeManager ;
25+ import net .minecraft .world . level . block . Blocks ;
26+ import net .minecraft .world . level . block . state . BlockState ;
27+ import net .minecraftforge .server .ServerLifecycleHooks ;
3128import org .junit .jupiter .api .Assertions ;
32- import org .junit .jupiter .api .Tag ;
3329import org .junit .jupiter .api .Test ;
3430
3531// @MCTestClass
36- @ IntegrationTestClass ("recipes" )
37- public class MiniaturizationRecipeTests {
32+ public class MiniaturizationRecipes {
3833
3934 private static RecipeManager RECIPES ;
4035
41- @ Tag ("minecraft" )
4236 @ org .junit .jupiter .api .BeforeAll
4337 static void BeforeAllTests () {
4438 ServerConfig .RECIPE_REGISTRATION .set (true );
@@ -49,19 +43,17 @@ static void BeforeAllTests() {
4943 }
5044
5145 @ Nullable
52- private MiniaturizationRecipe getRecipe (String name ) {
46+ private static MiniaturizationRecipe getRecipe (String name ) {
5347 return (MiniaturizationRecipe ) RECIPES .byKey (new ResourceLocation ("compactcrafting" , name )).orElse (null );
5448 }
5549
5650 @ Test
57- @ Tag ("minecraft" )
5851 void CanCreate () {
5952 MiniaturizationRecipe recipe = new MiniaturizationRecipe ();
6053 Assertions .assertNotNull (recipe );
6154 }
6255
6356 @ Test
64- @ Tag ("minecraft" )
6557 void CanSetId () {
6658 MiniaturizationRecipe recipe = new MiniaturizationRecipe ();
6759 Assertions .assertNotNull (recipe );
@@ -73,28 +65,26 @@ void CanSetId() {
7365
7466
7567 @ Test
76- @ Tag ("minecraft" )
7768 void IsSpecialRecipe () {
7869 MiniaturizationRecipe recipe = new MiniaturizationRecipe ();
7970 Assertions .assertNotNull (recipe );
8071 Assertions .assertTrue (recipe .isSpecial ());
8172 }
8273
83- @ Tag ( "minecraft" )
74+
8475 // @StructureFile("ender_crystal")
85- @ IntegrationTest ( " ender_crystal" )
86- void FakesFakeInventories (IntegrationTestHelper helper ) {
76+ @ GameTest ( template = "recipes/ ender_crystal", templateNamespace = CompactCrafting . MOD_ID )
77+ public static void FakesFakeInventories (final GameTestHelper helper ) {
8778 MiniaturizationRecipe recipe = new MiniaturizationRecipe ();
8879 Assertions .assertNotNull (recipe );
8980
9081 Assertions .assertDoesNotThrow (() -> {
91- boolean matched = recipe .matches (new FakeInventory (), helper .getWorld ());
82+ boolean matched = recipe .matches (new FakeInventory (), helper .getLevel ());
9283 Assertions .assertTrue (matched );
9384 });
9485 }
9586
9687 @ Test
97- @ Tag ("minecraft" )
9888 void FakesAssemble () {
9989 MiniaturizationRecipe recipe = new MiniaturizationRecipe ();
10090 Assertions .assertNotNull (recipe );
@@ -106,7 +96,6 @@ void FakesAssemble() {
10696 }
10797
10898 @ Test
109- @ Tag ("minecraft" )
11099 void FakesCanCraftDimensions () {
111100 MiniaturizationRecipe recipe = new MiniaturizationRecipe ();
112101 Assertions .assertNotNull (recipe );
@@ -118,7 +107,6 @@ void FakesCanCraftDimensions() {
118107 }
119108
120109 @ Test
121- @ Tag ("minecraft" )
122110 void FakesResultItem () {
123111 MiniaturizationRecipe recipe = new MiniaturizationRecipe ();
124112 Assertions .assertNotNull (recipe );
@@ -130,22 +118,19 @@ void FakesResultItem() {
130118 }
131119
132120 @ Test
133- @ Tag ("minecraft" )
134121 void RecipeSuppliesBasicMinecraftRegistrationInfo () {
135122 final MiniaturizationRecipe enderCrystal = getRecipe ("ender_crystal" );
136123 Assertions .assertNotNull (enderCrystal );
137124
138- final IRecipeSerializer <?> serializer = Assertions .assertDoesNotThrow (enderCrystal ::getSerializer );
125+ final var serializer = Assertions .assertDoesNotThrow (enderCrystal ::getSerializer );
139126 Assertions .assertNotNull (serializer );
140127
141- final IRecipeType <?> type = Assertions .assertDoesNotThrow (enderCrystal ::getType );
128+ final var type = Assertions .assertDoesNotThrow (enderCrystal ::getType );
142129 Assertions .assertNotNull (type );
143130 }
144131
145132
146-
147133 @ Test
148- @ Tag ("minecraft" )
149134 void RecipeReturnsEmptyIfLayerNotRegistered () {
150135 final MiniaturizationRecipe enderCrystal = getRecipe ("ender_crystal" );
151136 Assertions .assertNotNull (enderCrystal );
@@ -155,7 +140,6 @@ void RecipeReturnsEmptyIfLayerNotRegistered() {
155140 }
156141
157142 @ Test
158- @ Tag ("minecraft" )
159143 void FitsInCorrectFieldSizes () {
160144 final MiniaturizationRecipe enderCrystal = getRecipe ("ender_crystal" );
161145 Assertions .assertNotNull (enderCrystal );
@@ -176,7 +160,6 @@ void FitsInCorrectFieldSizes() {
176160 }
177161
178162 @ Test
179- @ Tag ("minecraft" )
180163 void CanGetComponentTotals () {
181164 final MiniaturizationRecipe recipe = getRecipe ("ender_crystal" );
182165 Assertions .assertNotNull (recipe );
@@ -196,7 +179,6 @@ void CanGetComponentTotals() {
196179 }
197180
198181 @ Test
199- @ Tag ("minecraft" )
200182 void UnregisteredBlockReturnsZeroCount () {
201183 final MiniaturizationRecipe recipe = getRecipe ("ender_crystal" );
202184 Assertions .assertNotNull (recipe );
@@ -206,7 +188,6 @@ void UnregisteredBlockReturnsZeroCount() {
206188 }
207189
208190 @ Test
209- @ Tag ("minecraft" )
210191 void HasCraftingTime () {
211192 final MiniaturizationRecipe recipe = getRecipe ("ender_crystal" );
212193 Assertions .assertNotNull (recipe );
@@ -215,13 +196,13 @@ void HasCraftingTime() {
215196 Assertions .assertNotEquals (0 , required );
216197 }
217198
218- @ Tag ( "minecraft" )
219- @ IntegrationTest ( " ender_crystal" )
220- void MatchesExactStructure (IntegrationTestHelper helper ) {
221- final BlockPos zero = helper .relativePos (BlockPos .ZERO ). get () ;
199+
200+ @ GameTest ( template = "recipes/ ender_crystal", templateNamespace = CompactCrafting . MOD_ID )
201+ public static void MatchesExactStructure (final GameTestHelper helper ) {
202+ final BlockPos zero = helper .relativePos (BlockPos .ZERO );
222203 final MiniaturizationRecipe enderCrystal = getRecipe ("ender_crystal" );
223204 final IRecipeBlocks blocks = RecipeBlocks
224- .create (helper .getWorld (), enderCrystal .getComponents (), enderCrystal .getDimensions ().move (zero ))
205+ .create (helper .getLevel (), enderCrystal .getComponents (), enderCrystal .getDimensions ().move (zero ))
225206 .normalize ();
226207
227208 Assertions .assertDoesNotThrow (() -> {
@@ -230,17 +211,17 @@ void MatchesExactStructure(IntegrationTestHelper helper) {
230211 });
231212 }
232213
233- @ Tag ( "minecraft" )
234- @ IntegrationTest ( " ender_crystal" )
235- void RecipeFailsIfUnidentifiedBlock (IntegrationTestHelper helper ) {
214+
215+ @ GameTest ( template = "recipes/ ender_crystal", templateNamespace = CompactCrafting . MOD_ID )
216+ public static void RecipeFailsIfUnidentifiedBlock (final GameTestHelper helper ) {
236217 final MiniaturizationRecipe enderCrystal = getRecipe ("ender_crystal" );
237218 Assertions .assertNotNull (enderCrystal );
238219
239220 // Force an unknown component in the exact center
240- helper .setBlockState (new BlockPos (2 , 2 , 2 ), Blocks .GOLD_BLOCK .defaultBlockState ());
221+ helper .setBlock (new BlockPos (2 , 2 , 2 ), Blocks .GOLD_BLOCK .defaultBlockState ());
241222
242223 final IRecipeBlocks blocks = RecipeBlocks
243- .create (helper .getWorld (), enderCrystal .getComponents (), RecipeTestUtil .getFieldBounds (MiniaturizationFieldSize .MEDIUM , helper ))
224+ .create (helper .getLevel (), enderCrystal .getComponents (), RecipeTestUtil .getFieldBounds (MiniaturizationFieldSize .MEDIUM , helper ))
244225 .normalize ();
245226
246227 Assertions .assertDoesNotThrow (() -> {
@@ -250,7 +231,6 @@ void RecipeFailsIfUnidentifiedBlock(IntegrationTestHelper helper) {
250231 }
251232
252233 @ Test
253- @ Tag ("minecraft" )
254234 void CanStreamLayerInfo () {
255235 final MiniaturizationRecipe enderCrystal = getRecipe ("ender_crystal" );
256236 final Stream <IRecipeLayer > strem = Assertions .assertDoesNotThrow (enderCrystal ::getLayers );
@@ -261,32 +241,31 @@ void CanStreamLayerInfo() {
261241 Assertions .assertEquals (5 , layers .size ());
262242 }
263243
264- @ Tag ("minecraft" )
265- @ IntegrationTest ("ender_crystal" )
266- void RecipeFailsIfDifferentDimensions (IntegrationTestHelper helper ) {
244+ @ GameTest (template = "recipes/ender_crystal" , templateNamespace = CompactCrafting .MOD_ID )
245+ public static void RecipeFailsIfDifferentDimensions (final GameTestHelper helper ) {
267246 final MiniaturizationRecipe recipe = getRecipe ("compact_walls" );
268247 Assertions .assertNotNull (recipe );
269248
270249 final IRecipeBlocks blocks = RecipeBlocks
271- .create (helper .getWorld (), recipe .getComponents (), RecipeTestUtil .getFieldBounds (MiniaturizationFieldSize .MEDIUM , helper ))
250+ .create (helper .getLevel (), recipe .getComponents (), RecipeTestUtil .getFieldBounds (MiniaturizationFieldSize .MEDIUM , helper ))
272251 .normalize ();
273252
274253 final boolean matched = Assertions .assertDoesNotThrow (() -> recipe .matches (blocks ));
275254 Assertions .assertFalse (matched , "Recipe matched even though dimensions are different." );
276255 }
277256
278- @ Tag ( "minecraft" )
279- @ IntegrationTest ( " empty_medium" )
280- void RecipeFailsIfNoRotationsMatched (IntegrationTestHelper helper ) {
257+
258+ @ GameTest ( template = "recipes/ empty_medium", templateNamespace = CompactCrafting . MOD_ID )
259+ public static void RecipeFailsIfNoRotationsMatched (final GameTestHelper helper ) {
281260 final MiniaturizationRecipe recipe = getRecipe ("ender_crystal" );
282261 Assertions .assertNotNull (recipe );
283262
284263 // Set up the 8 corners to be glass, so block creation below matches field boundaries
285264 final BlockState glass = Blocks .GLASS .defaultBlockState ();
286- BlockSpaceUtil .getCornersOfBounds (MiniaturizationFieldSize .MEDIUM ).forEach (p -> helper .setBlockState (p , glass ));
265+ BlockSpaceUtil .getCornersOfBounds (MiniaturizationFieldSize .MEDIUM ).forEach (p -> helper .setBlock (p , glass ));
287266
288267 final IRecipeBlocks blocks = RecipeBlocks
289- .create (helper .getWorld (), recipe .getComponents (), RecipeTestUtil .getFieldBounds (MiniaturizationFieldSize .MEDIUM , helper ))
268+ .create (helper .getLevel (), recipe .getComponents (), RecipeTestUtil .getFieldBounds (MiniaturizationFieldSize .MEDIUM , helper ))
290269 .normalize ();
291270
292271 final boolean matched = Assertions .assertDoesNotThrow (() -> recipe .matches (blocks ));
0 commit comments