@Override public void register(IModRegistry registry) { registry.addRecipes(RecipeManager.getInstance().getRecipes(DrinkRecipe.class).stream().map(DrinkRecipeWrapper::new).collect(Collectors.toList()), RecipeUIDs.DRINK); registry.handleRecipes(DrinkRecipeWrapper.class, recipe -> recipe, RecipeUIDs.DRINK); registry.addRecipeClickArea(GuiContainerDrinkMachine.class, 87, 27, 27, 25, RecipeUIDs.DRINK); registry.addRecipeClickArea(GuiContainerSmeltingDrinkMachine.class, 87, 27, 27, 25, RecipeUIDs.DRINK); registry.addRecipeCatalyst(new ItemStack(FCRBlocks.DRINK_MACHINE), RecipeUIDs.DRINK); registry.addRecipeCatalyst(new ItemStack(FCRBlocks.SMELTING_DRINK_MACHINE), RecipeUIDs.DRINK); }
@Override public boolean canStart() { DrinkRecipe recipe = RecipeManager.getInstance().getRecipeNullable(DrinkRecipe.class, new RecipeInput(itemStackHandler.getStackInSlot(0).getItem())); return super.canStart() && recipe != null && tank.getFluidAmount() < TileEntityDrinkMachine.FLUID_CAPACITY; }
@Override public boolean canStart() { DrinkRecipe recipe = RecipeManager.getInstance().getRecipeNullable(DrinkRecipe.class, new RecipeInput(itemStackHandler.getStackInSlot(0).getItem())); return super.canStart() && recipe != null && tank.getFluidAmount() < TileEntityDrinkMachine.FLUID_CAPACITY; }
@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); } }
@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()); } }
VegetableEnumLoader vegetableLoader = FoodCraftReloadedMod.getProxy().getLoaderManager().getLoader(VegetableEnumLoader.class).get(); for (FruitType fruitType : FruitType.values()) { RecipeManager.getInstance().addRecipe(new DrinkRecipe(fruitLoader.getInstanceMap(ItemFruit.class).get(fruitType), new FluidStack(fruitLoader.getInstance(FluidFruitJuice.class, fruitType), 1000))); GameRegistry.addShapedRecipe(new ResourceLocation(FoodCraftReloadedMod.MODID, NameBuilder.buildRegistryName(fruitType.toString(), "sapling")), new ResourceLocation(FoodCraftReloadedMod.MODID, "sapling"), RecipeManager.getInstance().addRecipe( new DrinkRecipe(vegetableLoader.getInstanceMap(ItemVegetable.class).get(vegetableType), new FluidStack(vegetableLoader.getInstance(FluidVegetableJuice.class, vegetableType), 1000))