Fixed Crafting CPU Render.
Finished Crafting Confirm Screen Added logic to prevent crafting in cpus with too little storage.
This commit is contained in:
Vendored
+30
-3
@@ -1,6 +1,8 @@
|
||||
package appeng.me.cache;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
@@ -49,6 +51,7 @@ import appeng.crafting.CraftingLinkNexus;
|
||||
import appeng.me.cluster.implementations.CraftingCPUCluster;
|
||||
import appeng.tile.crafting.TileCraftingStorageTile;
|
||||
import appeng.tile.crafting.TileCraftingTile;
|
||||
import appeng.util.ItemSorters;
|
||||
|
||||
import com.google.common.collect.ImmutableCollection;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
@@ -70,6 +73,12 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
||||
|
||||
boolean updateList = false;
|
||||
|
||||
@Override
|
||||
public ImmutableSet<ICraftingCPU> getCpus()
|
||||
{
|
||||
return ImmutableSet.copyOf( (HashSet<ICraftingCPU>) (HashSet) cpuClusters );
|
||||
}
|
||||
|
||||
public CraftingGridCache(IGrid g) {
|
||||
grid = g;
|
||||
}
|
||||
@@ -345,19 +354,37 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
||||
|
||||
if ( target == null )
|
||||
{
|
||||
// TODO real stuff...
|
||||
List<CraftingCPUCluster> validCpusClusters = new ArrayList<CraftingCPUCluster>();
|
||||
for (CraftingCPUCluster cpu : cpuClusters)
|
||||
{
|
||||
if ( !cpu.isBusy() )
|
||||
if ( !cpu.isBusy() && cpu.getAvailableStorage() >= job.getByteTotal() )
|
||||
{
|
||||
cpuClust = cpu;
|
||||
validCpusClusters.add( cpu );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Collections.sort( validCpusClusters, new Comparator<CraftingCPUCluster>() {
|
||||
|
||||
@Override
|
||||
public int compare(CraftingCPUCluster o1, CraftingCPUCluster o2)
|
||||
{
|
||||
int a = ItemSorters.compareLong( o2.getCoProcessors(), o1.getCoProcessors() );
|
||||
if ( a != 0 )
|
||||
return a;
|
||||
return ItemSorters.compareLong( o2.getAvailableStorage(), o1.getAvailableStorage() );
|
||||
}
|
||||
|
||||
} );
|
||||
|
||||
if ( !validCpusClusters.isEmpty() )
|
||||
cpuClust = validCpusClusters.get( 0 );
|
||||
}
|
||||
|
||||
if ( cpuClust != null )
|
||||
{
|
||||
return cpuClust.submitJob( grid, job, src, requestingMachine );
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -386,8 +386,13 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
||||
|
||||
private void updateCPU()
|
||||
{
|
||||
IAEItemStack send = finalOutput;
|
||||
|
||||
if ( finalOutput != null && finalOutput.getStackSize() <= 0 )
|
||||
send = null;
|
||||
|
||||
for (TileCraftingMonitorTile t : status)
|
||||
t.setJob( finalOutput );
|
||||
t.setJob( send );
|
||||
}
|
||||
|
||||
public IGrid getGrid()
|
||||
@@ -468,6 +473,10 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
||||
myLastLink = null;
|
||||
tasks.clear();
|
||||
waitingFor.resetStatus();
|
||||
|
||||
finalOutput = null;
|
||||
updateCPU();
|
||||
|
||||
storeItems(); // marks dirty
|
||||
}
|
||||
|
||||
@@ -701,6 +710,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
||||
if ( !(job instanceof CraftingJob) )
|
||||
return null;
|
||||
|
||||
if ( isBusy() || getAvailableStorage() < job.getByteTotal() )
|
||||
return null;
|
||||
|
||||
IStorageGrid sg = g.getCache( IStorageGrid.class );
|
||||
IMEInventory<IAEItemStack> storage = sg.getItemInventory();
|
||||
MECraftingInventory ci = new MECraftingInventory( storage, true, false, false );
|
||||
|
||||
Reference in New Issue
Block a user