Fixes #1905: Export bus now considers failed crafting requests

The export bus will now no longer speed up, if more than 1 of the last
crafting requests failed and slow down, if more then 5 failed.

Some code cleanup and moved the custom iterator into the helper package
as it is clearly related to the craftingtracker and not the export bus.
This commit is contained in:
yueh
2015-09-25 19:58:07 +02:00
committed by thatsIch
parent c96cf10c86
commit 3b495c35d7
3 changed files with 135 additions and 90 deletions
@@ -175,6 +175,13 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
// :P
}
final int failedAttempts = this.craftingTracker.getFailedCraftingAttempts();
if( this.isCraftingEnabled() && failedAttempts > 0 )
{
return this.getFailedCraftingPenalty( failedAttempts );
}
return this.didSomething ? TickRateModulation.FASTER : TickRateModulation.SLOWER;
}
@@ -379,4 +386,18 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
this.nextSlot = ( this.nextSlot + x ) % this.availableSlots();
}
}
private TickRateModulation getFailedCraftingPenalty( int failedAttempts )
{
if( failedAttempts > 5 )
{
return TickRateModulation.SLOWER;
}
else if( failedAttempts > 1 )
{
return TickRateModulation.SAME;
}
return TickRateModulation.FASTER;
}
}