Program: 171518
Project: 171518
Buggy source:
@Override public void onUpdate(){
  super.onUpdate();
  if (world.isRemote) {
    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 (isRunning()) {
        if (!idle.isPlaying()) {
          this.idle.play(getPositionVector());
        }
      }
 else {
        if (idle.isPlaying()) {
          idle.stop();
        }
      }
      if (this.getDataManager().get(HORN) != 0 && !horn.isPlaying() && isRunning()) {
        horn.play(getPositionVector());
      }
      float absThrottle=Math.abs(this.getThrottle());
      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()) + 0.05f;
    if (exhausts != null && isRunning()) {
      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;
  }
  float engineTemperature=getEngineTemperature();
  float heatUpSpeed=0.0029167f * Config.ConfigBalance.dieselLocoHeatTimeScale;
  float engineHeatEnergy=(float)(0.65f * (15000f * (engineTemperature - ambientTemperature())) * gauge.scale());
  float castIronHeatTransfer=0.65f * (engineTemperature * ambientTemperature()) * 2f;
  float heatTransferPerTick=castIronHeatTransfer / 20;
  float coolDownSpeed=0;
  if (engineHeatEnergy - heatTransferPerTick >= 0) {
    coolDownSpeed=heatTransferPerTick * Config.ConfigBalance.dieselLocoHeatTimeScale;
  }
  if (this.getLiquidAmount() > 0 && isRunning()) {
    float consumption=Math.abs(getThrottle()) + 0.05f;
    float burnTime=BurnUtil.getBurnTime(this.getLiquid());
    if (burnTime == 0) {
      burnTime=200;
    }
    burnTime*=getDefinition().getFuelEfficiency() / 100f;
    burnTime*=(Config.ConfigBalance.locoDieselFuelEfficiency / 100f);
    while (internalBurn < 0 && this.getLiquidAmount() > 0) {
      internalBurn+=burnTime;
      theTank.drain(1,true);
    }
    consumption*=100;
    consumption*=gauge.scale();
    internalBurn-=consumption;
    if (engineTemperature < 75) {
      setEngineTemperature(engineTemperature + heatUpSpeed);
    }
  }
  if (isRunning()) {
    if (engineTemperature > 70 && !isEngineOverheated()) {
      engineTemperature+=heatUpSpeed * (Math.abs(getThrottle()) + 0.1f);
    }
    if (engineTemperature > 150 && Config.ConfigBalance.canDieselEnginesOverheat) {
      engineTemperature=150;
      setEngineOverheated(true);
    }
    if ((engineTemperature < 50 || !Config.ConfigBalance.canDieselEnginesOverheat) && isEngineOverheated()) {
      setEngineOverheated(false);
    }
  }
  if (this.getThrottle() == 0 && (engineTemperature > 75 || (!isTurnedOn() && engineTemperature >= ambientTemperature()))) {
    engineTemperature-=coolDownSpeed;
  }
  if (engineTemperature < ambientTemperature() && !isTurnedOn()) {
    setEngineTemperature(ambientTemperature());
  }
  if (turnOnOffDelay > 0) {
    turnOnOffDelay-=1;
  }
}

Fixed version (ground truth):
@Override public void onUpdate(){
  super.onUpdate();
  if (world.isRemote) {
    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 (isRunning()) {
        if (!idle.isPlaying()) {
          this.idle.play(getPositionVector());
        }
      }
 else {
        if (idle.isPlaying()) {
          idle.stop();
        }
      }
      if (this.getDataManager().get(HORN) != 0 && !horn.isPlaying() && isRunning()) {
        horn.play(getPositionVector());
      }
      float absThrottle=Math.abs(this.getThrottle());
      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()) + 0.05f;
    if (exhausts != null && isRunning()) {
      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;
  }
  float engineTemperature=getEngineTemperature();
  float heatUpSpeed=0.0029167f * Config.ConfigBalance.dieselLocoHeatTimeScale;
  float coolDownSpeed=heatUpSpeed * ((engineTemperature - ambientTemperature()) / 200);
  if (this.getLiquidAmount() > 0 && isRunning()) {
    float consumption=Math.abs(getThrottle()) + 0.05f;
    float burnTime=BurnUtil.getBurnTime(this.getLiquid());
    if (burnTime == 0) {
      burnTime=200;
    }
    burnTime*=getDefinition().getFuelEfficiency() / 100f;
    burnTime*=(Config.ConfigBalance.locoDieselFuelEfficiency / 100f);
    while (internalBurn < 0 && this.getLiquidAmount() > 0) {
      internalBurn+=burnTime;
      theTank.drain(1,true);
    }
    consumption*=100;
    consumption*=gauge.scale();
    internalBurn-=consumption;
    if (engineTemperature < 75) {
      engineTemperature+=heatUpSpeed;
    }
  }
  if (isRunning()) {
    if (engineTemperature > 70 && !isEngineOverheated()) {
      engineTemperature+=(heatUpSpeed / 5) * (Math.abs(getThrottle()) + 0.1f);
    }
    if (engineTemperature > 150 && Config.ConfigBalance.canDieselEnginesOverheat) {
      engineTemperature=150;
      setEngineOverheated(true);
    }
    if ((engineTemperature < 50 || !Config.ConfigBalance.canDieselEnginesOverheat) && isEngineOverheated()) {
      setEngineOverheated(false);
    }
  }
  if (getThrottle() == 0 && engineTemperature > 74 || !isTurnedOn() && engineTemperature > ambientTemperature()) {
    engineTemperature-=coolDownSpeed;
  }
  if (turnOnOffDelay > 0) {
    turnOnOffDelay-=1;
  }
  setEngineTemperature(engineTemperature);
}