EntityDamageSource .java

net.minecraft.util.EntityDamageSource (class, 63 lines): members: damageSourceEntity, getIsThornsDamage, setIsThornsDamage, isThornsDamage, getEntity.

net.minecraft.utilclass63 linescommonextends DamageSource2.2 KB

API Surface (5)

EntityDamageSource setIsThornsDamage()
boolean getIsThornsDamage()
Entity getEntity()
IChatComponent getDeathMessage(EntityLivingBase entityLivingBaseIn)
boolean isDifficultyScaled()

Fields & Constants (2)

damageSourceEntity
isThornsDamage

String literals (2)

"death.attack."
".item"

Code Graph: Dependencies (7)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

EntityDamageSource.java63 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.util;
2
3
import net.minecraft.entity.Entity;
4
import net.minecraft.entity.EntityLivingBase;
5
import net.minecraft.entity.player.EntityPlayer;
6
import net.minecraft.item.ItemStack;
7
8
public class EntityDamageSource extends DamageSource
9
{
10
    protected Entity damageSourceEntity;
11
12
    /**
13
     * Whether this EntityDamageSource is from an entity wearing Thorns-enchanted armor.
14
     */
15
    private boolean isThornsDamage = false;
16
17
    public EntityDamageSource(String damageTypeIn, Entity damageSourceEntityIn)
18
    {
19
        super(damageTypeIn);
20
        this.damageSourceEntity = damageSourceEntityIn;
21
    }
22
23
    /**
24
     * Sets this EntityDamageSource as originating from Thorns armor
25
     */
26
    public EntityDamageSource setIsThornsDamage()
27
    {
28
        this.isThornsDamage = true;
29
        return this;
30
    }
31
32
    public boolean getIsThornsDamage()
33
    {
34
        return this.isThornsDamage;
35
    }
36
37
    public Entity getEntity()
38
    {
39
        return this.damageSourceEntity;
40
    }
41
42
    /**
43
     * Gets the death message that is displayed when the player dies
44
     *  
45
     * @param entityLivingBaseIn The EntityLivingBase that died
46
     */
47
    public IChatComponent getDeathMessage(EntityLivingBase entityLivingBaseIn)
48
    {
49
        ItemStack itemstack = this.damageSourceEntity instanceof EntityLivingBase ? ((EntityLivingBase)this.damageSourceEntity).getHeldItem() : null;
50
        String s = "death.attack." + this.damageType;
51
        String s1 = s + ".item";
52
        return itemstack != null && itemstack.hasDisplayName() && StatCollector.canTranslate(s1) ? new ChatComponentTranslation(s1, new Object[] {entityLivingBaseIn.getDisplayName(), this.damageSourceEntity.getDisplayName(), itemstack.getChatComponent()}): new ChatComponentTranslation(s, new Object[] {entityLivingBaseIn.getDisplayName(), this.damageSourceEntity.getDisplayName()});
53
    }
54
55
    /**
56
     * Return whether this damage source will have its damage amount scaled based on the current difficulty.
57
     */
58
    public boolean isDifficultyScaled()
59
    {
60
        return this.damageSourceEntity != null && this.damageSourceEntity instanceof EntityLivingBase && !(this.damageSourceEntity instanceof EntityPlayer);
61
    }
62
}
63

Deobfuscated MCP 1.8.9 source of EntityDamageSource from Marcelektro/MavenMCP-1.8.9 (net/minecraft/util/EntityDamageSource.java), stored verbatim.