package projectzombie.items;

import gl_engine.vec.Vec2d;
import gl_engine.vec.Vec2i;
import gl_engine.vec.Vec3d;
import projectzombie.entity.player.EntityPlayer;
import projectzombie.init.Items;
import projectzombie.init.Models;
import projectzombie.init.Tiles;
import projectzombie.model.Model;
import projectzombie.model.ModelItem;
import projectzombie.tiles.Tile;
import projectzombie.util.ItemStack;
import projectzombie.world.chunk.Chunk;
import projectzombie.world.layer.Layer;

public class ItemAcorn extends Item implements ItemBurnable
{

	@Override
	public ModelItem getModel(ItemStack stack) {
		return Models.ITEM_ACORN;
	}
	
	@Override
	public String getName(ItemStack stack) {
		return "Acorn";
	}
	
	@Override
	public Model getPlaceModel(ItemStack stack) {
		return Models.TILE_SAPLING_1;
	}
	
	@Override
	public boolean onPlayerRightClick(ItemStack stack, Layer layer, EntityPlayer player, Vec2d place_pos)
	{
		Vec2i pos = place_pos.toInt();
		Tile bt = layer.getBackTile(pos).tile;
		
		if((bt == Tiles.GRASS || bt == Tiles.SNOW) && layer.getFrontTile(pos).tile == Tiles.VOID) {
			layer.setFrontTile(Tiles.SAPLING.getDefaultState(), pos);
			stack.count -= 1;
			return true;
		}
		
		return false;
	}

	@Override
	public int getBurnTime(ItemStack stack) {
		return 800;
	}

	@Override
	public ItemStack[] getBurnProducts(ItemStack stack) {
		return new ItemStack[] {
				 new ItemStack(Items.ASH, 1),
		};
	}

}
