package common.entity;

import common.color.TextColor;
import common.entity.types.EntityLiving;
import common.item.ItemStack;

public class EntityDamageSourceIndirect extends EntityDamageSource
{
    private Entity indirectEntity;

    public EntityDamageSourceIndirect(TextColor color, String display, String item, String kill, String killItem, Entity source, Entity indirectEntityIn)
    {
        super(color, display, item, kill, killItem, source);
        this.indirectEntity = indirectEntityIn;
    }

    public EntityDamageSourceIndirect(TextColor color, String display, Entity source)
    {
        this(color, display, display, "", "", source, source);
    }

    public Entity getSourceOfDamage()
    {
        return this.damageSourceEntity;
    }

    public Entity getEntity()
    {
        return this.indirectEntity;
    }

    /**
     * Gets the death message that is displayed when the player dies
     *  
     * @param victim The EntityLivingBase that died
     */
    public String getDeathMessage(EntityLiving victim)
    {
    	String killer = this.indirectEntity == null ? this.damageSourceEntity.getColoredName(this.color) : this.indirectEntity.getColoredName(this.color);
        ItemStack item = this.indirectEntity instanceof EntityLiving ? ((EntityLiving)this.indirectEntity).getHeldItem() : null;
//        String s = "death.attack." + this.damageType;
//        String s1 = s + "Item";
        return item != null ? String.format(this.displayExtra, victim.getColoredName(this.color), killer, item.getColoredName(this.color)) : String.format(this.display, victim.getColoredName(this.color), killer);
    }
}
