package common.block.artificial;

import common.block.BlockRotatedPillar;
import common.block.Material;
import common.entity.types.EntityLiving;
import common.item.CheatTab;
import common.model.Model;
import common.model.ModelProvider;
import common.model.ModelRotation;
import common.properties.Property;
import common.util.BlockPos;
import common.util.Facing;
import common.world.State;
import common.world.World;

public class BlockQuartzPillar extends BlockRotatedPillar
{
	private final boolean dark;
	
    public BlockQuartzPillar(boolean dark)
    {
        super(Material.SOLID);
        this.setDefaultState(this.getBaseState().withProperty(AXIS, Facing.Axis.Y));
        this.setTab(CheatTab.BLOCKS);
        this.dark = dark;
    }
    
    public boolean isDark() {
    	return this.dark;
    }

    public State onBlockPlaced(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, EntityLiving placer)
    {
        return this.getState().withProperty(AXIS, facing.getAxis());
    }
    
    public State getStateFromMeta(int meta)
    {
        State state = this.getState();
        switch (meta & 3)
        {
            default:
                state = state.withProperty(AXIS, Facing.Axis.Y);
                break;
            case 1:
                state = state.withProperty(AXIS, Facing.Axis.X);
                break;
            case 2:
                state = state.withProperty(AXIS, Facing.Axis.Z);
                break;
        }
        return state;
    }

    public int getMetaFromState(State state)
    {
        int meta = 0;
        switch (state.getValue(AXIS))
        {
            case X:
                meta = 1;
                break;
            case Z:
                meta = 2;
                break;
        }
        return meta;
    }

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

    public Model getModel(ModelProvider provider, String name, State state) {
    	String prefix = this.dark ? "black_" : "";
		switch(state.getValue(AXIS)) {
	    	case X:
	    		return provider.getModel(prefix + "quartz_block_lines").add().nswe().du(prefix + "quartz_block_lines_top").rotate(ModelRotation.X90_Y90);
	    	case Y:
	    	default:
	    		return provider.getModel(prefix + "quartz_block_lines").add().nswe().du(prefix + "quartz_block_lines_top");
	    	case Z:
	    		return provider.getModel(prefix + "quartz_block_lines").add().nswe().du(prefix + "quartz_block_lines_top").rotate(ModelRotation.X90_Y0);
		}
    }
}
