Guest User

Untitled

a guest
Dec 31st, 2020
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.88 KB | None | 0 0
  1. public class PowPowBombEntity extends ProjectileItemEntity
  2. {
  3.     public int explosionPower = 2;
  4.  
  5.     public PowPowBombEntity(EntityType<PowPowBombEntity> type, World worldIn) {
  6.         super(type,worldIn);
  7.  
  8.     }
  9.     public PowPowBombEntity(LivingEntity entity, World worldIn){
  10.         super(EntityList.POWPOW_BOMB.get(), entity, worldIn);
  11.  
  12.     }
  13.  
  14.     public PowPowBombEntity(double x, double y, double z, World worldIn){
  15.         super(EntityList.POWPOW_BOMB.get(), x, y, z, worldIn);
  16.  
  17.     }
  18.  
  19.     @Override
  20.     protected Item getDefaultItem() {
  21.         return ItemList.POWPOW_BOMB.get().asItem();
  22.     }
  23.  
  24.     @Override
  25.     public IPacket<?> createSpawnPacket() {
  26.         return NetworkHooks.getEntitySpawningPacket(this);
  27.     }
  28.  
  29.     @Override
  30.     protected void onImpact(RayTraceResult result) {
  31.  
  32.  
  33.         if(!world.isRemote)
  34.         {
  35.             boolean flag = net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.world, this.func_234616_v_());
  36.  
  37.             this.world.createExplosion((Entity)null, this.getPosX(), this.getPosY(), this.getPosZ(), (float)this.explosionPower, false, flag ? Explosion.Mode.NONE : Explosion.Mode.NONE);
  38.             this.remove();
  39.         }
  40.  
  41.     }
  42.  
  43.     @Override
  44.     public void onAddedToWorld() {
  45.  
  46.         if(!world.isRemote)
  47.             this.world.playSound((PlayerEntity)null, this.getPosX(), this.getPosY(), this.getPosZ(), SoundEvents.ENTITY_TNT_PRIMED, SoundCategory.NEUTRAL, 1.0F, 1.0F);
  48.  
  49.     }
  50.  
  51.     @Override
  52.     public void onRemovedFromWorld()
  53.     {
  54.  
  55.         int k = 2 + this.rand.nextInt(3);
  56.  
  57.         if(!world.isRemote && this.isEntityEqual(this.getEntity()))
  58.         {
  59.             for(int l = 0; l < k; ++l) {
  60.  
  61.                 PowPowBombEntity powpow1 = new PowPowBombEntity(EntityList.POWPOW_BOMB.get(), world);
  62.  
  63.                 float f1 = ((float)(l % 2) - 0.5F) * 4.0F;
  64.                 float f2 = ((float)(l / 2) - 0.5F) * 4.0F;
  65.  
  66.                 powpow1.setLocationAndAngles(this.getPosX() + (double)f1, this.getPosY() + 0.5D, this.getPosZ() + (double)f2, this.rand.nextFloat() * 360.0F, 0.0F);
  67.                 world.addEntity(powpow1);
  68.             }
  69.         }
  70.  
  71.  
  72.     }
  73.  
  74.     public void tick()
  75.     {
  76.         super.tick();
  77.         if (this.world.isRemote) {
  78.             this.world.addParticle(ParticleTypes.SMOKE, this.getPosX(), this.getPosY() - 0.3D, this.getPosZ(), this.rand.nextGaussian() * 0.05D, -this.getMotion().y * 0.5D, this.rand.nextGaussian() * 0.05D);
  79.         }
  80.  
  81.  
  82.  
  83.         if(!this.world.isRemote && this.ticksExisted == 45) {
  84.             boolean flag = net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.world, this.func_234616_v_());
  85.             this.world.createExplosion((Entity)null, this.getPosX(), this.getPosY(), this.getPosZ(), (float)this.explosionPower, false, flag ? Explosion.Mode.NONE : Explosion.Mode.NONE);
  86.             this.remove();
  87.         }
  88.  
  89.     }
  90. }
Advertisement
Add Comment
Please, Sign In to add comment