From 62289dcf82961ecf6bbdf7da5d9d941b5650ad8c Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Thu, 31 Jul 2014 20:06:37 -0500 Subject: [PATCH] Automatic vs Manual Job Sorting. --- .../implementations/ContainerCraftConfirm.java | 2 +- helpers/MultiCraftingTracker.java | 2 +- me/cache/CraftingGridCache.java | 15 ++++++++++++--- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/container/implementations/ContainerCraftConfirm.java b/container/implementations/ContainerCraftConfirm.java index f60348fe..8bc38261 100644 --- a/container/implementations/ContainerCraftConfirm.java +++ b/container/implementations/ContainerCraftConfirm.java @@ -323,7 +323,7 @@ public class ContainerCraftConfirm extends AEBaseContainer if ( result != null && simulation == false ) { ICraftingGrid cc = getGrid().getCache( ICraftingGrid.class ); - ICraftingLink g = cc.submitJob( result, null, selectedCpu == -1 ? null : cpus.get( selectedCpu ).cpu, getActionSrc() ); + ICraftingLink g = cc.submitJob( result, null, selectedCpu == -1 ? null : cpus.get( selectedCpu ).cpu, true, getActionSrc() ); autoStart = false; if ( g != null && OriginalGui != null && openContext != null ) { diff --git a/helpers/MultiCraftingTracker.java b/helpers/MultiCraftingTracker.java index f0128fda..48f6748b 100644 --- a/helpers/MultiCraftingTracker.java +++ b/helpers/MultiCraftingTracker.java @@ -80,7 +80,7 @@ public class MultiCraftingTracker if ( job != null ) { setJob( x, null ); - setLink( x, cg.submitJob( job, owner, null, mySrc ) ); + setLink( x, cg.submitJob( job, owner, null, false, mySrc ) ); return true; } } diff --git a/me/cache/CraftingGridCache.java b/me/cache/CraftingGridCache.java index 3f2d532c..230f9f25 100644 --- a/me/cache/CraftingGridCache.java +++ b/me/cache/CraftingGridCache.java @@ -386,7 +386,8 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper } @Override - public ICraftingLink submitJob(ICraftingJob job, ICraftingRequester requestingMachine, ICraftingCPU target, BaseActionSource src) + public ICraftingLink submitJob(ICraftingJob job, ICraftingRequester requestingMachine, ICraftingCPU target, final boolean prioritizePower, + BaseActionSource src) { if ( job.isSimulation() ) return null; @@ -413,10 +414,18 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper @Override public int compare(CraftingCPUCluster o1, CraftingCPUCluster o2) { - int a = ItemSorters.compareLong( o2.getCoProcessors(), o1.getCoProcessors() ); + if ( prioritizePower ) + { + int a = ItemSorters.compareLong( o2.getCoProcessors(), o1.getCoProcessors() ); + if ( a != 0 ) + return a; + return ItemSorters.compareLong( o2.getAvailableStorage(), o1.getAvailableStorage() ); + } + + int a = ItemSorters.compareLong( o1.getCoProcessors(), o2.getCoProcessors() ); if ( a != 0 ) return a; - return ItemSorters.compareLong( o2.getAvailableStorage(), o1.getAvailableStorage() ); + return ItemSorters.compareLong( o1.getAvailableStorage(), o2.getAvailableStorage() ); } } );