1 package chemicraft.entity;
3 import java.util.Iterator;
5 import net.minecraft.src.DamageSource;
6 import net.minecraft.src.Entity;
7 import net.minecraft.src.EntityLiving;
8 import net.minecraft.src.EntityThrowable;
9 import net.minecraft.src.MovingObjectPosition;
10 import net.minecraft.src.PotionEffect;
11 import net.minecraft.src.World;
13 public class EntityAtomGrenade extends EntityThrowable
16 private float explodeSize;
17 private boolean isExplode;
18 private boolean onFire;
19 private boolean isNuke;
21 public EntityAtomGrenade(World par1World, EntityLiving par2EntityLiving, boolean par3, boolean par4, boolean par5) {
22 super(par1World, par2EntityLiving);
23 this.isExplode = par3;
29 public void onUpdate(){
34 protected void onImpact(MovingObjectPosition par1MovingObjectPosition)
38 this.explodeSize = 3.0F;
42 this.explodeSize = 20.0F;
45 if (par1MovingObjectPosition.entityHit != null) {
46 par1MovingObjectPosition.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.thrower), 2);
47 par1MovingObjectPosition.entityHit.setFire(5);
50 if (!this.worldObj.isRemote && !isNuke) {
51 this.worldObj.newExplosion((Entity)null, this.posX, this.posY, this.posZ, explodeSize, onFire);
53 }else if(!this.worldObj.isRemote && isNuke){
54 this.worldObj.newExplosion((Entity)null, this.posX, this.posY, this.posZ, explodeSize, onFire);
55 Iterator itr = this.worldObj.getEntitiesWithinAABB(EntityLiving.class, this.boundingBox.expand(30, 30, 30)).iterator();
57 EntityLiving entity = (EntityLiving) itr.next();
58 double dx = Math.abs(entity.posX - this.posX);
59 double dy = Math.abs(entity.posY - this.posY);
60 double dz = Math.abs(entity.posZ - this.posZ);
61 int distance = (int)Math.sqrt( Math.pow(dx, 2) + Math.pow(dy, 2) + Math.pow(dz, 2) );
62 if(30 - distance >= 0){
63 entity.addPotionEffect(new PotionEffect(2, (60 + (30 - distance)) * 20, (30 - distance) / 5));
64 entity.addPotionEffect(new PotionEffect(4, (60 + (30 - distance)) * 20, (30 - distance) / 5));
65 entity.addPotionEffect(new PotionEffect(18, (60 + (30 - distance)) * 20, (30 - distance) / 5));
66 entity.addPotionEffect(new PotionEffect(19, (60 + (30 - distance)) * 20, (30 - distance) / 5));