Program: 171526
Project: 171526
Buggy source:
@Override public void onUpdate(){
  super.onUpdate();
  boolean canDrive=(getEngineTemperature() > 70 && getTurnedOn() && Config.isFuelRequired(gauge));
  if (world.isRemote) {
    boolean hasFuel=(this.getLiquidAmount() > 0 || !Config.isFuelRequired(gauge));
    if (ConfigSound.soundEnabled) {
      if (this.horn == null) {
        this.horn=ImmersiveRailroading.proxy.newSound(this.getDefinition().horn,false,100,gauge);
        this.idle=ImmersiveRailroading.proxy.newSound(this.getDefinition().idle,true,80,gauge);
      }
      if (hasFuel) {
        if (!idle.isPlaying() && getTurnedOn()) {
          this.idle.play(getPositionVector());
        }
 else         if (!idle.isPlaying()) {
          this.idle.play(getPositionVector());
        }
        if (idle.isPlaying() && !getTurnedOn()) {
          idle.stop();
        }
      }
 else {
        if (idle.isPlaying()) {
          idle.stop();
        }
      }
      if (this.getDataManager().get(HORN) != 0 && !horn.isPlaying()) {
        horn.play(getPositionVector());
      }
      float absThrottle=Math.abs(this.getThrottle());
      if (this.soundThrottle > absThrottle && canDrive) {
        this.soundThrottle-=Math.min(0.01f,this.soundThrottle - absThrottle);
      }
 else       if (this.soundThrottle < absThrottle && canDrive) {
        this.soundThrottle+=Math.min(0.01f,absThrottle - this.soundThrottle);
      }
 else       if (!Config.isFuelRequired(gauge)) {
        if (this.soundThrottle > absThrottle) {
          this.soundThrottle-=Math.min(0.01f,this.soundThrottle - absThrottle);
        }
 else         if (this.soundThrottle < absThrottle) {
          this.soundThrottle+=Math.min(0.01f,absThrottle - this.soundThrottle);
        }
      }
      if (horn.isPlaying()) {
        horn.setPosition(getPositionVector());
        horn.setVelocity(getVelocity());
        horn.update();
      }
      if (idle.isPlaying()) {
        idle.setPitch(0.7f + this.soundThrottle / 4);
        idle.setVolume(Math.max(0.1f,this.soundThrottle));
        idle.setPosition(getPositionVector());
        idle.setVelocity(getVelocity());
        idle.update();
      }
    }
    if (!ConfigGraphics.particlesEnabled) {
      return;
    }
    Vec3d fakeMotion=new Vec3d(this.motionX,this.motionY,this.motionZ);
    List<RenderComponent> exhausts=this.getDefinition().getComponents(RenderComponentType.DIESEL_EXHAUST_X,gauge);
    float throttle=Math.abs(this.getThrottle());
    if (exhausts != null && throttle > 0 && hasFuel && getEngineTemperature() > 70 && getTurnedOn()) {
      for (      RenderComponent exhaust : exhausts) {
        Vec3d particlePos=this.getPositionVector().add(VecUtil.rotateYaw(exhaust.center(),this.rotationYaw + 180)).addVector(0,0.35 * gauge.scale(),0);
        double smokeMod=(1 + Math.min(1,Math.max(0.2,Math.abs(this.getCurrentSpeed().minecraft()) * 2))) / 2;
        EntitySmokeParticle sp=new EntitySmokeParticle(world,(int)(40 * (1 + throttle) * smokeMod),throttle,throttle,exhaust.width());
        particlePos=particlePos.subtract(fakeMotion);
        sp.setPosition(particlePos.x,particlePos.y,particlePos.z);
        sp.setVelocity(fakeMotion.x,fakeMotion.y + 0.4 * gauge.scale(),fakeMotion.z);
        world.spawnEntity(sp);
      }
    }
    return;
  }
  if (this.getLiquidAmount() > 0) {
    float burnTime=BurnUtil.getBurnTime(this.getLiquid());
    if (burnTime == 0) {
      burnTime=200;
    }
    burnTime*=getDefinition().getFuelEfficiency() / 100f;
    burnTime*=(Config.ConfigBalance.locoDieselFuelEfficiency / 100f);
    float heatUpSpeed=0.0029167f * Config.ConfigBalance.dieselLocoHeatTimeScale;
    if (getTurnedOn()) {
      if (getEngineTemperature() < 73 && this.getLiquidAmount() > 0) {
        while (internalBurn < 0 && this.getLiquidAmount() > 0) {
          internalBurn+=burnTime;
          setEngineTemperature(getEngineTemperature() + heatUpSpeed);
          theTank.drain(1,true);
        }
      }
      if (getEngineTemperature() > 150) {
        setEngineTemperature(150);
      }
      if (this.getCurrentSpeed().metric() < 10 && getEngineTemperature() > 70) {
        setEngineTemperature(getEngineTemperature() - 0.02f);
      }
    }
 else {
      if (getEngineTemperature() > 0) {
        setEngineTemperature(getEngineTemperature() - 0.02f);
      }
 else {
        setEngineTemperature(0);
      }
    }
    if (getEngineTemperature() > 70 && getTurnedOn() && this.getCurrentSpeed().metric() > 10) {
      setEngineTemperature(getEngineTemperature() + (float)((heatUpSpeed / 2000) * this.getCurrentSpeed().metric()));
    }
    if (getEngineTemperature() == 150 && Config.ConfigDamage.canEnginesOverheat) {
      setEngineOverheated(true);
    }
    if (getEngineOverheated() && getEngineTemperature() == 0 && this.getCurrentSpeed().metric() == 0) {
      setEngineOverheated(false);
    }
    float consumption=Math.abs(getThrottle()) + 0.05f;
    consumption*=100;
    consumption*=gauge.scale();
    internalBurn-=consumption;
    if (canTurnOnOff == false) {
      tick++;
      if (tick == turnOnOffDelay) {
        tick=0;
        canTurnOnOff=true;
      }
    }
  }
}

