package projectzombie.tiles;

import projectzombie.init.Items;
import projectzombie.init.Models;
import projectzombie.items.ItemTool;
import projectzombie.items.ItemToolType;
import projectzombie.items.modifier.ItemModifierMeta;
import projectzombie.model.Model;
import projectzombie.util.ItemStack;
import projectzombie.util.TileState;

public class TileTree extends Tile implements TileBulletBreakable
{
	public TileTree() {
		
		// Set some settings
		this.tileSolid = true;
		this.tileHitbox = 0.3;
		this.hardness = 500;
	}
	
	@Override
	public boolean canTileBreak(TileState state, ItemStack stack, ItemTool tool) {
		return (tool != null && tool.toolType(stack) == ItemToolType.HATCHET);
	}
	
	@Override
	public boolean canTileSpeedBreak(TileState state, ItemStack stack, ItemTool tool) {
		return canTileBreak(state, stack, tool);
	}
	
	@Override
	public ItemStack[] getTileDrops(TileState state)
	{
		return new ItemStack[] {
				new ItemStack(Items.ACORN, (int)(Math.random() * 3) + 1),
				new ItemStack(Items.LOG, (int)(Math.random() * 4) + 2, new ItemModifierMeta(state.meta)),
		};
	}
	
	@Override
	public double getLightDissipation(TileState state) {
		return 1/8.0;
	}
	
	@Override
	public int getBulletBreakChance() {
		return 35;
	}

	@Override
	public Model getModel(byte meta)
	{
		switch(meta)
		{
		case 1: return Models.TILE_TREE_SNOW;
		default: return Models.TILE_TREE;
		}
	}
	
}
