package projectzombie.items;

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

public class ItemLantern extends Item
{

	@Override
	public ModelItem getModel(short meta) {
		return Models.ITEM_LANTERN;
	}
	
	@Override
	public double getLightLevel() {
		return 1;
	}
	
	@Override
	public boolean onPlayerRightClick(ItemStack stack, Layer layer, Chunk chunk, EntityPlayer player)
	{
		Vec2i tpos = new Vec2i(MathHelpers.floor(player.getPos().x), MathHelpers.floor(player.getPos().z));
		if(layer.getFrontTile(tpos).tile == Tiles.VOID) {
			layer.setFrontTile(Tiles.LANTERN.getDefaultState(), tpos);
			stack.count -= 1;
			return true;
		}
		
		return false;
	}
	
	@Override
	public String getName(short meta) {
		return "Lantern";
	}

}
