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