001 package net.minecraft.util;
002
003 import net.minecraft.entity.Entity;
004 import net.minecraft.entity.EntityLiving;
005 import net.minecraft.entity.player.EntityPlayer;
006
007 public 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 }