package projectzombie.items;

import projectzombie.entity.Entity;
import projectzombie.entity.EntityHasInventory;
import projectzombie.entity.player.EntityPlayer;
import projectzombie.inventory.IInventory;
import projectzombie.model.ModelItem;
import projectzombie.util.math.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, Chunk chunk, EntityPlayer player) {
		return false;
	}
	
	public boolean onPlayerRightClick(ItemStack stack, Layer layer, Chunk chunk, EntityPlayer player) {
		return false;
	}
	
	public String getName(short meta) {
		return "";
	}
	
	public double getLightLevel() {
		return 0;
	}
	
	public abstract ModelItem getModel(short meta);
	
	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);
		}
	}
}
