diff --git a/src/main/java/appeng/crafting/CraftingJob.java b/src/main/java/appeng/crafting/CraftingJob.java index 8755f824b..4976861de 100644 --- a/src/main/java/appeng/crafting/CraftingJob.java +++ b/src/main/java/appeng/crafting/CraftingJob.java @@ -59,7 +59,6 @@ public class CraftingJob implements Runnable, ICraftingJob private final IItemList missing = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList(); private final HashMap opsAndMultiplier = new HashMap<>(); private final Object monitor = new Object(); - private final Stopwatch watch = Stopwatch.createUnstarted(); private CraftingTreeNode tree; private final IAEItemStack output; private boolean simulate = false; @@ -67,10 +66,7 @@ public class CraftingJob implements Runnable, ICraftingJob private long bytes = 0; private final IActionSource actionSrc; private final ICraftingCallback callback; - private boolean running = false; private boolean done = false; - private int time = 5; - private int incTime = Integer.MAX_VALUE; private World wrapWorld( final World w ) { @@ -137,7 +133,6 @@ public class CraftingJob implements Runnable, ICraftingJob try { TickHandler.INSTANCE.registerCraftingSimulation( this.world, this ); - this.handlePausing(); final Stopwatch timer = Stopwatch.createStarted(); @@ -219,42 +214,6 @@ public class CraftingJob implements Runnable, ICraftingJob this.finish(); } - void handlePausing() throws InterruptedException - { - if( this.incTime > 100 ) - { - this.incTime = 0; - - synchronized( this.monitor ) - { - if( this.watch.elapsed( TimeUnit.MICROSECONDS ) > this.time ) - { - this.running = false; - this.watch.stop(); - this.monitor.notify(); - } - - if( !this.running ) - { - AELog.craftingDebug( "crafting job will now sleep" ); - - while( !this.running ) - { - this.monitor.wait(); - } - - AELog.craftingDebug( "crafting job now active" ); - } - } - - if( Thread.interrupted() ) - { - throw new InterruptedException(); - } - } - this.incTime++; - } - private void finish() { if( this.callback != null ) @@ -266,7 +225,6 @@ public class CraftingJob implements Runnable, ICraftingJob synchronized( this.monitor ) { - this.running = false; this.done = true; this.monitor.notify(); } @@ -310,45 +268,15 @@ public class CraftingJob implements Runnable, ICraftingJob } /** - * returns true if this needs more simulation. - * - * @param milli milliseconds of simulation - * * @return true if this needs more simulation */ - public boolean simulateFor( final int milli ) + public boolean simulateFor() { - this.time = milli; - - synchronized( this.monitor ) - { - if( this.done ) - { + synchronized( this.monitor ) { + if ( this.done ) { return false; } - - this.watch.reset(); - this.watch.start(); - this.running = true; - - AELog.craftingDebug( "main thread is now going to sleep" ); - - this.monitor.notify(); - - while( this.running ) - { - try - { - this.monitor.wait(); - } - catch( final InterruptedException ignored ) - { - } - } - - AELog.craftingDebug( "main thread is now active" ); } - return true; } diff --git a/src/main/java/appeng/crafting/CraftingTreeNode.java b/src/main/java/appeng/crafting/CraftingTreeNode.java index f62391378..136ed0a6e 100644 --- a/src/main/java/appeng/crafting/CraftingTreeNode.java +++ b/src/main/java/appeng/crafting/CraftingTreeNode.java @@ -119,7 +119,6 @@ public class CraftingTreeNode IAEItemStack request( final MECraftingInventory inv, long l, final IActionSource src ) throws CraftBranchFailure, InterruptedException { - this.job.handlePausing(); final List thingsUsed = new ArrayList<>(); diff --git a/src/main/java/appeng/crafting/CraftingTreeProcess.java b/src/main/java/appeng/crafting/CraftingTreeProcess.java index b82e3458f..c4a8ad484 100644 --- a/src/main/java/appeng/crafting/CraftingTreeProcess.java +++ b/src/main/java/appeng/crafting/CraftingTreeProcess.java @@ -185,7 +185,6 @@ public class CraftingTreeProcess void request( final MECraftingInventory inv, final long i, final IActionSource src ) throws CraftBranchFailure, InterruptedException { - this.job.handlePausing(); if( this.fullSimulation ) { diff --git a/src/main/java/appeng/hooks/TickHandler.java b/src/main/java/appeng/hooks/TickHandler.java index ba6836447..76f70df2c 100644 --- a/src/main/java/appeng/hooks/TickHandler.java +++ b/src/main/java/appeng/hooks/TickHandler.java @@ -192,12 +192,11 @@ public class TickHandler final Collection jobSet = this.craftingJobs.get( wte.world ); if( !jobSet.isEmpty() ) { - final int simTime = Math.max( 1, AEConfig.instance().getCraftingCalculationTimePerTick() / jobSet.size() * 1000); final Iterator i = jobSet.iterator(); while( i.hasNext() ) { final CraftingJob cj = i.next(); - if( !cj.simulateFor( simTime ) ) + if( !cj.simulateFor() ) { i.remove(); }