EntityWitherSkull .java

net.minecraft.entity.projectile.EntityWitherSkull (class): members: getMotionFactor, setInvulnerable, isInvulnerable, getExplosionResistance, isBurning.

net.minecraft.entity.projectileclass158 linescommonextends EntityFireball4.8 KB

API Surface (9)

float getMotionFactor()
boolean isBurning()
float getExplosionResistance(Explosion explosionIn, World worldIn, BlockPos pos, IBlockState blockStateIn)
void onImpact(MovingObjectPosition movingObject)
boolean canBeCollidedWith()
boolean attackEntityFrom(DamageSource source, float amount)
void entityInit()
boolean isInvulnerable()
void setInvulnerable(boolean invulnerable)

String literals (1)

"mobGriefing"

Full Source

EntityWitherSkull.java158 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.entity.projectile;
2
3
import net.minecraft.block.Block;
4
import net.minecraft.block.state.IBlockState;
5
import net.minecraft.entity.EntityLivingBase;
6
import net.minecraft.entity.boss.EntityWither;
7
import net.minecraft.potion.Potion;
8
import net.minecraft.potion.PotionEffect;
9
import net.minecraft.util.BlockPos;
10
import net.minecraft.util.DamageSource;
11
import net.minecraft.util.MovingObjectPosition;
12
import net.minecraft.world.EnumDifficulty;
13
import net.minecraft.world.Explosion;
14
import net.minecraft.world.World;
15
16
public class EntityWitherSkull extends EntityFireball
17
{
18
    public EntityWitherSkull(World worldIn)
19
    {
20
        super(worldIn);
21
        this.setSize(0.3125F, 0.3125F);
22
    }
23
24
    public EntityWitherSkull(World worldIn, EntityLivingBase shooter, double accelX, double accelY, double accelZ)
25
    {
26
        super(worldIn, shooter, accelX, accelY, accelZ);
27
        this.setSize(0.3125F, 0.3125F);
28
    }
29
30
    /**
31
     * Return the motion factor for this projectile. The factor is multiplied by the original motion.
32
     */
33
    protected float getMotionFactor()
34
    {
35
        return this.isInvulnerable() ? 0.73F : super.getMotionFactor();
36
    }
37
38
    public EntityWitherSkull(World worldIn, double x, double y, double z, double accelX, double accelY, double accelZ)
39
    {
40
        super(worldIn, x, y, z, accelX, accelY, accelZ);
41
        this.setSize(0.3125F, 0.3125F);
42
    }
43
44
    /**
45
     * Returns true if the entity is on fire. Used by render to add the fire effect on rendering.
46
     */
47
    public boolean isBurning()
48
    {
49
        return false;
50
    }
51
52
    /**
53
     * Explosion resistance of a block relative to this entity
54
     */
55
    public float getExplosionResistance(Explosion explosionIn, World worldIn, BlockPos pos, IBlockState blockStateIn)
56
    {
57
        float f = super.getExplosionResistance(explosionIn, worldIn, pos, blockStateIn);
58
        Block block = blockStateIn.getBlock();
59
60
        if (this.isInvulnerable() && EntityWither.canDestroyBlock(block))
61
        {
62
            f = Math.min(0.8F, f);
63
        }
64
65
        return f;
66
    }
67
68
    /**
69
     * Called when this EntityFireball hits a block or entity.
70
     */
71
    protected void onImpact(MovingObjectPosition movingObject)
72
    {
73
        if (!this.worldObj.isRemote)
74
        {
75
            if (movingObject.entityHit != null)
76
            {
77
                if (this.shootingEntity != null)
78
                {
79
                    if (movingObject.entityHit.attackEntityFrom(DamageSource.causeMobDamage(this.shootingEntity), 8.0F))
80
                    {
81
                        if (!movingObject.entityHit.isEntityAlive())
82
                        {
83
                            this.shootingEntity.heal(5.0F);
84
                        }
85
                        else
86
                        {
87
                            this.applyEnchantments(this.shootingEntity, movingObject.entityHit);
88
                        }
89
                    }
90
                }
91
                else
92
                {
93
                    movingObject.entityHit.attackEntityFrom(DamageSource.magic, 5.0F);
94
                }
95
96
                if (movingObject.entityHit instanceof EntityLivingBase)
97
                {
98
                    int i = 0;
99
100
                    if (this.worldObj.getDifficulty() == EnumDifficulty.NORMAL)
101
                    {
102
                        i = 10;
103
                    }
104
                    else if (this.worldObj.getDifficulty() == EnumDifficulty.HARD)
105
                    {
106
                        i = 40;
107
                    }
108
109
                    if (i > 0)
110
                    {
111
                        ((EntityLivingBase)movingObject.entityHit).addPotionEffect(new PotionEffect(Potion.wither.id, 20 * i, 1));
112
                    }
113
                }
114
            }
115
116
            this.worldObj.newExplosion(this, this.posX, this.posY, this.posZ, 1.0F, false, this.worldObj.getGameRules().getBoolean("mobGriefing"));
117
            this.setDead();
118
        }
119
    }
120
121
    /**
122
     * Returns true if other Entities should be prevented from moving through this Entity.
123
     */
124
    public boolean canBeCollidedWith()
125
    {
126
        return false;
127
    }
128
129
    /**
130
     * Called when the entity is attacked.
131
     */
132
    public boolean attackEntityFrom(DamageSource source, float amount)
133
    {
134
        return false;
135
    }
136
137
    protected void entityInit()
138
    {
139
        this.dataWatcher.addObject(10, Byte.valueOf((byte)0));
140
    }
141
142
    /**
143
     * Return whether this skull comes from an invulnerable (aura) wither boss.
144
     */
145
    public boolean isInvulnerable()
146
    {
147
        return this.dataWatcher.getWatchableObjectByte(10) == 1;
148
    }
149
150
    /**
151
     * Set whether this skull comes from an invulnerable (aura) wither boss.
152
     */
153
    public void setInvulnerable(boolean invulnerable)
154
    {
155
        this.dataWatcher.updateObject(10, Byte.valueOf((byte)(invulnerable ? 1 : 0)));
156
    }
157
}
158

Deobfuscated MCP 1.8.9 source of EntityWitherSkull from Marcelektro/MavenMCP-1.8.9 (net/minecraft/entity/projectile/EntityWitherSkull.java), stored verbatim.