Program: 81834
Project: 81834
Buggy source:
/** 
 * Manages transitioning fog densities and color from current vanilla settings to our desired settings, and vice versa
 */
public static void tickSandstorm(){
  if (adjustAmountTargetPocketSandOverride > 0) {
    adjustAmountTargetPocketSandOverride-=0.01F;
  }
  Minecraft mc=Minecraft.getMinecraft();
  EntityPlayer player=mc.player;
  World world=mc.world;
  Vec3 posPlayer=new Vec3(mc.player.posX,0,mc.player.posZ);
  WeatherObjectSandstorm sandstorm=ClientTickHandler.weatherManager.getClosestSandstormByIntensity(posPlayer);
  WindManager windMan=ClientTickHandler.weatherManager.getWindManager();
  float scaleIntensityTarget=0F;
  if (sandstorm != null) {
    if (mc.world.getTotalWorldTime() % 40 == 0) {
      isPlayerOutside=WeatherUtilEntity.isEntityOutside(mc.player);
    }
    scaleIntensityTarget=sandstorm.getSandstormScale();
    List<Vec3> points=sandstorm.getSandstormAsShape();
    boolean inStorm=CoroUtilPhysics.isInConvexShape(posPlayer,points);
    if (inStorm) {
      distToStorm=0;
    }
 else {
      distToStorm=CoroUtilPhysics.getDistanceToShape(posPlayer,points);
    }
  }
 else {
    distToStorm=distToStormThreshold + 10;
  }
  scaleIntensitySmooth=adjVal(scaleIntensitySmooth,scaleIntensityTarget,0.01F);
  float fogColorChangeRate=0.01F;
  float fogDistChangeRate=2F;
  float fogDensityChangeRate=0.01F;
  adjustAmountTarget=1F - (float)((distToStorm) / distToStormThreshold);
  adjustAmountTarget*=2F * scaleIntensitySmooth * (isPlayerOutside ? 1F : 0.5F);
  boolean pocketSandOverride=false;
  if (adjustAmountTarget < adjustAmountTargetPocketSandOverride) {
    adjustAmountTarget=adjustAmountTargetPocketSandOverride;
    pocketSandOverride=true;
  }
  if (adjustAmountTarget < 0F)   adjustAmountTarget=0F;
  if (adjustAmountTarget > 1F)   adjustAmountTarget=1F;
  float sunBrightness=mc.world.getSunBrightness(1F) * 1F;
  if (!pocketSandOverride) {
    if (adjustAmountSmooth < adjustAmountTarget) {
      adjustAmountSmooth=CoroUtilMisc.adjVal(adjustAmountSmooth,adjustAmountTarget,0.003F);
    }
 else {
      adjustAmountSmooth=CoroUtilMisc.adjVal(adjustAmountSmooth,adjustAmountTarget,0.002F);
    }
  }
 else {
    adjustAmountSmooth=CoroUtilMisc.adjVal(adjustAmountSmooth,adjustAmountTarget,0.02F);
  }
  RotatingParticleManager.sandstormFogAmount=adjustAmountSmooth;
  if (mc.world.getTotalWorldTime() % 20 == 0) {
    if (adjustAmountSmooth > 0) {
    }
  }
  if (adjustAmountSmooth > 0) {
    if (needFogState) {
      try {
        Object fogState=ObfuscationReflectionHelper.getPrivateValue(GlStateManager.class,null,"String_Node_Str");
        Class<?> innerClass=Class.forName("String_Node_Str");
        Field fieldDensity=null;
        Field fieldStart=null;
        Field fieldEnd=null;
        try {
          fieldDensity=innerClass.getField("String_Node_Str");
          fieldDensity.setAccessible(true);
          fieldStart=innerClass.getField("String_Node_Str");
          fieldStart.setAccessible(true);
          fieldEnd=innerClass.getField("String_Node_Str");
          fieldEnd.setAccessible(true);
        }
 catch (        Exception e) {
          fieldDensity=innerClass.getField("String_Node_Str");
          fieldDensity.setAccessible(true);
          fieldStart=innerClass.getField("String_Node_Str");
          fieldStart.setAccessible(true);
          fieldEnd=innerClass.getField("String_Node_Str");
          fieldEnd.setAccessible(true);
        }
        stormFogDensity=fieldDensity.getFloat(fogState);
        stormFogStart=fieldStart.getFloat(fogState);
        stormFogEnd=fieldEnd.getFloat(fogState);
        stormFogStartClouds=0;
        stormFogEndClouds=192;
        stormFogStartOrig=stormFogStart;
        stormFogEndOrig=stormFogEnd;
        stormFogStartCloudsOrig=stormFogStartClouds;
        stormFogEndCloudsOrig=stormFogEndClouds;
        stormFogDensityOrig=stormFogDensity;
      }
 catch (      Exception e) {
        e.printStackTrace();
      }
      needFogState=false;
    }
    stormFogRed=stormFogRedOrig + (-(stormFogRedOrig - (0.7F * sunBrightness)) * adjustAmountSmooth);
    stormFogGreen=stormFogGreenOrig + (-(stormFogGreenOrig - (0.5F * sunBrightness)) * adjustAmountSmooth);
    stormFogBlue=stormFogBlueOrig + (-(stormFogBlueOrig - (0.25F * sunBrightness)) * adjustAmountSmooth);
    stormFogDensity=stormFogDensityOrig + (-(stormFogDensityOrig - 0.02F) * adjustAmountSmooth);
    stormFogStart=stormFogStartOrig + (-(stormFogStartOrig - 0F) * adjustAmountSmooth);
    stormFogEnd=stormFogEndOrig + (-(stormFogEndOrig - 7F) * adjustAmountSmooth);
    stormFogStartClouds=stormFogStartCloudsOrig + (-(stormFogStartCloudsOrig - 0F) * adjustAmountSmooth);
    stormFogEndClouds=stormFogEndCloudsOrig + (-(stormFogEndCloudsOrig - 20F) * adjustAmountSmooth);
  }
 else {
    if (!needFogState) {
    }
    needFogState=true;
  }
  if (adjustAmountSmooth > 0.75F && sandstorm != null) {
    Vec3 windForce=windMan.getWindForce();
    Random rand=mc.world.rand;
    int spawnAreaSize=80;
    double sandstormParticleRateDebris=ConfigParticle.Sandstorm_Particle_Debris_effect_rate;
    double sandstormParticleRateDust=ConfigParticle.Sandstorm_Particle_Dust_effect_rate;
    float adjustAmountSmooth75=(adjustAmountSmooth * 8F) - 7F;
    for (int i=0; i < ((float)30 * adjustAmountSmooth75 * sandstormParticleRateDust); i++) {
      BlockPos pos=new BlockPos(player.posX + rand.nextInt(spawnAreaSize) - (spawnAreaSize / 2),player.posY - 2 + rand.nextInt(10),player.posZ + rand.nextInt(spawnAreaSize) - (spawnAreaSize / 2));
      if (canPrecipitateAt(world,pos)) {
        TextureAtlasSprite sprite=ParticleRegistry.cloud256;
        ParticleSandstorm part=new ParticleSandstorm(world,pos.getX(),pos.getY(),pos.getZ(),0,0,0,sprite);
        particleBehavior.initParticle(part);
        part.setMotionX(windForce.xCoord);
        part.setMotionZ(windForce.zCoord);
        part.setFacePlayer(false);
        part.isTransparent=true;
        part.rotationYaw=(float)rand.nextInt(360);
        part.rotationPitch=(float)rand.nextInt(360);
        part.setMaxAge(40);
        part.setGravity(0.09F);
        part.setAlphaF(0F);
        float brightnessMulti=1F - (rand.nextFloat() * 0.5F);
        part.setRBGColorF(0.65F * brightnessMulti,0.6F * brightnessMulti,0.3F * brightnessMulti);
        part.setScale(40);
        part.aboveGroundHeight=0.2D;
        part.setKillOnCollide(true);
        part.windWeight=1F;
        particleBehavior.particles.add(part);
        ClientTickHandler.weatherManager.addWeatheredParticle(part);
        part.spawnAsWeatherEffect();
      }
    }
    for (int i=0; i < ((float)1 * adjustAmountSmooth75 * sandstormParticleRateDebris); i++) {
      BlockPos pos=new BlockPos(player.posX + rand.nextInt(spawnAreaSize) - (spawnAreaSize / 2),player.posY - 2 + rand.nextInt(10),player.posZ + rand.nextInt(spawnAreaSize) - (spawnAreaSize / 2));
      if (canPrecipitateAt(world,pos)) {
        TextureAtlasSprite sprite=ParticleRegistry.tumbleweed;
        ParticleSandstorm part=new ParticleSandstorm(world,pos.getX(),pos.getY(),pos.getZ(),0,0,0,sprite);
        particleBehavior.initParticle(part);
        part.setMotionX(windForce.xCoord);
        part.setMotionZ(windForce.zCoord);
        part.setFacePlayer(true);
        part.isTransparent=true;
        part.rotationYaw=(float)rand.nextInt(360);
        part.rotationPitch=(float)rand.nextInt(360);
        part.setMaxAge(80);
        part.setGravity(0.3F);
        part.setAlphaF(0F);
        float brightnessMulti=1F - (rand.nextFloat() * 0.2F);
        part.setRBGColorF(1F * brightnessMulti,1F * brightnessMulti,1F * brightnessMulti);
        part.setScale(8);
        part.aboveGroundHeight=0.5D;
        part.collisionSpeedDampen=false;
        part.bounceSpeed=0.03D;
        part.bounceSpeedAhead=0.03D;
        part.setKillOnCollide(false);
        part.windWeight=1F;
        particleBehavior.particles.add(part);
        ClientTickHandler.weatherManager.addWeatheredParticle(part);
        part.spawnAsWeatherEffect();
      }
    }
    for (int i=0; i < ((float)8 * adjustAmountSmooth75 * sandstormParticleRateDebris); i++) {
      BlockPos pos=new BlockPos(player.posX + rand.nextInt(spawnAreaSize) - (spawnAreaSize / 2),player.posY - 2 + rand.nextInt(10),player.posZ + rand.nextInt(spawnAreaSize) - (spawnAreaSize / 2));
      if (canPrecipitateAt(world,pos)) {
        TextureAtlasSprite sprite=null;
        int tex=rand.nextInt(3);
        if (tex == 0) {
          sprite=ParticleRegistry.debris_1;
        }
 else         if (tex == 1) {
          sprite=ParticleRegistry.debris_2;
        }
 else         if (tex == 2) {
          sprite=ParticleRegistry.debris_3;
        }
        ParticleSandstorm part=new ParticleSandstorm(world,pos.getX(),pos.getY(),pos.getZ(),0,0,0,sprite);
        particleBehavior.initParticle(part);
        part.setMotionX(windForce.xCoord);
        part.setMotionZ(windForce.zCoord);
        part.setFacePlayer(false);
        part.spinFast=true;
        part.isTransparent=true;
        part.rotationYaw=(float)rand.nextInt(360);
        part.rotationPitch=(float)rand.nextInt(360);
        part.setMaxAge(80);
        part.setGravity(0.3F);
        part.setAlphaF(0F);
        float brightnessMulti=1F - (rand.nextFloat() * 0.5F);
        part.setRBGColorF(1F * brightnessMulti,1F * brightnessMulti,1F * brightnessMulti);
        part.setScale(8);
        part.aboveGroundHeight=0.5D;
        part.collisionSpeedDampen=false;
        part.bounceSpeed=0.03D;
        part.bounceSpeedAhead=0.03D;
        part.setKillOnCollide(false);
        part.windWeight=1F;
        particleBehavior.particles.add(part);
        ClientTickHandler.weatherManager.addWeatheredParticle(part);
        part.spawnAsWeatherEffect();
      }
    }
  }
  tickSandstormSound();
}

