public AbstractRecipe(Object[] input, Object... output) { this.input = new RecipeInput(input); this.output = new RecipeOutput(output); }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; AbstractRecipe that = (AbstractRecipe) o; if (input != null ? !input.equals(that.input) : that.input != null) return false; return output != null ? output.equals(that.output) : that.output == null; }
@Override public int hashCode() { int result = input != null ? input.hashCode() : 0; result = 31 * result + (output != null ? output.hashCode() : 0); return result; } }
@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); } }
@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()); } }
public DrinkRecipe(Item input, FluidStack output) { super(new Item[]{input}, output); getOutput().setValue(output, ItemStack.EMPTY); } }
@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()); } }