Guest User

Untitled

a guest
Jul 27th, 2017
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.47 KB | None | 0 0
  1. package melonslise.runicinscription.common.entity;
  2.  
  3. import net.minecraft.entity.EntityLivingBase;
  4. import net.minecraft.init.Blocks;
  5. import net.minecraft.util.DamageSource;
  6. import net.minecraft.util.EnumParticleTypes;
  7. import net.minecraft.util.math.BlockPos;
  8. import net.minecraft.util.math.RayTraceResult;
  9. import net.minecraft.world.World;
  10.  
  11. public class EntityFirebolt extends EntityProjectile
  12. {
  13.     public EntityFirebolt(World world)
  14.     {
  15.         super(world);
  16.         this.setSize(0.25F, 0.25F);
  17.     }
  18.  
  19.     public EntityFirebolt(World world, EntityLivingBase caster, double speed)
  20.     {
  21.         super(world, caster, speed);
  22.         this.setSize(0.25F, 0.25F);
  23.     }
  24.  
  25.     @Override
  26.     protected void onImpact(RayTraceResult result)
  27.     {
  28.         System.out.println("IMPACT" + " is client " + this.worldObj.isRemote + ", " + result.entityHit);
  29.         if (result.entityHit != null)
  30.         {
  31.             if (!result.entityHit.isImmuneToFire())
  32.             {
  33.                 boolean flag = result.entityHit.attackEntityFrom(DamageSource.inFire, 5.0F); // TODO OWN DAMAGE SRC
  34.                 if (flag)
  35.                 {
  36.                     this.applyEnchantments(this.getCaster(), result.entityHit); // Not sure what this is TODO
  37.                     result.entityHit.setFire(5);
  38.                 }
  39.             }
  40.         }
  41.         else
  42.         {
  43.             boolean flag1 = this.worldObj.getGameRules().getBoolean("doFireTick");
  44.             if (flag1)
  45.             {
  46.                 BlockPos blockpos = result.getBlockPos().offset(result.sideHit);
  47.                 if (this.worldObj.isAirBlock(blockpos))
  48.                 {
  49.                     this.worldObj.setBlockState(blockpos, Blocks.FIRE.getDefaultState());
  50.                 }
  51.             }
  52.         }
  53.         if(!this.isInWater())
  54.         {
  55.             for (int a = 0; a < 16; ++a)
  56.             {
  57.                 this.worldObj.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, this.posX, this.posY, this.posZ, this.rand.nextGaussian() * 0.03D, 0.0D, this.rand.nextGaussian() * 0.03D, new int[0]);
  58.             }
  59.             for (int a = 0; a < 12; ++a) // TODO Add lava particles
  60.             {
  61.                 this.worldObj.spawnParticle(EnumParticleTypes.FLAME, this.posX, this.posY, this.posZ, -this.motionX * this.rand.nextGaussian() * 0.15D, -this.motionY * this.rand.nextGaussian() * 0.2D, -this.motionZ * this.rand.nextGaussian() * 0.15D, new int[0]);
  62.             }
  63.         }
  64.         if(!this.worldObj.isRemote)
  65.         {
  66.             this.setDead();
  67.         }
  68.     }
  69.  
  70.     @Override
  71.     protected void spawnParticleTrail()
  72.     {
  73.         this.worldObj.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, this.posX, this.posY + 0.3D, this.posZ, 0.0D, 0.0D, 0.0D);
  74.     }
  75.  
  76.     @Override
  77.     protected void entityInit()
  78.     {
  79.     }
  80.  
  81.     @Override
  82.     public boolean diesInWater()
  83.     {
  84.         return true;
  85.     }
  86.  
  87.     @Override
  88.     public boolean shouldBurn()
  89.     {
  90.         return true;
  91.     }
  92. }
Advertisement
Add Comment
Please, Sign In to add comment