package common.block;

import java.util.List;

import common.item.CheatTab;
import common.item.Item;
import common.item.ItemStack;
import common.material.Material;
import common.model.Model;
import common.model.ModelProvider;
import common.properties.IProperty;
import common.properties.PropertyBool;
import common.world.State;

public class BlockRock extends Block {
	public static final PropertyBool SMOOTH = PropertyBool.create("smooth");

	public BlockRock() {
		super(Material.rock);
		this.setDefaultState(this.getBaseState().withProperty(SMOOTH, false));
		this.setTab(CheatTab.tabNature);
	}

	public int damageDropped(State state) {
		return state.getValue(SMOOTH) ? 1 : 0;
	}

	public void getSubBlocks(Item itemIn, CheatTab tab, List<ItemStack> list) {
		list.add(new ItemStack(itemIn, 1, 0));
		list.add(new ItemStack(itemIn, 1, 1));
	}

	public State getStateFromMeta(int meta) {
		return this.getState().withProperty(SMOOTH, (meta & 1) != 0);
	}

	public int getMetaFromState(State state) {
		return state.getValue(SMOOTH) ? 1 : 0;
	}

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

    public Model getModel(ModelProvider provider, String name, State state) {
    	return provider.getModel(state.getValue(SMOOTH) ? "smooth_rock" : "rock").add().all();
    }
}
