Program: 81907
Project: 81907
Buggy source:
/** 
 * Manages transitioning fog densities and color from current vanilla settings to our desired settings, and vice versa
 */
public static void tickSandstorm(){
  Minecraft mc=Minecraft.getMinecraft();
  EntityPlayer player=mc.thePlayer;
  World world=mc.theWorld;
  Vec3 posPlayer=new Vec3(mc.thePlayer.posX,0,mc.thePlayer.posZ);
  WeatherObjectSandstorm sandstorm=ClientTickHandler.weatherManager.getClosestSandstormByIntensity(posPlayer);
  WindManager windMan=ClientTickHandler.weatherManager.getWindManager();
  float scaleIntensityTarget=0F;
  if (sandstorm != null) {
    if (mc.theWorld.getTotalWorldTime() % 40 == 0) {
      isPlayerOutside=WeatherUtilEntity.isEntityOutside(mc.thePlayer);
    }
    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);
  if (adjustAmountTarget < 0F)   adjustAmountTarget=0F;
  if (adjustAmountTarget > 1F)   adjustAmountTarget=1F;
  adjustAmountTarget=1F;
  float sunBrightness=mc.theWorld.getSunBrightness(1F);
  if (adjustAmountSmooth < adjustAmountTarget) {
    adjustAmountSmooth=CoroUtilMisc.adjVal(adjustAmountSmooth,adjustAmountTarget,0.003F);
  }
 else {
    adjustAmountSmooth=CoroUtilMisc.adjVal(adjustAmountSmooth,adjustAmountTarget,0.002F);
  }
  RotatingParticleManager.sandstormFogAmount=adjustAmountSmooth;
  if (mc.theWorld.getTotalWorldTime() % 20 == 0) {
    if (adjustAmountSmooth > 0) {
      System.out.println("String_Node_Str" + adjustAmountTarget);
      System.out.println("String_Node_Str" + adjustAmountSmooth);
    }
  }
  if (adjustAmountSmooth > 0) {
    if (needFogState) {
      stormFogRed=ObfuscationReflectionHelper.getPrivateValue(EntityRenderer.class,Minecraft.getMinecraft().entityRenderer,"String_Node_Str");
      stormFogGreen=ObfuscationReflectionHelper.getPrivateValue(EntityRenderer.class,Minecraft.getMinecraft().entityRenderer,"String_Node_Str");
      stormFogBlue=ObfuscationReflectionHelper.getPrivateValue(EntityRenderer.class,Minecraft.getMinecraft().entityRenderer,"String_Node_Str");
      if (stormFogRed == 0 && stormFogGreen == 0 && stormFogBlue == 0) {
        stormFogRed=0.7225088F;
        stormFogGreen=0.8253213F;
        stormFogBlue=1F;
      }
      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.6F * sunBrightness)) * adjustAmountSmooth);
    stormFogBlue=stormFogBlueOrig + (-(stormFogBlueOrig - (0.3F * sunBrightness)) * adjustAmountSmooth);
    stormFogDensity=stormFogDensityOrig + (-(stormFogDensityOrig - 0.5F) * 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) {
    Vec3 windForce=windMan.getWindForce();
    Random rand=mc.theWorld.rand;
    int spawnAreaSize=80;
    float adjustAmountSmooth75=(adjustAmountSmooth * 8F) - 7F;
    for (int i=0; i < ((float)30 * adjustAmountSmooth75); 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 (isSnowingAt(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); 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 (isSnowingAt(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)12 * adjustAmountSmooth75); 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 (isSnowingAt(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(){
  Minecraft mc=Minecraft.getMinecraft();
  EntityPlayer player=mc.thePlayer;
  World world=mc.theWorld;
  Vec3 posPlayer=new Vec3(mc.thePlayer.posX,0,mc.thePlayer.posZ);
  WeatherObjectSandstorm sandstorm=ClientTickHandler.weatherManager.getClosestSandstormByIntensity(posPlayer);
  WindManager windMan=ClientTickHandler.weatherManager.getWindManager();
  float scaleIntensityTarget=0F;
  if (sandstorm != null) {
    if (mc.theWorld.getTotalWorldTime() % 40 == 0) {
      isPlayerOutside=WeatherUtilEntity.isEntityOutside(mc.thePlayer);
    }
    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);
  if (adjustAmountTarget < 0F)   adjustAmountTarget=0F;
  if (adjustAmountTarget > 1F)   adjustAmountTarget=1F;
  float sunBrightness=mc.theWorld.getSunBrightness(1F);
  if (adjustAmountSmooth < adjustAmountTarget) {
    adjustAmountSmooth=CoroUtilMisc.adjVal(adjustAmountSmooth,adjustAmountTarget,0.003F);
  }
 else {
    adjustAmountSmooth=CoroUtilMisc.adjVal(adjustAmountSmooth,adjustAmountTarget,0.002F);
  }
  RotatingParticleManager.sandstormFogAmount=adjustAmountSmooth;
  if (mc.theWorld.getTotalWorldTime() % 20 == 0) {
    if (adjustAmountSmooth > 0) {
      System.out.println("String_Node_Str" + adjustAmountTarget);
      System.out.println("String_Node_Str" + adjustAmountSmooth);
    }
  }
  if (adjustAmountSmooth > 0) {
    if (needFogState) {
      stormFogRed=ObfuscationReflectionHelper.getPrivateValue(EntityRenderer.class,Minecraft.getMinecraft().entityRenderer,"String_Node_Str");
      stormFogGreen=ObfuscationReflectionHelper.getPrivateValue(EntityRenderer.class,Minecraft.getMinecraft().entityRenderer,"String_Node_Str");
      stormFogBlue=ObfuscationReflectionHelper.getPrivateValue(EntityRenderer.class,Minecraft.getMinecraft().entityRenderer,"String_Node_Str");
      if (stormFogRed == 0 && stormFogGreen == 0 && stormFogBlue == 0) {
        stormFogRed=0.7225088F;
        stormFogGreen=0.8253213F;
        stormFogBlue=1F;
      }
      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.6F * sunBrightness)) * adjustAmountSmooth);
    stormFogBlue=stormFogBlueOrig + (-(stormFogBlueOrig - (0.3F * sunBrightness)) * adjustAmountSmooth);
    stormFogDensity=stormFogDensityOrig + (-(stormFogDensityOrig - 0.5F) * 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) {
    Vec3 windForce=windMan.getWindForce();
    Random rand=mc.theWorld.rand;
    int spawnAreaSize=80;
    float adjustAmountSmooth75=(adjustAmountSmooth * 8F) - 7F;
    for (int i=0; i < ((float)30 * adjustAmountSmooth75); 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 (isSnowingAt(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); 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 (isSnowingAt(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)12 * adjustAmountSmooth75); 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 (isSnowingAt(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();
}