Advertisement
Guest User

Untitled

a guest
Feb 5th, 2017
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.16 KB | None | 0 0
  1. //Copyright (C) 2016 Andrew Morin
  2. //Licensed under GNU GPL v3; see license.txt for complete license terms + conditions etc.
  3.  
  4. package theishiopian.gunmod.entity;
  5.  
  6. import net.minecraft.client.multiplayer.WorldClient;
  7. import net.minecraft.entity.EntityLivingBase;
  8. import net.minecraft.entity.player.EntityPlayer;
  9. import net.minecraft.entity.projectile.EntityThrowable;
  10. import net.minecraft.init.Blocks;
  11. import net.minecraft.init.SoundEvents;
  12. import net.minecraft.util.DamageSource;
  13. import net.minecraft.util.EnumParticleTypes;
  14. import net.minecraft.util.SoundCategory;
  15. import net.minecraft.util.math.BlockPos;
  16. import net.minecraft.util.math.RayTraceResult;
  17. import net.minecraft.util.math.RayTraceResult.Type;
  18. import net.minecraft.world.World;
  19. import net.minecraft.world.WorldServer;
  20.  
  21. import java.util.Random;
  22.  
  23. public class EntityBullet extends EntityThrowable
  24. {  
  25.     public EntityBullet(World world)
  26.     {
  27.         super(world);
  28.     }
  29.    
  30.     public EntityBullet(World world, EntityLivingBase entity)
  31.     {
  32.         super(world, entity);
  33.         this.ignoreEntity = entity;
  34.     }
  35.  
  36.     public EntityBullet(World world, double x, double y, double z)
  37.     {
  38.         super(world, x, y, z);
  39.     }
  40.    
  41.     @Override
  42.     protected void onImpact(RayTraceResult result)
  43.     {
  44.         if(result.typeOfHit == Type.BLOCK)
  45.         {
  46.             if(!world.isRemote&&world.getBlockState(result.getBlockPos()).getBlockHardness(world, result.getBlockPos())>1)
  47.             {
  48.                 ((WorldServer)world).spawnParticle(EnumParticleTypes.LAVA, true, posX, posY, posZ, 1, 0, 0, 0, 1, new int[0]);
  49.                 this.world.playSound(null, posX, posY, posZ, SoundEvents.BLOCK_ANVIL_FALL, SoundCategory.HOSTILE, 1, 1);
  50.             }
  51.             if(world.getBlockState(result.getBlockPos()).getCollisionBoundingBox(world, result.getBlockPos()) != null)setDead();
  52.         }
  53.         else if(result.entityHit != null)
  54.         {
  55.            
  56.             result.entityHit.attackEntityFrom(DamageSource.GENERIC, 3);
  57.             result.entityHit.hurtResistantTime = 0;
  58.             setDead();
  59.         }
  60.     }
  61.    
  62.     @Override
  63.     public void onUpdate()
  64.     {
  65.         super.onUpdate();
  66.        
  67.         if(this.ticksExisted>100)setDead();
  68.        
  69.         this.world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, this.posX, this.posY, this.posZ, this.motionX, this.motionY, this.motionZ, new int[0]);       
  70.     }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement