    001    package net.minecraft.src;
    002
    003    import cpw.mods.fml.common.Side;
    004    import cpw.mods.fml.common.asm.SideOnly;
    005
    006    public class EntityWitherSkull extends EntityFireball
    007    {
    008        public EntityWitherSkull(World par1World)
    009        {
    010            super(par1World);
    011            this.setSize(0.3125F, 0.3125F);
    012        }
    013
    014        public EntityWitherSkull(World par1World, EntityLiving par2EntityLiving, double par3, double par5, double par7)
    015        {
    016            super(par1World, par2EntityLiving, par3, par5, par7);
    017            this.setSize(0.3125F, 0.3125F);
    018        }
    019
    020        /**
    021         * Return the motion factor for this projectile. The factor is multiplied by the original motion.
    022         */
    023        protected float getMotionFactor()
    024        {
    025            return this.isInvulnerable() ? 0.73F : super.getMotionFactor();
    026        }
    027
    028        @SideOnly(Side.CLIENT)
    029        public EntityWitherSkull(World par1World, double par2, double par4, double par6, double par8, double par10, double par12)
    030        {
    031            super(par1World, par2, par4, par6, par8, par10, par12);
    032            this.setSize(0.3125F, 0.3125F);
    033        }
    034
    035        /**
    036         * Returns true if the entity is on fire. Used by render to add the fire effect on rendering.
    037         */
    038        public boolean isBurning()
    039        {
    040            return false;
    041        }
    042
    043        public float func_82146_a(Explosion par1Explosion, Block par2Block, int par3, int par4, int par5)
    044        {
    045            float var6 = super.func_82146_a(par1Explosion, par2Block, par3, par4, par5);
    046
    047            if (this.isInvulnerable() && par2Block != Block.bedrock && par2Block != Block.endPortal && par2Block != Block.endPortalFrame)
    048            {
    049                var6 = Math.min(0.8F, var6);
    050            }
    051
    052            return var6;
    053        }
    054
    055        /**
    056         * Called when this EntityFireball hits a block or entity.
    057         */
    058        protected void onImpact(MovingObjectPosition par1MovingObjectPosition)
    059        {
    060            if (!this.worldObj.isRemote)
    061            {
    062                if (par1MovingObjectPosition.entityHit != null)
    063                {
    064                    if (this.shootingEntity != null)
    065                    {
    066                        if (par1MovingObjectPosition.entityHit.attackEntityFrom(DamageSource.causeMobDamage(this.shootingEntity), 8) && !par1MovingObjectPosition.entityHit.isEntityAlive())
    067                        {
    068                            this.shootingEntity.heal(5);
    069                        }
    070                    }
    071                    else
    072                    {
    073                        par1MovingObjectPosition.entityHit.attackEntityFrom(DamageSource.magic, 5);
    074                    }
    075
    076                    if (par1MovingObjectPosition.entityHit instanceof EntityLiving)
    077                    {
    078                        byte var2 = 0;
    079
    080                        if (this.worldObj.difficultySetting > 1)
    081                        {
    082                            if (this.worldObj.difficultySetting == 2)
    083                            {
    084                                var2 = 10;
    085                            }
    086                            else if (this.worldObj.difficultySetting == 3)
    087                            {
    088                                var2 = 40;
    089                            }
    090                        }
    091
    092                        if (var2 > 0)
    093                        {
    094                            ((EntityLiving)par1MovingObjectPosition.entityHit).addPotionEffect(new PotionEffect(Potion.wither.id, 20 * var2, 1));
    095                        }
    096                    }
    097                }
    098
    099                this.worldObj.newExplosion(this, this.posX, this.posY, this.posZ, 1.0F, false, this.worldObj.getGameRules().getGameRuleBooleanValue("mobGriefing"));
    100                this.setDead();
    101            }
    102        }
    103
    104        /**
    105         * Returns true if other Entities should be prevented from moving through this Entity.
    106         */
    107        public boolean canBeCollidedWith()
    108        {
    109            return false;
    110        }
    111
    112        /**
    113         * Called when the entity is attacked.
    114         */
    115        public boolean attackEntityFrom(DamageSource par1DamageSource, int par2)
    116        {
    117            return false;
    118        }
    119
    120        protected void entityInit()
    121        {
    122            this.dataWatcher.addObject(10, Byte.valueOf((byte)0));
    123        }
    124
    125        /**
    126         * Return whether this skull comes from an invulnerable (aura) wither boss.
    127         */
    128        public boolean isInvulnerable()
    129        {
    130            return this.dataWatcher.getWatchableObjectByte(10) == 1;
    131        }
    132
    133        /**
    134         * Set whether this skull comes from an invulnerable (aura) wither boss.
    135         */
    136        public void setInvulnerable(boolean par1)
    137        {
    138            this.dataWatcher.updateObject(10, Byte.valueOf((byte)(par1 ? 1 : 0)));
    139        }
    140    }