Allow Config to adjust CPU Calculation time per tick.

This commit is contained in:
AlgorithmX2 2014-08-30 14:50:00 -05:00
parent 4213dd55d2
commit b7ea4e75d3
2 changed files with 19 additions and 5 deletions

View file

@ -130,6 +130,8 @@ public class AEConfig extends Configuration implements IConfigureableObject, ICo
public double metoriteClusterChance = 0.1;
public double metoriteSpawnChance = 0.3;
public int craftingCalculationTimePerTick = 5;
@SubscribeEvent
public void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent eventArgs)
{
@ -301,6 +303,12 @@ public class AEConfig extends Configuration implements IConfigureableObject, ICo
spatialPowerScaler = get( "spatialio", "spatialPowerScaler", spatialPowerScaler ).getDouble( spatialPowerScaler );
}
if ( isFeatureEnabled( AEFeature.CraftingCPU ) )
{
craftingCalculationTimePerTick = get( "craftingcpu", "craftingCalculationTimePerTick", craftingCalculationTimePerTick ).getInt(
craftingCalculationTimePerTick );
}
if ( isFeatureEnabled( AEFeature.VersionChecker ) )
{
try

View file

@ -16,6 +16,7 @@ import appeng.api.AEApi;
import appeng.api.networking.IGridNode;
import appeng.api.parts.CableRenderMode;
import appeng.api.util.AEColor;
import appeng.core.AEConfig;
import appeng.core.AELog;
import appeng.core.CommonHelper;
import appeng.core.sync.packets.PacketPaintedEntity;
@ -210,15 +211,20 @@ public class TickHandler
WorldTickEvent wte = (WorldTickEvent) ev;
synchronized (craftingJobs)
{
Iterator<CraftingJob> i = craftingJobs.get( wte.world ).iterator();
Collection<CraftingJob> jobSet = craftingJobs.get( wte.world );
if ( !jobSet.isEmpty() )
{
int simTime = Math.max( 1, AEConfig.instance.craftingCalculationTimePerTick / jobSet.size() );
Iterator<CraftingJob> i = jobSet.iterator();
while (i.hasNext())
{
CraftingJob cj = i.next();
if ( !cj.simulateFor( 5 ) )
if ( !cj.simulateFor( simTime ) )
i.remove();
}
}
}
}
// for no there is no reason to care about this on the client...
else if ( ev.type == Type.SERVER && ev.phase == Phase.END )