package com.ferreusveritas.dynamictrees.systems.dropcreators;

import java.util.List;
import java.util.Random;

import com.ferreusveritas.dynamictrees.ModConfigs;
import com.ferreusveritas.dynamictrees.ModConstants;
import com.ferreusveritas.dynamictrees.api.treedata.IDropCreator;
import com.ferreusveritas.dynamictrees.event.SeedVoluntaryDropEvent;
import com.ferreusveritas.dynamictrees.trees.Species;

import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;

public class DropCreatorSeed implements IDropCreator {

	private final float rarity;
	
	public DropCreatorSeed() {
		this.rarity = 1.0f;
	}
	
	public DropCreatorSeed(float rarity) {
		this.rarity = rarity;
	}
	
	@Override
	public ResourceLocation getName() {
		return new ResourceLocation(ModConstants.MODID, "seed");
	}
	
	@Override
	public List<ItemStack> getHarvestDrop(World world, Species species, BlockPos leafPos, Random random, List<ItemStack> dropList, int soilLife, int fortune) {
		if(random.nextInt(64) == 0) {//1 in 64 chance to drop a seed on destruction..	
			dropList.add(species.getSeedStack(1));
		}
		return dropList;
	}

	@Override
	public List<ItemStack> getVoluntaryDrop(World world, Species species, BlockPos rootPos, Random random, List<ItemStack> dropList, int soilLife) {
		if(rarity * ModConfigs.seedDropRate > random.nextFloat()) {
			dropList.add(species.getSeedStack(1));
			SeedVoluntaryDropEvent seedDropEvent = new SeedVoluntaryDropEvent(world, rootPos, species, dropList);
			MinecraftForge.EVENT_BUS.post(seedDropEvent);
			if(seedDropEvent.isCanceled()) {
				dropList.clear();
			}
		}
		return dropList;
	}

	@Override
	public List<ItemStack> getLeavesDrop(IBlockAccess access, Species species, BlockPos breakPos, Random random, List<ItemStack> dropList, int fortune) {
		int chance = 20; //See BlockLeaves#getSaplingDropChance(state);
		//Hokey fortune stuff here to match Vanilla logic.
		if (fortune > 0) {
			chance -= 2 << fortune;
			if (chance < 10) { 
				chance = 10;
			}
		}
		
		if(random.nextInt(chance) == 0) {
			dropList.add(species.getSeedStack(1));
		}
		
		return dropList;
	}

	@Override
	public List<ItemStack> getLogsDrop(World world, Species species, BlockPos breakPos, Random random, List<ItemStack> dropList, float volume) {
		return dropList;
	}


		
}

@@ -709,13 +709,15 @@
 %0A%09pr
-ivate
+otected
  fin
@@ -773,22 +773,14 @@
 this
-.rarity = 
+(
 1.0f
+)
 ;%0A%09%7D
@@ -847,24 +847,333 @@
 arity;%0A%09%7D%0A%09%0A
+%09//Provided for customization via override%0A%09protected float getHarvestRarity() %7B%0A%09%09return rarity;%0A%09%7D%0A%09%0A%09//Provided for customization via override%0A%09protected float getVoluntaryRarity() %7B%0A%09%09return rarity;%0A%09%7D%0A%09%0A%09//Provided for customization via override%0A%09protected float getLeavesRarity() %7B%0A%09%09return rarity;%0A%09%7D%0A%0A
 %09@Override%0A%09
@@ -1449,31 +1449,59 @@
 %09if(
-random.nextInt(64) == 0
+(1 / 64f) * getHarvestRarity() %3E random.nextFloat()
 ) %7B/
@@ -1780,22 +1780,36 @@
  %7B%0A%09%09if(
-r
+getVoluntaryR
 arity
+()
  * ModCo
@@ -2538,22 +2538,50 @@
 nextInt(
-chance
+(int) (chance / getLeavesRarity())
 ) == 0) 

Make drop creator more useful without affecting compatibility.