package common.block.foliage;

import common.init.Blocks;
import common.init.Items;
import common.item.Item;
import common.item.ItemStack;
import common.item.block.ItemSeedFood;
import common.model.Model;
import common.model.ModelProvider;
import common.util.BlockPos;
import common.world.State;
import common.world.World;

public class BlockPotato extends BlockCrops
{
    protected Item getSeed()
    {
        return Items.potato;
    }

    protected Item getCrop()
    {
        return Items.potato;
    }

    /**
     * Spawns this Block's drops into the World as EntityItems.
     */
    public void dropBlockAsItemWithChance(World worldIn, BlockPos pos, State state, float chance, int fortune)
    {
        super.dropBlockAsItemWithChance(worldIn, pos, state, chance, fortune);

        if (!worldIn.client)
        {
            if (((Integer)state.getValue(AGE)).intValue() >= 7 && worldIn.rand.chance(50))
            {
                spawnAsEntity(worldIn, pos, new ItemStack(Items.poisonous_potato));
            }
        }
    }
    
    public Model getModel(ModelProvider provider, String name, State state) {
    	int age = state.getValue(AGE);
    	return crop(provider, name + "_" + (age == 6 ? 2 : (age / 2)));
    }
	
	protected Item getItemToRegister() {
		return new ItemSeedFood(1, this, Blocks.farmland).setDisplay("Kartoffel").setMaxAmount(128);
	}
}