Fixed version (ground truth):
/** 
 * Manages transitioning fog densities and color from current vanilla settings to our desired settings, and vice versa
 */
public static void tickSandstorm(){
  if (adjustAmountTargetPocketSandOverride > 0) {
    adjustAmountTargetPocketSandOverride-=0.01F;
  }
  Minecraft mc=Minecraft.getMinecraft();
  EntityPlayer player=mc.player;
  World world=mc.world;
  Vec3 posPlayer=new Vec3(mc.player.posX,0,mc.player.posZ);
  WeatherObjectSandstorm sandstorm=ClientTickHandler.weatherManager.getClosestSandstormByIntensity(posPlayer);
  WindManager windMan=ClientTickHandler.weatherManager.getWindManager();
  float scaleIntensityTarget=0F;
  if (sandstorm != null) {
    if (mc.world.getTotalWorldTime() % 40 == 0) {
      isPlayerOutside=WeatherUtilEntity.isEntityOutside(mc.player);
    }
    scaleIntensityTarget=sandstorm.getSandstormScale();
    List<Vec3> points=sandstorm.getSandstormAsShape();
    boolean inStorm=CoroUtilPhysics.isInConvexShape(posPlayer,points);
    if (inStorm) {
      distToStorm=0;
    }
 else {
      distToStorm=CoroUtilPhysics.getDistanceToShape(posPlayer,points);
    }
  }
 else {
    distToStorm=distToStormThreshold + 10;
  }
  scaleIntensitySmooth=adjVal(scaleIntensitySmooth,scaleIntensityTarget,0.01F);
  float fogColorChangeRate=0.01F;
  float fogDistChangeRate=2F;
  float fogDensityChangeRate=0.01F;
  adjustAmountTarget=1F - (float)((distToStorm) / distToStormThreshold);
  adjustAmountTarget*=2F * scaleIntensitySmooth * (isPlayerOutside ? 1F : 0.5F);
  boolean pocketSandOverride=false;
  if (adjustAmountTarget < adjustAmountTargetPocketSandOverride) {
    adjustAmountTarget=adjustAmountTargetPocketSandOverride;
    pocketSandOverride=true;
  }
  if (adjustAmountTarget < 0F)   adjustAmountTarget=0F;
  if (adjustAmountTarget > 1F)   adjustAmountTarget=1F;
  float sunBrightness=mc.world.getSunBrightness(1F) * 1F;
  if (!pocketSandOverride) {
    if (adjustAmountSmooth < adjustAmountTarget) {
      adjustAmountSmooth=CoroUtilMisc.adjVal(adjustAmountSmooth,adjustAmountTarget,0.003F);
    }
 else {
      adjustAmountSmooth=CoroUtilMisc.adjVal(adjustAmountSmooth,adjustAmountTarget,0.002F);
    }
  }
 else {
    adjustAmountSmooth=CoroUtilMisc.adjVal(adjustAmountSmooth,adjustAmountTarget,0.02F);
  }
  EventHandler.sandstormFogAmount=adjustAmountSmooth;
  if (mc.world.getTotalWorldTime() % 20 == 0) {
    if (adjustAmountSmooth > 0) {
    }
  }
  if (adjustAmountSmooth > 0) {
    if (needFogState) {
      try {
        Object fogState=ObfuscationReflectionHelper.getPrivateValue(GlStateManager.class,null,"String_Node_Str");
        Class<?> innerClass=Class.forName("String_Node_Str");
        Field fieldDensity=null;
        Field fieldStart=null;
        Field fieldEnd=null;
        try {
          fieldDensity=innerClass.getField("String_Node_Str");
          fieldDensity.setAccessible(true);
          fieldStart=innerClass.getField("String_Node_Str");
          fieldStart.setAccessible(true);
          fieldEnd=innerClass.getField("String_Node_Str");
          fieldEnd.setAccessible(true);
        }
 catch (        Exception e) {
          fieldDensity=innerClass.getField("String_Node_Str");
          fieldDensity.setAccessible(true);
          fieldStart=innerClass.getField("String_Node_Str");
          fieldStart.setAccessible(true);
          fieldEnd=innerClass.getField("String_Node_Str");
          fieldEnd.setAccessible(true);
        }
        stormFogDensity=fieldDensity.getFloat(fogState);
        stormFogStart=fieldStart.getFloat(fogState);
        stormFogEnd=fieldEnd.getFloat(fogState);
        stormFogStartClouds=0;
        stormFogEndClouds=192;
        stormFogStartOrig=stormFogStart;
        stormFogEndOrig=stormFogEnd;
        stormFogStartCloudsOrig=stormFogStartClouds;
        stormFogEndCloudsOrig=stormFogEndClouds;
        stormFogDensityOrig=stormFogDensity;
      }
 catch (      Exception e) {
        e.printStackTrace();
      }
      needFogState=false;
    }
    stormFogRed=stormFogRedOrig + (-(stormFogRedOrig - (0.7F * sunBrightness)) * adjustAmountSmooth);
    stormFogGreen=stormFogGreenOrig + (-(stormFogGreenOrig - (0.5F * sunBrightness)) * adjustAmountSmooth);
    stormFogBlue=stormFogBlueOrig + (-(stormFogBlueOrig - (0.25F * sunBrightness)) * adjustAmountSmooth);
    stormFogDensity=stormFogDensityOrig + (-(stormFogDensityOrig - 0.02F) * adjustAmountSmooth);
    stormFogStart=stormFogStartOrig + (-(stormFogStartOrig - 0F) * adjustAmountSmooth);
    stormFogEnd=stormFogEndOrig + (-(stormFogEndOrig - 7F) * adjustAmountSmooth);
    stormFogStartClouds=stormFogStartCloudsOrig + (-(stormFogStartCloudsOrig - 0F) * adjustAmountSmooth);
    stormFogEndClouds=stormFogEndCloudsOrig + (-(stormFogEndCloudsOrig - 20F) * adjustAmountSmooth);
  }
 else {
    if (!needFogState) {
    }
    needFogState=true;
  }
  if (adjustAmountSmooth > 0.75F && sandstorm != null) {
    Vec3 windForce=windMan.getWindForce();
    Random rand=mc.world.rand;
    int spawnAreaSize=80;
    double sandstormParticleRateDebris=ConfigParticle.Sandstorm_Particle_Debris_effect_rate;
    double sandstormParticleRateDust=ConfigParticle.Sandstorm_Particle_Dust_effect_rate;
    float adjustAmountSmooth75=(adjustAmountSmooth * 8F) - 7F;
    for (int i=0; i < ((float)30 * adjustAmountSmooth75 * sandstormParticleRateDust); i++) {
      BlockPos pos=new BlockPos(player.posX + rand.nextInt(spawnAreaSize) - (spawnAreaSize / 2),player.posY - 2 + rand.nextInt(10),player.posZ + rand.nextInt(spawnAreaSize) - (spawnAreaSize / 2));
      if (canPrecipitateAt(world,pos)) {
        TextureAtlasSprite sprite=ParticleRegistry.cloud256;
        ParticleSandstorm part=new ParticleSandstorm(world,pos.getX(),pos.getY(),pos.getZ(),0,0,0,sprite);
        particleBehavior.initParticle(part);
        part.setMotionX(windForce.xCoord);
        part.setMotionZ(windForce.zCoord);
        part.setFacePlayer(false);
        part.isTransparent=true;
        part.rotationYaw=(float)rand.nextInt(360);
        part.rotationPitch=(float)rand.nextInt(360);
        part.setMaxAge(40);
        part.setGravity(0.09F);
        part.setAlphaF(0F);
        float brightnessMulti=1F - (rand.nextFloat() * 0.5F);
        part.setRBGColorF(0.65F * brightnessMulti,0.6F * brightnessMulti,0.3F * brightnessMulti);
        part.setScale(40);
        part.aboveGroundHeight=0.2D;
        part.setKillOnCollide(true);
        part.windWeight=1F;
        particleBehavior.particles.add(part);
        ClientTickHandler.weatherManager.addWeatheredParticle(part);
        part.spawnAsWeatherEffect();
      }
    }
    for (int i=0; i < ((float)1 * adjustAmountSmooth75 * sandstormParticleRateDebris); i++) {
      BlockPos pos=new BlockPos(player.posX + rand.nextInt(spawnAreaSize) - (spawnAreaSize / 2),player.posY - 2 + rand.nextInt(10),player.posZ + rand.nextInt(spawnAreaSize) - (spawnAreaSize / 2));
      if (canPrecipitateAt(world,pos)) {
        TextureAtlasSprite sprite=ParticleRegistry.tumbleweed;
        ParticleSandstorm part=new ParticleSandstorm(world,pos.getX(),pos.getY(),pos.getZ(),0,0,0,sprite);
        particleBehavior.initParticle(part);
        part.setMotionX(windForce.xCoord);
        part.setMotionZ(windForce.zCoord);
        part.setFacePlayer(true);
        part.isTransparent=true;
        part.rotationYaw=(float)rand.nextInt(360);
        part.rotationPitch=(float)rand.nextInt(360);
        part.setMaxAge(80);
        part.setGravity(0.3F);
        part.setAlphaF(0F);
        float brightnessMulti=1F - (rand.nextFloat() * 0.2F);
        part.setRBGColorF(1F * brightnessMulti,1F * brightnessMulti,1F * brightnessMulti);
        part.setScale(8);
        part.aboveGroundHeight=0.5D;
        part.collisionSpeedDampen=false;
        part.bounceSpeed=0.03D;
        part.bounceSpeedAhead=0.03D;
        part.setKillOnCollide(false);
        part.windWeight=1F;
        particleBehavior.particles.add(part);
        ClientTickHandler.weatherManager.addWeatheredParticle(part);
        part.spawnAsWeatherEffect();
      }
    }
    for (int i=0; i < ((float)8 * adjustAmountSmooth75 * sandstormParticleRateDebris); i++) {
      BlockPos pos=new BlockPos(player.posX + rand.nextInt(spawnAreaSize) - (spawnAreaSize / 2),player.posY - 2 + rand.nextInt(10),player.posZ + rand.nextInt(spawnAreaSize) - (spawnAreaSize / 2));
      if (canPrecipitateAt(world,pos)) {
        TextureAtlasSprite sprite=null;
        int tex=rand.nextInt(3);
        if (tex == 0) {
          sprite=ParticleRegistry.debris_1;
        }
 else         if (tex == 1) {
          sprite=ParticleRegistry.debris_2;
        }
 else         if (tex == 2) {
          sprite=ParticleRegistry.debris_3;
        }
        ParticleSandstorm part=new ParticleSandstorm(world,pos.getX(),pos.getY(),pos.getZ(),0,0,0,sprite);
        particleBehavior.initParticle(part);
        part.setMotionX(windForce.xCoord);
        part.setMotionZ(windForce.zCoord);
        part.setFacePlayer(false);
        part.spinFast=true;
        part.isTransparent=true;
        part.rotationYaw=(float)rand.nextInt(360);
        part.rotationPitch=(float)rand.nextInt(360);
        part.setMaxAge(80);
        part.setGravity(0.3F);
        part.setAlphaF(0F);
        float brightnessMulti=1F - (rand.nextFloat() * 0.5F);
        part.setRBGColorF(1F * brightnessMulti,1F * brightnessMulti,1F * brightnessMulti);
        part.setScale(8);
        part.aboveGroundHeight=0.5D;
        part.collisionSpeedDampen=false;
        part.bounceSpeed=0.03D;
        part.bounceSpeedAhead=0.03D;
        part.setKillOnCollide(false);
        part.windWeight=1F;
        particleBehavior.particles.add(part);
        ClientTickHandler.weatherManager.addWeatheredParticle(part);
        part.spawnAsWeatherEffect();
      }
    }
  }
  tickSandstormSound();
}