@Override public void startProgress() { DrinkRecipe recipe = RecipeManager.getInstance().getRecipeNullable(DrinkRecipe.class, new RecipeInput(itemStackHandler.getStackInSlot(0).getItem())); if (recipe != null) { FoodCraftReloaded.getLogger().debug("Smelting drink machine: Found recipe " + recipe.getOutput().<FluidStack>first().getFluid().getName()); fluidOutput = recipe.getOutput().first(); output = recipe.getOutput().second(); itemStackHandler.getStackInSlot(0).setCount(itemStackHandler.getStackInSlot(0).getCount() - 1); } }
@Override public void startProgress() { DrinkRecipe recipe = RecipeManager.getInstance().getRecipeNullable(DrinkRecipe.class, new RecipeInput(itemStackHandler.getStackInSlot(0).getItem())); if (recipe != null) { FoodCraftReloaded.getLogger().debug("Smelting drink machine: Found recipe " + recipe.getOutput().<FluidStack>first().getFluid().getName()); fluidOutput = recipe.getOutput().first(); output = recipe.getOutput().second(); itemStackHandler.getStackInSlot(0).setCount(itemStackHandler.getStackInSlot(0).getCount() - 1); } }
@Override public void getIngredients(@Nonnull IIngredients ingredients) { ingredients.setInput(ItemStack.class, new ItemStack(getRecipe().getInput().<Item>first())); ingredients.setOutput(FluidStack.class, getRecipe().getOutput().first()); ingredients.setOutput(ItemStack.class, getRecipe().getOutput().second()); } }
@Test public void testRecipeIngredients() { // Add null -> null recipe RecipeManager.getInstance().addRecipe(new DrinkRecipe(null, null)); // Should be null recipe DrinkRecipe recipe = RecipeManager.getInstance().getRecipeNullable(DrinkRecipe.class, new RecipeInput((Item)null)); // Should be presented Assert.assertNotNull(recipe); // Null input Assert.assertNull(recipe.getInput().first()); // Null output Assert.assertNull(recipe.getOutput().first()); } }