Program: 81877
Project: 81877
Buggy source:
@SideOnly(Side.CLIENT) public void tickClient(){
  if (isCloudlessStorm())   return;
  if (particleBehaviorFog == null) {
    particleBehaviorFog=new ParticleBehaviorFog(new Vec3(pos.xCoord,pos.yCoord,pos.zCoord));
  }
 else {
    if (!Minecraft.getMinecraft().isSingleplayer() || !(Minecraft.getMinecraft().currentScreen instanceof GuiIngameMenu)) {
      particleBehaviorFog.tickUpdateList();
    }
  }
  EntityPlayer entP=Minecraft.getMinecraft().player;
  spinSpeed=0.02D;
  double spinSpeedMax=0.4D;
  if (isCycloneFormingOrGreater()) {
    spinSpeed=spinSpeedMax * 0.00D + ((levelCurIntensityStage - levelStormIntensityFormingStartVal + 1) * spinSpeedMax * 0.2D);
  }
 else   if (isTornadoFormingOrGreater()) {
    spinSpeed=spinSpeedMax * 0.2D;
  }
 else   if (levelCurIntensityStage >= STATE_HIGHWIND) {
    spinSpeed=spinSpeedMax * 0.05D;
  }
 else {
    spinSpeed=spinSpeedMax * 0.02D;
  }
  if (isHurricane()) {
    spinSpeed+=0.1D;
  }
  if (size == 0)   size=1;
  int delay=Math.max(1,(int)(100F / size * 1F));
  int loopSize=1;
  int extraSpawning=0;
  if (isSpinning()) {
    loopSize+=4;
    extraSpawning=300;
  }
  if (stormType == TYPE_WATER) {
    if (levelCurIntensityStage >= STATE_STAGE5) {
      loopSize=10;
      extraSpawning=800;
    }
 else     if (levelCurIntensityStage >= STATE_STAGE4) {
      loopSize=8;
      extraSpawning=700;
    }
 else     if (levelCurIntensityStage >= STATE_STAGE3) {
      loopSize=6;
      extraSpawning=500;
    }
 else     if (levelCurIntensityStage >= STATE_STAGE2) {
      loopSize=4;
      extraSpawning=400;
    }
 else {
      extraSpawning=300;
    }
  }
  Random rand=new Random();
  Vec3 playerAdjPos=new Vec3(entP.posX,pos.yCoord,entP.posZ);
  double maxSpawnDistFromPlayer=512;
  if (this.manager.getWorld().getTotalWorldTime() % (delay + ConfigMisc.Cloud_ParticleSpawnDelay) == 0) {
    for (int i=0; i < loopSize; i++) {
      if (listParticlesCloud.size() < size + extraSpawning) {
        double spawnRad=size;
        Vec3 tryPos=new Vec3(pos.xCoord + (rand.nextDouble() * spawnRad) - (rand.nextDouble() * spawnRad),layers.get(layer),pos.zCoord + (rand.nextDouble() * spawnRad) - (rand.nextDouble() * spawnRad));
        if (tryPos.distanceTo(playerAdjPos) < maxSpawnDistFromPlayer) {
          if (getAvoidAngleIfTerrainAtOrAheadOfPosition(getAdjustedAngle(),tryPos) == 0) {
            EntityRotFX particle;
            if (WeatherUtil.isAprilFoolsDay()) {
              particle=spawnFogParticle(tryPos.xCoord,tryPos.yCoord,tryPos.zCoord,0,ParticleRegistry.chicken);
            }
 else {
              particle=spawnFogParticle(tryPos.xCoord,tryPos.yCoord,tryPos.zCoord,0);
            }
            listParticlesCloud.add(particle);
          }
        }
      }
    }
  }
  if (levelCurIntensityStage >= STATE_HIGHWIND) {
    for (int i=0; i < (stormType == TYPE_WATER ? 50 : 3); i++) {
      if (listParticlesGround.size() < (stormType == TYPE_WATER ? 600 : 150)) {
        double spawnRad=size / 4 * 3;
        if (stormType == TYPE_WATER) {
          spawnRad=size * 3;
        }
        Vec3 tryPos=new Vec3(pos.xCoord + (rand.nextDouble() * spawnRad) - (rand.nextDouble() * spawnRad),posGround.yCoord,pos.zCoord + (rand.nextDouble() * spawnRad) - (rand.nextDouble() * spawnRad));
        if (tryPos.distanceTo(playerAdjPos) < maxSpawnDistFromPlayer) {
          int groundY=WeatherUtilBlock.getPrecipitationHeightSafe(manager.getWorld(),new BlockPos((int)tryPos.xCoord,0,(int)tryPos.zCoord)).getY();
          EntityRotFX particle;
          if (WeatherUtil.isAprilFoolsDay()) {
            particle=spawnFogParticle(tryPos.xCoord,groundY + 3,tryPos.zCoord,0,ParticleRegistry.potato);
          }
 else {
            particle=spawnFogParticle(tryPos.xCoord,groundY + 3,tryPos.zCoord,0);
          }
          particle.setScale(100);
          particle.rotationYaw=rand.nextInt(360);
          particle.rotationPitch=rand.nextInt(360);
          listParticlesGround.add(particle);
        }
      }
    }
  }
  delay=1;
  loopSize=2;
  double spawnRad=size / 48;
  if (levelCurIntensityStage >= STATE_STAGE5) {
    spawnRad=200;
    loopSize=10;
    sizeMaxFunnelParticles=1200;
  }
 else   if (levelCurIntensityStage >= STATE_STAGE4) {
    spawnRad=150;
    loopSize=8;
    sizeMaxFunnelParticles=1000;
  }
 else   if (levelCurIntensityStage >= STATE_STAGE3) {
    spawnRad=100;
    loopSize=6;
    sizeMaxFunnelParticles=800;
  }
 else   if (levelCurIntensityStage >= STATE_STAGE2) {
    spawnRad=50;
    loopSize=4;
    sizeMaxFunnelParticles=600;
  }
 else {
    sizeMaxFunnelParticles=600;
  }
  if (isTornadoFormingOrGreater() || (attrib_waterSpout)) {
    if (this.manager.getWorld().getTotalWorldTime() % (delay + ConfigStorm.Storm_ParticleSpawnDelay) == 0) {
      for (int i=0; i < loopSize; i++) {
        if (listParticlesFunnel.size() >= sizeMaxFunnelParticles) {
          listParticlesFunnel.get(0).setExpired();
          listParticlesFunnel.remove(0);
        }
        if (listParticlesFunnel.size() < sizeMaxFunnelParticles) {
          Vec3 tryPos=new Vec3(pos.xCoord + (rand.nextDouble() * spawnRad) - (rand.nextDouble() * spawnRad),pos.yCoord,pos.zCoord + (rand.nextDouble() * spawnRad) - (rand.nextDouble() * spawnRad));
          if (tryPos.distanceTo(playerAdjPos) < maxSpawnDistFromPlayer) {
            EntityRotFX particle;
            if (WeatherUtil.isAprilFoolsDay()) {
              particle=spawnFogParticle(tryPos.xCoord,posBaseFormationPos.yCoord,tryPos.zCoord,1,ParticleRegistry.potato);
            }
 else {
              if (!isFirenado && false) {
                particle=spawnFogParticle(tryPos.xCoord,posBaseFormationPos.yCoord,tryPos.zCoord,1);
              }
 else {
                particle=spawnFogParticle(tryPos.xCoord,posBaseFormationPos.yCoord,tryPos.zCoord,1,ParticleRegistry.cloud256_fire);
              }
            }
            particle.setMaxAge(150 + ((levelCurIntensityStage - 1) * 100) + rand.nextInt(100));
            float baseBright=0.3F;
            float randFloat=(rand.nextFloat() * 0.6F);
            particle.rotationYaw=rand.nextInt(360);
            float finalBright=Math.min(1F,baseBright + randFloat);
            if (levelCurIntensityStage == STATE_HIGHWIND) {
              particle.setScale(150);
              particle.setRBGColorF(finalBright - 0.2F,finalBright - 0.2F,finalBright);
            }
 else {
              particle.setScale(250);
              particle.setRBGColorF(finalBright,finalBright,finalBright);
            }
            if (isFirenado) {
              particle.setRBGColorF(1F,1F,1F);
            }
            listParticlesFunnel.add(particle);
          }
        }
 else {
        }
      }
    }
  }
  for (int i=0; i < listParticlesFunnel.size(); i++) {
    EntityRotFX ent=listParticlesFunnel.get(i);
    if (!ent.isAlive()) {
      listParticlesFunnel.remove(ent);
    }
 else     if (ent.getPosY() > pos.yCoord) {
      ent.setExpired();
      listParticlesFunnel.remove(ent);
    }
 else {
      double var16=this.pos.xCoord - ent.getPosX();
      double var18=this.pos.zCoord - ent.getPosZ();
      ent.rotationYaw=(float)(Math.atan2(var18,var16) * 180.0D / Math.PI) - 90.0F;
      ent.rotationYaw+=ent.getEntityId() % 90;
      ent.rotationPitch=-30F;
      if (levelCurIntensityStage == STATE_HIGHWIND) {
        int fadingDistStart=30;
        if (ent.getPosY() > posGround.yCoord + fadingDistStart) {
          float maxVal=ent.getBlueColorF();
          float fadeRate=0.002F;
          ent.setRBGColorF(Math.min(maxVal,ent.getRedColorF() + fadeRate),Math.min(maxVal,ent.getGreenColorF() + fadeRate),maxVal);
        }
      }
      spinEntity(ent);
    }
  }
  for (int i=0; i < listParticlesCloud.size(); i++) {
    EntityRotFX ent=listParticlesCloud.get(i);
    if (!ent.isAlive()) {
      listParticlesCloud.remove(ent);
    }
 else {
      double curSpeed=Math.sqrt(ent.getMotionX() * ent.getMotionX() + ent.getMotionY() * ent.getMotionY() + ent.getMotionZ() * ent.getMotionZ());
      double curDist=ent.getDistance(pos.xCoord,ent.getPosY(),pos.zCoord);
      float dropDownRange=15F;
      float extraDropCalc=0;
      if (curDist < 200 && ent.getEntityId() % 20 < 5) {
        extraDropCalc=((ent.getEntityId() % 20) * dropDownRange);
        if (isCycloneFormingOrGreater()) {
          extraDropCalc=((ent.getEntityId() % 20) * dropDownRange * 5F);
        }
      }
      if (isSpinning()) {
        double speed=spinSpeed + (rand.nextDouble() * 0.01D);
        double distt=size;
        double vecX=ent.getPosX() - pos.xCoord;
        double vecZ=ent.getPosZ() - pos.zCoord;
        float angle=(float)(Math.atan2(vecZ,vecX) * 180.0D / Math.PI);
        angle+=speed * 50D;
        angle-=(ent.getEntityId() % 10) * 3D;
        angle+=rand.nextInt(10) - rand.nextInt(10);
        if (curDist > distt) {
          angle+=40;
        }
        if (ent.getEntityId() % 20 < 5) {
          if (levelCurIntensityStage >= STATE_FORMING) {
            if (stormType == TYPE_WATER) {
              angle+=40 + ((ent.getEntityId() % 5) * 4);
              if (curDist > 150 + ((levelCurIntensityStage - levelStormIntensityFormingStartVal + 1) * 30)) {
                angle+=10;
              }
            }
 else {
              angle+=30 + ((ent.getEntityId() % 5) * 4);
            }
          }
 else {
            if (curDist > 150) {
              angle+=50 + ((ent.getEntityId() % 5) * 4);
            }
          }
          double var16=this.pos.xCoord - ent.getPosX();
          double var18=this.pos.zCoord - ent.getPosZ();
          ent.rotationYaw=(float)(Math.atan2(var18,var16) * 180.0D / Math.PI) - 90.0F;
          ent.rotationPitch=-20F - (ent.getEntityId() % 10);
        }
        if (curSpeed < speed * 20D) {
          ent.setMotionX(ent.getMotionX() + -Math.sin(Math.toRadians(angle)) * speed);
          ent.setMotionZ(ent.getMotionZ() + Math.cos(Math.toRadians(angle)) * speed);
        }
      }
 else {
        float cloudMoveAmp=0.2F * (1 + layer);
        float speed=getAdjustedSpeed() * cloudMoveAmp;
        float angle=getAdjustedAngle();
        if ((manager.getWorld().getTotalWorldTime() + this.ID) % 40 == 0) {
          ent.avoidTerrainAngle=getAvoidAngleIfTerrainAtOrAheadOfPosition(angle,ent.getPos());
        }
        angle+=ent.avoidTerrainAngle;
        if (ent.avoidTerrainAngle != 0) {
          speed*=0.5D;
        }
        dropDownRange=5;
        if (ent.getEntityId() % 20 < 5) {
          extraDropCalc=((ent.getEntityId() % 20) * dropDownRange);
        }
        if (curSpeed < speed * 1D) {
          ent.setMotionX(ent.getMotionX() + -Math.sin(Math.toRadians(angle)) * speed);
          ent.setMotionZ(ent.getMotionZ() + Math.cos(Math.toRadians(angle)) * speed);
        }
      }
      if (Math.abs(ent.getPosY() - (pos.yCoord - extraDropCalc)) > 2F) {
        if (ent.getPosY() < pos.yCoord - extraDropCalc) {
          ent.setMotionY(ent.getMotionY() + 0.1D);
        }
 else {
          ent.setMotionY(ent.getMotionY() - 0.1D);
        }
      }
      float dropDownSpeedMax=0.15F;
      if (isCycloneFormingOrGreater()) {
        dropDownSpeedMax=0.9F;
      }
      if (ent.getMotionY() < -dropDownSpeedMax) {
        ent.setMotionY(-dropDownSpeedMax);
      }
      if (ent.getMotionY() > dropDownSpeedMax) {
        ent.setMotionY(dropDownSpeedMax);
      }
    }
  }
  for (int i=0; i < listParticlesGround.size(); i++) {
    EntityRotFX ent=listParticlesGround.get(i);
    double curDist=ent.getDistance(pos.xCoord,ent.getPosY(),pos.zCoord);
    if (!ent.isAlive()) {
      listParticlesGround.remove(ent);
    }
 else {
      double curSpeed=Math.sqrt(ent.getMotionX() * ent.getMotionX() + ent.getMotionY() * ent.getMotionY() + ent.getMotionZ() * ent.getMotionZ());
      double speed=Math.max(0.2F,5F * spinSpeed) + (rand.nextDouble() * 0.01D);
      double distt=size;
      double vecX=ent.getPosX() - pos.xCoord;
      double vecZ=ent.getPosZ() - pos.zCoord;
      float angle=(float)(Math.atan2(vecZ,vecX) * 180.0D / Math.PI);
      angle+=85;
      int maxParticleSize=60;
      if (stormType == TYPE_WATER) {
        maxParticleSize=150;
        speed/=5D;
      }
      ent.setScale((float)Math.min(maxParticleSize,curDist * 2F));
      if (curDist < 20) {
        ent.setExpired();
      }
      double var16=this.pos.xCoord - ent.getPosX();
      double var18=this.pos.zCoord - ent.getPosZ();
      if (curSpeed < speed * 20D) {
        ent.setMotionX(ent.getMotionX() + -Math.sin(Math.toRadians(angle)) * speed);
        ent.setMotionZ(ent.getMotionZ() + Math.cos(Math.toRadians(angle)) * speed);
      }
    }
  }
}

