    001package net.minecraft.util;
    002
    003import net.minecraft.entity.Entity;
    004import net.minecraft.entity.EntityLiving;
    005import net.minecraft.entity.player.EntityPlayer;
    006import net.minecraft.item.ItemStack;
    007
    008public class EntityDamageSource extends DamageSource
    009{
    010    protected Entity damageSourceEntity;
    011
    012    public EntityDamageSource(String par1Str, Entity par2Entity)
    013    {
    014        super(par1Str);
    015        this.damageSourceEntity = par2Entity;
    016    }
    017
    018    public Entity getEntity()
    019    {
    020        return this.damageSourceEntity;
    021    }
    022
    023    /**
    024     * Returns the message to be displayed on player death.
    025     */
    026    public String getDeathMessage(EntityLiving par1EntityLiving)
    027    {
    028        ItemStack itemstack = this.damageSourceEntity instanceof EntityLiving ? ((EntityLiving)this.damageSourceEntity).getHeldItem() : null;
    029        String s = "death.attack." + this.damageType;
    030        String s1 = s + ".item";
    031        return itemstack != null && itemstack.hasDisplayName() && StatCollector.func_94522_b(s1) ? StatCollector.translateToLocalFormatted(s1, new Object[] {par1EntityLiving.func_96090_ax(), this.damageSourceEntity.func_96090_ax(), itemstack.getDisplayName()}): StatCollector.translateToLocalFormatted(s, new Object[] {par1EntityLiving.func_96090_ax(), this.damageSourceEntity.func_96090_ax()});
    032    }
    033
    034    /**
    035     * Return whether this damage source will have its damage amount scaled based on the current difficulty.
    036     */
    037    public boolean isDifficultyScaled()
    038    {
    039        return this.damageSourceEntity != null && this.damageSourceEntity instanceof EntityLiving && !(this.damageSourceEntity instanceof EntityPlayer);
    040    }
    041}