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