package com.ferreusveritas.dynamictrees;

import com.ferreusveritas.dynamictrees.trees.DynamicTree;

import net.minecraft.block.BlockSapling;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.registries.IForgeRegistry;

public class ModRecipes {

	@SubscribeEvent(priority = EventPriority.LOWEST)
	public static void registerRecipes(IForgeRegistry<IRecipe> registry) {

		ModItems.dendroPotion.registerRecipes(registry);
		ModItems.dirtBucket.registerRecipes(registry);
		
		for(DynamicTree tree: ModTrees.baseTrees) {

			IBlockState primitiveSapling = tree.getPrimitiveSaplingBlockState();

			if(primitiveSapling != null) {
				ItemStack saplingStack = new ItemStack(primitiveSapling.getBlock());
				saplingStack.setItemDamage(primitiveSapling.getValue(BlockSapling.TYPE).getMetadata());

				ItemStack seedStack = tree.getCommonSpecies().getSeedStack(1);
				
				//Create a seed from a sapling and dirt bucket
				GameRegistry.addShapelessRecipe(
					new ResourceLocation(ModConstants.MODID, tree.getName().getResourcePath() + "seed"),
					null,
					seedStack,
					new Ingredient[]{
						Ingredient.fromStacks(saplingStack),
						Ingredient.fromItem(ModItems.dirtBucket)
					}
				);

				//Creates a vanilla sapling from a seed and dirt bucket
				GameRegistry.addShapelessRecipe(
					new ResourceLocation(ModConstants.MODID, tree.getName().getResourcePath() + "sapling"),
					null,
					saplingStack,
					new Ingredient[]{
						Ingredient.fromStacks(seedStack),
						Ingredient.fromItem(ModItems.dirtBucket)
					}
				);

				//Register the seed in the ore dictionary as a sapling since we can convert for free anyway.
				OreDictionary.registerOre("treeSapling", seedStack);
			}

		}

		DynamicTrees.compatProxy.registerRecipes(registry);
	}
	
}

@@ -92,16 +92,70 @@
 micTree;
+%0Aimport com.ferreusveritas.dynamictrees.trees.Species;
 %0A%0Aimport
@@ -235,16 +235,49 @@
 kState;%0A
+import net.minecraft.init.Items;%0A
 import n
@@ -2221,16 +2221,406 @@
 %09%7D%0A%0A%09%09%7D%0A
+%09%09%0A%09%09//Create an apple seed from an apple and dirt bucket%0A%09%09GameRegistry.addShapelessRecipe(%0A%09%09%09new ResourceLocation(ModConstants.MODID, %22appleseed%22),%0A%09%09%09null,%0A%09%09%09Species.REGISTRY.getValue(new ResourceLocation(ModConstants.MODID, %22apple%22)).getSeedStack(1),%0A%09%09%09new Ingredient%5B%5D%7B%0A%09%09%09%09Ingredient.fromStacks(new ItemStack(Items.APPLE)),%0A%09%09%09%09Ingredient.fromItem(ModItems.dirtBucket)%0A%09%09%09%7D%0A%09%09);%0A%09%09
 %0A%09%09Dynam

Add apple pip recipe