Fixed version (ground truth):
@Override public void onUpdate(){
  super.onUpdate();
  boolean canDrive=(getEngineTemperature() > 70 && getTurnedOn() && Config.isFuelRequired(gauge));
  if (world.isRemote) {
    boolean hasFuel=(this.getLiquidAmount() > 0 || !Config.isFuelRequired(gauge));
    if (ConfigSound.soundEnabled) {
      if (this.horn == null) {
        this.horn=ImmersiveRailroading.proxy.newSound(this.getDefinition().horn,false,100,gauge);
        this.idle=ImmersiveRailroading.proxy.newSound(this.getDefinition().idle,true,80,gauge);
      }
      if (hasFuel) {
        if (!idle.isPlaying() && getTurnedOn()) {
          this.idle.play(getPositionVector());
        }
 else         if (!idle.isPlaying() && !getTurnedOn()) {
          this.idle.play(getPositionVector());
        }
        if (idle.isPlaying() && !getTurnedOn()) {
          idle.stop();
        }
      }
 else {
        if (idle.isPlaying()) {
          idle.stop();
        }
      }
      if (this.getDataManager().get(HORN) != 0 && !horn.isPlaying()) {
        horn.play(getPositionVector());
      }
      float absThrottle=Math.abs(this.getThrottle());
      if (this.soundThrottle > absThrottle && canDrive) {
        this.soundThrottle-=Math.min(0.01f,this.soundThrottle - absThrottle);
      }
 else       if (this.soundThrottle < absThrottle && canDrive) {
        this.soundThrottle+=Math.min(0.01f,absThrottle - this.soundThrottle);
      }
 else       if (!Config.isFuelRequired(gauge)) {
        if (this.soundThrottle > absThrottle) {
          this.soundThrottle-=Math.min(0.01f,this.soundThrottle - absThrottle);
        }
 else         if (this.soundThrottle < absThrottle) {
          this.soundThrottle+=Math.min(0.01f,absThrottle - this.soundThrottle);
        }
      }
      if (horn.isPlaying()) {
        horn.setPosition(getPositionVector());
        horn.setVelocity(getVelocity());
        horn.update();
      }
      if (idle.isPlaying()) {
        idle.setPitch(0.7f + this.soundThrottle / 4);
        idle.setVolume(Math.max(0.1f,this.soundThrottle));
        idle.setPosition(getPositionVector());
        idle.setVelocity(getVelocity());
        idle.update();
      }
    }
    if (!ConfigGraphics.particlesEnabled) {
      return;
    }
    Vec3d fakeMotion=new Vec3d(this.motionX,this.motionY,this.motionZ);
    List<RenderComponent> exhausts=this.getDefinition().getComponents(RenderComponentType.DIESEL_EXHAUST_X,gauge);
    float throttle=Math.abs(this.getThrottle());
    if (exhausts != null && throttle > 0 && hasFuel && getEngineTemperature() > 70 && getTurnedOn()) {
      for (      RenderComponent exhaust : exhausts) {
        Vec3d particlePos=this.getPositionVector().add(VecUtil.rotateYaw(exhaust.center(),this.rotationYaw + 180)).addVector(0,0.35 * gauge.scale(),0);
        double smokeMod=(1 + Math.min(1,Math.max(0.2,Math.abs(this.getCurrentSpeed().minecraft()) * 2))) / 2;
        EntitySmokeParticle sp=new EntitySmokeParticle(world,(int)(40 * (1 + throttle) * smokeMod),throttle,throttle,exhaust.width());
        particlePos=particlePos.subtract(fakeMotion);
        sp.setPosition(particlePos.x,particlePos.y,particlePos.z);
        sp.setVelocity(fakeMotion.x,fakeMotion.y + 0.4 * gauge.scale(),fakeMotion.z);
        world.spawnEntity(sp);
      }
    }
    return;
  }
  if (this.getLiquidAmount() > 0) {
    float burnTime=BurnUtil.getBurnTime(this.getLiquid());
    if (burnTime == 0) {
      burnTime=200;
    }
    burnTime*=getDefinition().getFuelEfficiency() / 100f;
    burnTime*=(Config.ConfigBalance.locoDieselFuelEfficiency / 100f);
    float heatUpSpeed=0.0029167f * Config.ConfigBalance.dieselLocoHeatTimeScale;
    if (getTurnedOn()) {
      if (getEngineTemperature() < 73 && this.getLiquidAmount() > 0) {
        theTank.drain(1,true);
        setEngineTemperature(getEngineTemperature() + heatUpSpeed);
      }
      if (getEngineTemperature() > 150) {
        setEngineTemperature(150);
      }
      if (this.getThrottle() == 0f && getEngineTemperature() > 70) {
        setEngineTemperature(getEngineTemperature() - 0.02f);
      }
    }
 else {
      if (getEngineTemperature() > 0) {
        setEngineTemperature(getEngineTemperature() - 0.02f);
      }
 else {
        setEngineTemperature(0);
      }
    }
    if (getEngineTemperature() > 70 && getTurnedOn() && this.getThrottle() > 0f) {
      while (internalBurn < 0 && this.getLiquidAmount() > 0) {
        internalBurn+=burnTime / (this.getThrottle() * 10);
        theTank.drain(1,true);
      }
      setEngineTemperature(getEngineTemperature() + (float)(heatUpSpeed * this.getThrottle()) / 10);
    }
    float consumption=Math.abs(getThrottle()) + 0.05f;
    consumption*=100;
    consumption*=gauge.scale();
    internalBurn-=consumption;
    if (canTurnOnOff == false) {
      tick++;
      if (tick == turnOnOffDelay) {
        tick=0;
        canTurnOnOff=true;
      }
    }
  }
  if (getEngineTemperature() >= 150 && Config.ConfigDamage.canEnginesOverheat) {
    setEngineOverheated(true);
    setTurnedOn(false);
  }
  if (getEngineOverheated() && getEngineTemperature() == 0 && this.getCurrentSpeed().metric() == 0) {
    setEngineOverheated(false);
  }
}