package projectzombie.items;

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

public class ItemAcorn extends Item
{

	@Override
	public ModelItem getModel(short meta) {
		return Models.ITEM_ACORN;
	}
	
	@Override
	public String getName(short meta) {
		return "Acorn";
	}
	
	@Override
	public boolean onPlayerRightClick(ItemStack stack, Layer layer, Chunk chunk, EntityPlayer player) {
		
		Vec2i tpos = player.getPos().xz().toInt();
		Tile bt = chunk.getBackTile(tpos).tile;
		
		if((bt == Tiles.GRASS || bt == Tiles.SNOW) && chunk.getFrontTile(tpos).tile == Tiles.VOID) {
			chunk.setFrontTile(Tiles.SAPLING.getDefaultState(), tpos);
			stack.count -= 1;
			return true;
		}
		
		return false;
	}

}
