@Override public void getIngredients(IIngredients ingredients) { IFabricatorRecipe recipe = getRecipe(); NonNullList<NonNullList<ItemStack>> itemInputs = recipe.getIngredients(); List<List<ItemStack>> inputStacks = new ArrayList<>(); for (List<ItemStack> stacks : itemInputs) { List<ItemStack> copy = new ArrayList<>(); copy.addAll(stacks); inputStacks.add(copy); } ingredients.setInputLists(ItemStack.class, inputStacks); ingredients.setInputs(FluidStack.class, Collections.singletonList(getRecipe().getLiquid())); ingredients.setOutput(ItemStack.class, recipe.getRecipeOutput()); } }
@Nullable public static RecipePair<IFabricatorRecipe> findMatchingRecipe(ItemStack plan, IInventory resources) { ItemStack[][] gridResources = RecipeUtil.getResources(resources); for (IFabricatorRecipe recipe : recipes) { if (!recipe.getPlan().isEmpty() && !ItemStackUtil.isCraftingEquivalent(recipe.getPlan(), plan)) { continue; } String[][] oreDicts = RecipeUtil.matches(recipe.getIngredients(), recipe.getOreDicts(), recipe.getWidth(), recipe.getHeight(), gridResources); if (oreDicts != null) { return new RecipePair<>(recipe, oreDicts); } } return RecipePair.EMPTY; }
@Override protected void onIndexUpdate(int index, IFabricatorRecipe recipe) { selectedElement.add(new TankElement(1, 33, null, () -> new FluidTankInfo(recipe.getLiquid(), 2000), FABRICATOR_TANK_OVERLAY, 16, 16)); NonNullList<NonNullList<ItemStack>> ingredients = recipe.getIngredients(); for (int x = 0; x < 3; x++) { for (int y = 0; y < 3; y++) { int ingredientIndex = y * 3 + x; if (ingredientIndex >= ingredients.size()) { continue; } NonNullList<ItemStack> items = ingredients.get(ingredientIndex); selectedElement.add(new IngredientElement(21 + x * 19, 1 + y * 19, Ingredient.fromStacks(items.toArray(new ItemStack[items.size()])))); } } ItemStack plan = recipe.getPlan(); if (!plan.isEmpty()) { selectedElement.item(91, 1, plan); } selectedElement.item(91, 39, recipe.getRecipeOutput()); NonNullList<ItemStack> smeltingInput = NonNullList.create(); Fluid recipeFluid = recipe.getLiquid().getFluid(); for (IFabricatorSmeltingRecipe s : getSmeltingInputs().get(recipeFluid)) { smeltingInput.add(s.getResource()); } if (!smeltingInput.isEmpty()) { selectedElement.add(new IngredientElement(1, 6, smeltingInput)); } }