package projectzombie.items;

import gl_engine.vec.Vec2d;
import gl_engine.vec.Vec2i;
import gl_engine.vec.Vec3d;
import projectzombie.entity.Entity;
import projectzombie.entity.EntityHasInventory;
import projectzombie.entity.player.EntityPlayer;
import projectzombie.init.Models;
import projectzombie.inventory.IInventory;
import projectzombie.items.modifier.ItemModifierDamage;
import projectzombie.model.Model;
import projectzombie.model.ModelItem;
import projectzombie.util.ItemStack;
import projectzombie.world.chunk.Chunk;
import projectzombie.world.layer.Layer;

public abstract class Item
{
	public int id;
	public int max = 99;
	
	public boolean onPlayerLeftClick(ItemStack stack, Layer layer, EntityPlayer player, Vec2d place_pos) {
		return false;
	}
	
	public boolean onPlayerRightClick(ItemStack stack, Layer layer, EntityPlayer player, Vec2d place_pos) {
		return false;
	}
	
	public double getLightLevel(ItemStack stack) {
		return 0;
	}
	
	public Model getPlaceModel(ItemStack stack) {
		return null;
	}
	
	public Model getSpawnModel(ItemStack stack) {
		return null;
	}
	
	public abstract ModelItem getModel(ItemStack stack);
	public abstract String getName(ItemStack stack);
	
	public void onPickedUp(ItemStack stack, Layer layer, Chunk chunk, Entity entity)
	{
		// Update the stacks count
		if(stack.isEmpty()) return;
		
		// Does the entity have an inventory
		if(entity instanceof EntityHasInventory)
		{
			// Get the entities inventory
			IInventory entity_i = ((EntityHasInventory) entity).getInventory();
			
			// Add the item to the entities inventory
			entity_i.addItem(stack);
		}
	}
	
	public double getDamage(ItemStack stack)
	{
		ItemModifierDamage damage_modifier = (ItemModifierDamage)stack.getModifier(ItemModifierDamage.class);
		
		if(damage_modifier == null) {
			return 0;
		}
		
		return (double)damage_modifier.getDamage() / (double)damage_modifier.getMaxDamage();
	}
	
	public boolean isEmpty(ItemStack stack) {
		return false;
	}
}
