package exnihiloadscensio.registries;

import java.util.ArrayList;
import java.util.HashMap;

import exnihiloadscensio.items.ENItems;
import exnihiloadscensio.items.ItemResource;
import exnihiloadscensio.registries.types.CrookReward;
import exnihiloadscensio.util.BlockInfo;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;

public class CrookRegistry {
	
	private static HashMap<BlockInfo, ArrayList<CrookReward>> map = new HashMap<BlockInfo, ArrayList<CrookReward>>();
	
	public static void addCrookRecipe(IBlockState state, ItemStack reward, float chance, float fortuneChance) {
		BlockInfo info = new BlockInfo(state);
		addCrookRecipe(info, reward, chance, fortuneChance);
	}
	
	public static void addCrookRecipe(BlockInfo info, ItemStack reward, float chance, float fortuneChance) {
		ArrayList<CrookReward> list = map.get(info);
		if (list == null)
		{
			list = new ArrayList<CrookReward>();
		}
		list.add(new CrookReward(reward, chance, fortuneChance));
		map.put(info, list);
	}
	
	public static boolean registered(Block block)
	{
		return map.containsKey(new BlockInfo(block.getDefaultState()));
	}
	
	public static ArrayList<CrookReward> getRewards(IBlockState state)
	{
		BlockInfo info = new BlockInfo(state);
		if (!map.containsKey(info))
			return null;
		
		return map.get(info);
	}
	
	public static void registerDefaults() {
		for (int i = 0 ; i < 16 ; i++)
			addCrookRecipe(new BlockInfo(Blocks.LEAVES, i), ItemResource.getResourceStack(ItemResource.SILKWORM), 0.1f, 0f);
	}

}

@@ -449,18 +449,17 @@
 istry %7B%0A
-%09
 %0A
+
 %09private
@@ -565,18 +565,17 @@
 rd%3E%3E();%0A
-%09
 %0A
+
 %09public 
@@ -770,26 +770,25 @@
 Chance);%0A%09%7D%0A
-%09
 %0A
+
 %09public stat
@@ -1078,26 +1078,25 @@
 , list);%0A%09%7D%0A
-%09
 %0A
+
 %09public stat
@@ -1198,26 +1198,25 @@
 ate()));%0A%09%7D%0A
-%09
 %0A
+
 %09public stat
@@ -1365,11 +1365,9 @@
 ll;%0A
-%09%09
 %0A
+
 %09%09re
@@ -1393,10 +1393,9 @@
 %0A%09%7D%0A
-%09
 %0A
+
 %09pub
@@ -1463,16 +1463,18 @@
 6 ; i++)
+ %7B
 %0A%09%09%09addC
@@ -1582,14 +1582,135 @@
 f, 0f);%0A
+%09%09%09addCrookRecipe(new BlockInfo(Blocks.LEAVES2, i), ItemResource.getResourceStack(ItemResource.SILKWORM), 0.1f, 0f);%0A%09%09%7D%0A
 %09%7D%0A%0A%7D%0A

Add the other vanilla leaves for crooking