|
2 | 2 |
|
3 | 3 | import gregtech.Bootstrap; |
4 | 4 | import gregtech.api.GTValues; |
| 5 | +import gregtech.api.items.metaitem.MetaItem; |
5 | 6 | import gregtech.api.recipes.builders.SimpleRecipeBuilder; |
6 | 7 | import gregtech.api.recipes.map.AbstractMapIngredient; |
7 | 8 | import gregtech.api.recipes.map.MapFluidIngredient; |
8 | 9 | import gregtech.api.recipes.map.MapItemStackIngredient; |
9 | 10 | import gregtech.api.recipes.map.MapOreDictIngredient; |
10 | 11 | import gregtech.api.unification.material.Materials; |
11 | 12 | import gregtech.api.util.GTUtility; |
| 13 | +import gregtech.common.items.MetaItems; |
| 14 | +import gregtech.loaders.recipe.VanillaStandardRecipes; |
12 | 15 |
|
13 | 16 | import net.minecraft.init.Blocks; |
14 | 17 | import net.minecraft.item.ItemStack; |
|
24 | 27 | import org.junit.jupiter.api.Test; |
25 | 28 |
|
26 | 29 | import java.lang.reflect.Field; |
| 30 | +import java.lang.reflect.InvocationTargetException; |
27 | 31 | import java.lang.reflect.Method; |
28 | 32 | import java.util.Arrays; |
29 | 33 | import java.util.Collection; |
@@ -281,46 +285,38 @@ public void wildcardInput() { |
281 | 285 | } |
282 | 286 |
|
283 | 287 | @Test |
284 | | - public void testInputs() { |
| 288 | + public void testInputs() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { |
| 289 | + for (MetaItem<?> item : MetaItems.ITEMS) { |
| 290 | + item.registerSubItems(); |
| 291 | + } |
| 292 | + |
| 293 | + Method dyingCleaningRecipes = VanillaStandardRecipes.class.getDeclaredMethod("dyingCleaningRecipes"); |
| 294 | + dyingCleaningRecipes.setAccessible(true); |
| 295 | + dyingCleaningRecipes.invoke(null); |
| 296 | + |
285 | 297 | FluidStack dye = Materials.CHEMICAL_DYES[1].getFluid(GTValues.L); |
286 | 298 |
|
287 | | - map.recipeBuilder() |
288 | | - .inputs(new ItemStack(Blocks.WOOL)) |
289 | | - .fluidInputs(GTUtility.copy(dye)) |
290 | | - .outputs(new ItemStack(Blocks.WOOL, 1, 1)) |
291 | | - .duration(1).EUt(1) |
292 | | - .buildAndRegister(); |
| 299 | + Method prepareRecipeFind = RecipeMap.class.getDeclaredMethod("prepareRecipeFind", Collection.class, |
| 300 | + Collection.class); |
| 301 | + prepareRecipeFind.setAccessible(true); |
293 | 302 |
|
294 | | - map.recipeBuilder() |
295 | | - .input(Blocks.WOOL, 1, true) |
296 | | - .fluidInputs(Chlorine.getFluid(50)) |
297 | | - .output(Blocks.WOOL) |
298 | | - .duration(1).EUt(1) |
299 | | - .buildAndRegister(); |
| 303 | + // noinspection unchecked |
| 304 | + List<List<AbstractMapIngredient>> list = (List<List<AbstractMapIngredient>>) prepareRecipeFind.invoke(map, |
| 305 | + Collections.singletonList(new ItemStack(Blocks.WOOL)), |
| 306 | + Collections.singletonList(GTUtility.copy(dye))); |
300 | 307 |
|
301 | | - try { |
302 | | - Method prepareRecipeFind = RecipeMap.class.getDeclaredMethod("prepareRecipeFind", Collection.class, |
303 | | - Collection.class); |
304 | | - prepareRecipeFind.setAccessible(true); |
305 | | - |
306 | | - // noinspection unchecked |
307 | | - List<List<AbstractMapIngredient>> list = (List<List<AbstractMapIngredient>>) prepareRecipeFind.invoke(map, |
308 | | - Collections.singletonList(new ItemStack(Blocks.WOOL)), |
309 | | - Collections.singletonList(GTUtility.copy(dye))); |
310 | | - |
311 | | - // noinspection unchecked |
312 | | - List<List<AbstractMapIngredient>> list2 = (List<List<AbstractMapIngredient>>) prepareRecipeFind.invoke(map, |
313 | | - Collections.singletonList(new ItemStack(Blocks.WOOL)), |
314 | | - Collections.singletonList(Chlorine.getFluid(50))); |
315 | | - |
316 | | - MatcherAssert.assertThat("the first two ingredients are not equal!", |
317 | | - list.get(0).get(0).equals(list2.get(0).get(0))); |
318 | | - } catch (ReflectiveOperationException ignored) {} |
319 | | - |
320 | | - Recipe recipe = map.find( |
321 | | - Collections.singleton(new ItemStack(Blocks.WOOL)), |
322 | | - Collections.singleton(GTUtility.copy(dye)), |
323 | | - r -> true); |
| 308 | + // noinspection unchecked |
| 309 | + List<List<AbstractMapIngredient>> list2 = (List<List<AbstractMapIngredient>>) prepareRecipeFind.invoke(map, |
| 310 | + Collections.singletonList(new ItemStack(Blocks.WOOL)), |
| 311 | + Collections.singletonList(Chlorine.getFluid(50))); |
| 312 | + |
| 313 | + MatcherAssert.assertThat("the first two ingredients are not equal!", |
| 314 | + list.get(0).get(0).equals(list2.get(0).get(0))); |
| 315 | + |
| 316 | + List<ItemStack> wool = Arrays.asList(new ItemStack(Blocks.WOOL)); |
| 317 | + List<FluidStack> fluidDye = Arrays.asList(GTUtility.copy(dye)); |
| 318 | + Recipe recipe = RecipeMaps.CHEMICAL_BATH_RECIPES.find( |
| 319 | + wool, fluidDye, r -> r.matches(false, wool, fluidDye)); |
324 | 320 |
|
325 | 321 | MatcherAssert.assertThat("recipe could not be found!", recipe != null); |
326 | 322 | } |
|
0 commit comments