Fixed version (ground truth):
@SideOnly(Side.CLIENT) public void tickClient(){
  if (isCloudlessStorm())   return;
  if (particleBehaviorFog == null) {
    particleBehaviorFog=new ParticleBehaviorFog(new Vec3(pos.xCoord,pos.yCoord,pos.zCoord));
  }
 else {
    if (!Minecraft.getMinecraft().isSingleplayer() || !(Minecraft.getMinecraft().currentScreen instanceof GuiIngameMenu)) {
      particleBehaviorFog.tickUpdateList();
    }
  }
  EntityPlayer entP=Minecraft.getMinecraft().player;
  spinSpeed=0.02D;
  double spinSpeedMax=0.4D;
  if (isCycloneFormingOrGreater()) {
    spinSpeed=spinSpeedMax * 0.00D + ((levelCurIntensityStage - levelStormIntensityFormingStartVal + 1) * spinSpeedMax * 0.2D);
  }
 else   if (isTornadoFormingOrGreater()) {
    spinSpeed=spinSpeedMax * 0.2D;
  }
 else   if (levelCurIntensityStage >= STATE_HIGHWIND) {
    spinSpeed=spinSpeedMax * 0.05D;
  }
 else {
    spinSpeed=spinSpeedMax * 0.02D;
  }
  if (isHurricane()) {
    spinSpeed+=0.1D;
  }
  if (size == 0)   size=1;
  int delay=Math.max(1,(int)(100F / size * 1F));
  int loopSize=1;
  int extraSpawning=0;
  if (isSpinning()) {
    loopSize+=4;
    extraSpawning=300;
  }
  if (stormType == TYPE_WATER) {
    if (levelCurIntensityStage >= STATE_STAGE5) {
      loopSize=10;
      extraSpawning=800;
    }
 else     if (levelCurIntensityStage >= STATE_STAGE4) {
      loopSize=8;
      extraSpawning=700;
    }
 else     if (levelCurIntensityStage >= STATE_STAGE3) {
      loopSize=6;
      extraSpawning=500;
    }
 else     if (levelCurIntensityStage >= STATE_STAGE2) {
      loopSize=4;
      extraSpawning=400;
    }
 else {
      extraSpawning=300;
    }
  }
  Random rand=new Random();
  Vec3 playerAdjPos=new Vec3(entP.posX,pos.yCoord,entP.posZ);
  double maxSpawnDistFromPlayer=512;
  if (this.manager.getWorld().getTotalWorldTime() % (delay + ConfigMisc.Cloud_ParticleSpawnDelay) == 0) {
    for (int i=0; i < loopSize; i++) {
      if (listParticlesCloud.size() < size + extraSpawning) {
        double spawnRad=size;
        Vec3 tryPos=new Vec3(pos.xCoord + (rand.nextDouble() * spawnRad) - (rand.nextDouble() * spawnRad),layers.get(layer),pos.zCoord + (rand.nextDouble() * spawnRad) - (rand.nextDouble() * spawnRad));
        if (tryPos.distanceTo(playerAdjPos) < maxSpawnDistFromPlayer) {
          if (getAvoidAngleIfTerrainAtOrAheadOfPosition(getAdjustedAngle(),tryPos) == 0) {
            EntityRotFX particle;
            if (WeatherUtil.isAprilFoolsDay()) {
              particle=spawnFogParticle(tryPos.xCoord,tryPos.yCoord,tryPos.zCoord,0,ParticleRegistry.chicken);
            }
 else {
              particle=spawnFogParticle(tryPos.xCoord,tryPos.yCoord,tryPos.zCoord,0);
            }
            listParticlesCloud.add(particle);
          }
        }
      }
    }
  }
  if (levelCurIntensityStage >= STATE_HIGHWIND) {
    for (int i=0; i < (stormType == TYPE_WATER ? 50 : 3); i++) {
      if (listParticlesGround.size() < (stormType == TYPE_WATER ? 600 : 150)) {
        double spawnRad=size / 4 * 3;
        if (stormType == TYPE_WATER) {
          spawnRad=size * 3;
        }
        Vec3 tryPos=new Vec3(pos.xCoord + (rand.nextDouble() * spawnRad) - (rand.nextDouble() * spawnRad),posGround.yCoord,pos.zCoord + (rand.nextDouble() * spawnRad) - (rand.nextDouble() * spawnRad));
        if (tryPos.distanceTo(playerAdjPos) < maxSpawnDistFromPlayer) {
          int groundY=WeatherUtilBlock.getPrecipitationHeightSafe(manager.getWorld(),new BlockPos((int)tryPos.xCoord,0,(int)tryPos.zCoord)).getY();
          EntityRotFX particle;
          if (WeatherUtil.isAprilFoolsDay()) {
            particle=spawnFogParticle(tryPos.xCoord,groundY + 3,tryPos.zCoord,0,ParticleRegistry.potato);
          }
 else {
            particle=spawnFogParticle(tryPos.xCoord,groundY + 3,tryPos.zCoord,0);
          }
          particle.setScale(100);
          particle.rotationYaw=rand.nextInt(360);
          particle.rotationPitch=rand.nextInt(360);
          listParticlesGround.add(particle);
        }
      }
    }
  }
  delay=1;
  loopSize=2;
  double spawnRad=size / 48;
  if (levelCurIntensityStage >= STATE_STAGE5) {
    spawnRad=200;
    loopSize=10;
    sizeMaxFunnelParticles=1200;
  }
 else   if (levelCurIntensityStage >= STATE_STAGE4) {
    spawnRad=150;
    loopSize=8;
    sizeMaxFunnelParticles=1000;
  }
 else   if (levelCurIntensityStage >= STATE_STAGE3) {
    spawnRad=100;
    loopSize=6;
    sizeMaxFunnelParticles=800;
  }
 else   if (levelCurIntensityStage >= STATE_STAGE2) {
    spawnRad=50;
    loopSize=4;
    sizeMaxFunnelParticles=600;
  }
 else {
    sizeMaxFunnelParticles=600;
  }
  if (isTornadoFormingOrGreater() || (attrib_waterSpout)) {
    if (this.manager.getWorld().getTotalWorldTime() % (delay + ConfigStorm.Storm_ParticleSpawnDelay) == 0) {
      for (int i=0; i < loopSize; i++) {
        if (listParticlesFunnel.size() >= sizeMaxFunnelParticles) {
          listParticlesFunnel.get(0).setExpired();
          listParticlesFunnel.remove(0);
        }
        if (listParticlesFunnel.size() < sizeMaxFunnelParticles) {
          Vec3 tryPos=new Vec3(pos.xCoord + (rand.nextDouble() * spawnRad) - (rand.nextDouble() * spawnRad),pos.yCoord,pos.zCoord + (rand.nextDouble() * spawnRad) - (rand.nextDouble() * spawnRad));
          if (tryPos.distanceTo(playerAdjPos) < maxSpawnDistFromPlayer) {
            EntityRotFX particle;
            if (WeatherUtil.isAprilFoolsDay()) {
              particle=spawnFogParticle(tryPos.xCoord,posBaseFormationPos.yCoord,tryPos.zCoord,1,ParticleRegistry.potato);
            }
 else {
              if (!isFirenado) {
                particle=spawnFogParticle(tryPos.xCoord,posBaseFormationPos.yCoord,tryPos.zCoord,1);
              }
 else {
                particle=spawnFogParticle(tryPos.xCoord,posBaseFormationPos.yCoord,tryPos.zCoord,1,ParticleRegistry.cloud256_fire);
              }
            }
            particle.setMaxAge(150 + ((levelCurIntensityStage - 1) * 100) + rand.nextInt(100));
            float baseBright=0.3F;
            float randFloat=(rand.nextFloat() * 0.6F);
            particle.rotationYaw=rand.nextInt(360);
            float finalBright=Math.min(1F,baseBright + randFloat);
            if (levelCurIntensityStage == STATE_HIGHWIND) {
              particle.setScale(150);
              particle.setRBGColorF(finalBright - 0.2F,finalBright - 0.2F,finalBright);
            }
 else {
              particle.setScale(250);
              particle.setRBGColorF(finalBright,finalBright,finalBright);
            }
            if (isFirenado) {
              particle.setRBGColorF(1F,1F,1F);
            }
            listParticlesFunnel.add(particle);
          }
        }
 else {
        }
      }
    }
  }
  for (int i=0; i < listParticlesFunnel.size(); i++) {
    EntityRotFX ent=listParticlesFunnel.get(i);
    if (!ent.isAlive()) {
      listParticlesFunnel.remove(ent);
    }
 else     if (ent.getPosY() > pos.yCoord) {
      ent.setExpired();
      listParticlesFunnel.remove(ent);
    }
 else {
      double var16=this.pos.xCoord - ent.getPosX();
      double var18=this.pos.zCoord - ent.getPosZ();
      ent.rotationYaw=(float)(Math.atan2(var18,var16) * 180.0D / Math.PI) - 90.0F;
      ent.rotationYaw+=ent.getEntityId() % 90;
      ent.rotationPitch=-30F;
      if (levelCurIntensityStage == STATE_HIGHWIND) {
        int fadingDistStart=30;
        if (ent.getPosY() > posGround.yCoord + fadingDistStart) {
          float maxVal=ent.getBlueColorF();
          float fadeRate=0.002F;
          ent.setRBGColorF(Math.min(maxVal,ent.getRedColorF() + fadeRate),Math.min(maxVal,ent.getGreenColorF() + fadeRate),maxVal);
        }
      }
      spinEntity(ent);
    }
  }
  for (int i=0; i < listParticlesCloud.size(); i++) {
    EntityRotFX ent=listParticlesCloud.get(i);
    if (!ent.isAlive()) {
      listParticlesCloud.remove(ent);
    }
 else {
      double curSpeed=Math.sqrt(ent.getMotionX() * ent.getMotionX() + ent.getMotionY() * ent.getMotionY() + ent.getMotionZ() * ent.getMotionZ());
      double curDist=ent.getDistance(pos.xCoord,ent.getPosY(),pos.zCoord);
      float dropDownRange=15F;
      float extraDropCalc=0;
      if (curDist < 200 && ent.getEntityId() % 20 < 5) {
        extraDropCalc=((ent.getEntityId() % 20) * dropDownRange);
        if (isCycloneFormingOrGreater()) {
          extraDropCalc=((ent.getEntityId() % 20) * dropDownRange * 5F);
        }
      }
      if (isSpinning()) {
        double speed=spinSpeed + (rand.nextDouble() * 0.01D);
        double distt=size;
        double vecX=ent.getPosX() - pos.xCoord;
        double vecZ=ent.getPosZ() - pos.zCoord;
        float angle=(float)(Math.atan2(vecZ,vecX) * 180.0D / Math.PI);
        angle+=speed * 50D;
        angle-=(ent.getEntityId() % 10) * 3D;
        angle+=rand.nextInt(10) - rand.nextInt(10);
        if (curDist > distt) {
          angle+=40;
        }
        if (ent.getEntityId() % 20 < 5) {
          if (levelCurIntensityStage >= STATE_FORMING) {
            if (stormType == TYPE_WATER) {
              angle+=40 + ((ent.getEntityId() % 5) * 4);
              if (curDist > 150 + ((levelCurIntensityStage - levelStormIntensityFormingStartVal + 1) * 30)) {
                angle+=10;
              }
            }
 else {
              angle+=30 + ((ent.getEntityId() % 5) * 4);
            }
          }
 else {
            if (curDist > 150) {
              angle+=50 + ((ent.getEntityId() % 5) * 4);
            }
          }
          double var16=this.pos.xCoord - ent.getPosX();
          double var18=this.pos.zCoord - ent.getPosZ();
          ent.rotationYaw=(float)(Math.atan2(var18,var16) * 180.0D / Math.PI) - 90.0F;
          ent.rotationPitch=-20F - (ent.getEntityId() % 10);
        }
        if (curSpeed < speed * 20D) {
          ent.setMotionX(ent.getMotionX() + -Math.sin(Math.toRadians(angle)) * speed);
          ent.setMotionZ(ent.getMotionZ() + Math.cos(Math.toRadians(angle)) * speed);
        }
      }
 else {
        float cloudMoveAmp=0.2F * (1 + layer);
        float speed=getAdjustedSpeed() * cloudMoveAmp;
        float angle=getAdjustedAngle();
        if ((manager.getWorld().getTotalWorldTime() + this.ID) % 40 == 0) {
          ent.avoidTerrainAngle=getAvoidAngleIfTerrainAtOrAheadOfPosition(angle,ent.getPos());
        }
        angle+=ent.avoidTerrainAngle;
        if (ent.avoidTerrainAngle != 0) {
          speed*=0.5D;
        }
        dropDownRange=5;
        if (ent.getEntityId() % 20 < 5) {
          extraDropCalc=((ent.getEntityId() % 20) * dropDownRange);
        }
        if (curSpeed < speed * 1D) {
          ent.setMotionX(ent.getMotionX() + -Math.sin(Math.toRadians(angle)) * speed);
          ent.setMotionZ(ent.getMotionZ() + Math.cos(Math.toRadians(angle)) * speed);
        }
      }
      if (Math.abs(ent.getPosY() - (pos.yCoord - extraDropCalc)) > 2F) {
        if (ent.getPosY() < pos.yCoord - extraDropCalc) {
          ent.setMotionY(ent.getMotionY() + 0.1D);
        }
 else {
          ent.setMotionY(ent.getMotionY() - 0.1D);
        }
      }
      float dropDownSpeedMax=0.15F;
      if (isCycloneFormingOrGreater()) {
        dropDownSpeedMax=0.9F;
      }
      if (ent.getMotionY() < -dropDownSpeedMax) {
        ent.setMotionY(-dropDownSpeedMax);
      }
      if (ent.getMotionY() > dropDownSpeedMax) {
        ent.setMotionY(dropDownSpeedMax);
      }
    }
  }
  for (int i=0; i < listParticlesGround.size(); i++) {
    EntityRotFX ent=listParticlesGround.get(i);
    double curDist=ent.getDistance(pos.xCoord,ent.getPosY(),pos.zCoord);
    if (!ent.isAlive()) {
      listParticlesGround.remove(ent);
    }
 else {
      double curSpeed=Math.sqrt(ent.getMotionX() * ent.getMotionX() + ent.getMotionY() * ent.getMotionY() + ent.getMotionZ() * ent.getMotionZ());
      double speed=Math.max(0.2F,5F * spinSpeed) + (rand.nextDouble() * 0.01D);
      double distt=size;
      double vecX=ent.getPosX() - pos.xCoord;
      double vecZ=ent.getPosZ() - pos.zCoord;
      float angle=(float)(Math.atan2(vecZ,vecX) * 180.0D / Math.PI);
      angle+=85;
      int maxParticleSize=60;
      if (stormType == TYPE_WATER) {
        maxParticleSize=150;
        speed/=5D;
      }
      ent.setScale((float)Math.min(maxParticleSize,curDist * 2F));
      if (curDist < 20) {
        ent.setExpired();
      }
      double var16=this.pos.xCoord - ent.getPosX();
      double var18=this.pos.zCoord - ent.getPosZ();
      if (curSpeed < speed * 20D) {
        ent.setMotionX(ent.getMotionX() + -Math.sin(Math.toRadians(angle)) * speed);
        ent.setMotionZ(ent.getMotionZ() + Math.cos(Math.toRadians(angle)) * speed);
      }
    }
  }
}