package common.block;

import common.init.Blocks;
import common.item.CheatTab;
import common.item.Item;
import common.material.Material;
import common.model.Model;
import common.model.ModelProvider;
import common.properties.IProperty;
import common.properties.PropertyBool;
import common.rng.Random;
import common.util.BlockPos;
import common.world.IWorldAccess;
import common.world.State;

public class BlockTianSoil extends Block
{
    public static final PropertyBool SNOWY = PropertyBool.create("snowy");

    public BlockTianSoil()
    {
        super(Material.rock);
        this.setDefaultState(this.getBaseState().withProperty(SNOWY, Boolean.valueOf(false)));
        this.setTab(CheatTab.tabNature);
    }
    
    public State getActualState(State state, IWorldAccess worldIn, BlockPos pos)
    {
        Block block = worldIn.getState(pos.up()).getBlock();
        return state.withProperty(SNOWY, Boolean.valueOf(block == Blocks.snow || block == Blocks.snow_layer));
    }
    
    public Item getItemDropped(State state, Random rand, int fortune)
    {
        return Blocks.tian.getItemDropped(Blocks.tian.getState(), rand, fortune);
    }

    public int getMetaFromState(State state)
    {
        return 0;
    }

    protected IProperty[] getProperties()
    {
        return new IProperty[] {SNOWY};
    }

    public Model getModel(ModelProvider provider, String name, State state) {
    	if(state.getValue(SNOWY))
    		return provider.getModel("tian_soil_side_snowed").add().nswe().d("tian").u("grass_top");
    	else
    		return provider.getModel("tian_soil_side").add().nswe().d("tian").u("tian_soil_top");
    }
}
