package common.block.natural;

import common.block.Block;
import common.block.Material;
import common.init.Blocks;
import common.init.Items;
import common.item.CheatTab;
import common.item.Item;
import common.model.Model;
import common.model.ModelProvider;
import common.properties.Property;
import common.properties.PropertyBool;
import common.rng.Random;
import common.util.BlockPos;
import common.world.IWorldAccess;
import common.world.State;

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

	public BlockPodzol() {
		super(Material.LOOSE);
		this.setDefaultState(this.getBaseState().withProperty(SNOWY, Boolean.valueOf(false)));
		this.setTab(CheatTab.NATURE);
	}

	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 int getMetaFromState(State state) {
		return 0;
	}

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

	public Item getItemDropped(State state, Random rand, int fortune) {
		return Items.dirt;
	}

	public Model getModel(ModelProvider provider, String name, State state) {
		return state.getValue(SNOWY) ? provider.getModel("grass_side_snowed").add().nswe().d("dirt").u("grass_top")
				: provider.getModel("dirt_podzol_side").add().nswe().d("dirt").u("dirt_podzol_top");
	}
}
