Allow Config to adjust CPU Calculation time per tick.
This commit is contained in:
parent
4213dd55d2
commit
b7ea4e75d3
2 changed files with 19 additions and 5 deletions
|
@ -130,6 +130,8 @@ public class AEConfig extends Configuration implements IConfigureableObject, ICo
|
||||||
public double metoriteClusterChance = 0.1;
|
public double metoriteClusterChance = 0.1;
|
||||||
public double metoriteSpawnChance = 0.3;
|
public double metoriteSpawnChance = 0.3;
|
||||||
|
|
||||||
|
public int craftingCalculationTimePerTick = 5;
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent eventArgs)
|
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 );
|
spatialPowerScaler = get( "spatialio", "spatialPowerScaler", spatialPowerScaler ).getDouble( spatialPowerScaler );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( isFeatureEnabled( AEFeature.CraftingCPU ) )
|
||||||
|
{
|
||||||
|
craftingCalculationTimePerTick = get( "craftingcpu", "craftingCalculationTimePerTick", craftingCalculationTimePerTick ).getInt(
|
||||||
|
craftingCalculationTimePerTick );
|
||||||
|
}
|
||||||
|
|
||||||
if ( isFeatureEnabled( AEFeature.VersionChecker ) )
|
if ( isFeatureEnabled( AEFeature.VersionChecker ) )
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
|
@ -16,6 +16,7 @@ import appeng.api.AEApi;
|
||||||
import appeng.api.networking.IGridNode;
|
import appeng.api.networking.IGridNode;
|
||||||
import appeng.api.parts.CableRenderMode;
|
import appeng.api.parts.CableRenderMode;
|
||||||
import appeng.api.util.AEColor;
|
import appeng.api.util.AEColor;
|
||||||
|
import appeng.core.AEConfig;
|
||||||
import appeng.core.AELog;
|
import appeng.core.AELog;
|
||||||
import appeng.core.CommonHelper;
|
import appeng.core.CommonHelper;
|
||||||
import appeng.core.sync.packets.PacketPaintedEntity;
|
import appeng.core.sync.packets.PacketPaintedEntity;
|
||||||
|
@ -210,12 +211,17 @@ public class TickHandler
|
||||||
WorldTickEvent wte = (WorldTickEvent) ev;
|
WorldTickEvent wte = (WorldTickEvent) ev;
|
||||||
synchronized (craftingJobs)
|
synchronized (craftingJobs)
|
||||||
{
|
{
|
||||||
Iterator<CraftingJob> i = craftingJobs.get( wte.world ).iterator();
|
Collection<CraftingJob> jobSet = craftingJobs.get( wte.world );
|
||||||
while (i.hasNext())
|
if ( !jobSet.isEmpty() )
|
||||||
{
|
{
|
||||||
CraftingJob cj = i.next();
|
int simTime = Math.max( 1, AEConfig.instance.craftingCalculationTimePerTick / jobSet.size() );
|
||||||
if ( !cj.simulateFor( 5 ) )
|
Iterator<CraftingJob> i = jobSet.iterator();
|
||||||
i.remove();
|
while (i.hasNext())
|
||||||
|
{
|
||||||
|
CraftingJob cj = i.next();
|
||||||
|
if ( !cj.simulateFor( simTime ) )
|
||||||
|
i.remove();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue