Advertisement
civilwargeeky

IceBolt

Jan 4th, 2014
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.74 KB | None | 0 0
  1. package icecreammod;
  2.  
  3. import net.minecraft.block.Block;
  4. import net.minecraft.entity.player.EntityPlayer;
  5. import net.minecraft.entity.projectile.EntityThrowable;
  6. import net.minecraft.util.MovingObjectPosition;
  7. import net.minecraft.world.World;
  8.  
  9. public class EntityIcebolt extends EntityThrowable {
  10.    
  11.     /** Explosion radius for this entity. */
  12.     private int damageRadius = 2;
  13.        
  14.            public EntityIcebolt(World par1World) {
  15.                super(par1World);
  16.            }
  17.            
  18.            public EntityIcebolt(World par1World, EntityPlayer par3EntityPlayer) {
  19.                super(par1World, par3EntityPlayer);
  20.            }
  21.            
  22.            public EntityIcebolt(World par1World, double par2, double par4, double par6) {
  23.                super(par1World, par2, par4, par6);
  24.            }
  25.            
  26.            @Override
  27.            protected void onImpact(MovingObjectPosition movingobjectposition) {
  28.                    this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, (float)this.damageRadius, false);
  29.            this.setFire(25);
  30.                    this.setDead();
  31.                 if (!this.worldObj.isRemote)
  32.                 {
  33.                     if (movingobjectposition.entityHit != null)
  34.                     {
  35.                         if (!movingobjectposition.entityHit.isImmuneToFire())
  36.                         {
  37.                                 movingobjectposition.entityHit.setFire(20);
  38.                         }
  39.                        
  40.                     }
  41.                     else
  42.                     {
  43.                         int i = movingobjectposition.blockX;
  44.                         int j = movingobjectposition.blockY;
  45.                         int k = movingobjectposition.blockZ;
  46.  
  47.                         switch (movingobjectposition.sideHit)
  48.                         {
  49.                             case 0:
  50.                                 --j;
  51.                                 break;
  52.                             case 1:
  53.                                 ++j;
  54.                                 break;
  55.                             case 2:
  56.                                 --k;
  57.                                 break;
  58.                             case 3:
  59.                                 ++k;
  60.                                 break;
  61.                             case 4:
  62.                                 --i;
  63.                                 break;
  64.                             case 5:
  65.                                 ++i;
  66.                         }
  67.  
  68.                         if (this.worldObj.isAirBlock(i, j, k))
  69.                         {
  70.                             trySet(i, j, k, Block.snow.blockID);
  71.                             trySet(i+2, j, k, Block.snow.blockID);
  72.                             trySet(i, j, k+3, Block.snow.blockID);
  73.                             trySet(i+4, j, k, Block.snow.blockID);
  74.                             trySet(i, j, k+1, Block.snow.blockID);
  75.                             trySet(i+2, j, k+4, Block.snow.blockID);
  76.                             trySet(i+1, j, k+1, Block.snow.blockID);
  77.                             trySet(i+4, j, k+5, Block.snow.blockID);
  78.                             trySet(i+6, j, k, Block.snow.blockID);
  79.                         }
  80.                     }
  81.                    
  82.                    
  83.                 }
  84.            }
  85.            
  86.            @Override
  87.            protected float getGravityVelocity()
  88.            {
  89.                    return 0;
  90.            }
  91.  
  92.            protected boolean trySet(int a, int b, int c, int d) {
  93.                if (!this.worldObj.isAirBlock(a,b-1,c) && (this.worldObj.getBlockId(a, b-1, c) != Block.snow.blockID)) {
  94.                    return this.worldObj.setBlock(a, b, c, d);
  95.                }
  96.                return false;
  97.            }
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement