Fix Crafting Dupe on Extraction, if extraction fails roll back and fail.
This commit is contained in:
@@ -44,7 +44,8 @@ public class CraftingTreeNode
|
|||||||
|
|
||||||
boolean sim;
|
boolean sim;
|
||||||
|
|
||||||
public CraftingTreeNode(ICraftingGrid cc, CraftingJob job, IAEItemStack wat, CraftingTreeProcess par, int slot, int depth) {
|
public CraftingTreeNode(ICraftingGrid cc, CraftingJob job, IAEItemStack wat, CraftingTreeProcess par, int slot, int depth)
|
||||||
|
{
|
||||||
what = wat;
|
what = wat;
|
||||||
parent = par;
|
parent = par;
|
||||||
this.slot = slot;
|
this.slot = slot;
|
||||||
@@ -206,7 +207,8 @@ public class CraftingTreeNode
|
|||||||
|
|
||||||
if ( available != null )
|
if ( available != null )
|
||||||
{
|
{
|
||||||
subInv.commit( src );
|
if ( !subInv.commit( src ) )
|
||||||
|
throw new CraftBranchFailure( what, l );
|
||||||
|
|
||||||
bytes += available.getStackSize();
|
bytes += available.getStackSize();
|
||||||
l -= available.getStackSize();
|
l -= available.getStackSize();
|
||||||
|
|||||||
@@ -153,18 +153,59 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
|
|||||||
return StorageChannel.ITEMS;
|
return StorageChannel.ITEMS;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void commit(BaseActionSource src)
|
public boolean commit(BaseActionSource src)
|
||||||
{
|
{
|
||||||
|
IItemList<IAEItemStack> added = AEApi.instance().storage().createItemList();
|
||||||
|
IItemList<IAEItemStack> pulled = AEApi.instance().storage().createItemList();
|
||||||
|
boolean failed = false;
|
||||||
|
|
||||||
|
if ( logExtracted )
|
||||||
|
{
|
||||||
|
for (IAEItemStack extra : extractedCache)
|
||||||
|
{
|
||||||
|
IAEItemStack result = null;
|
||||||
|
pulled.add( result = target.extractItems( extra, Actionable.MODULATE, src ) );
|
||||||
|
|
||||||
|
if ( result == null || result.getStackSize() != extra.getStackSize() )
|
||||||
|
{
|
||||||
|
failed = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( failed )
|
||||||
|
{
|
||||||
|
for (IAEItemStack is : pulled)
|
||||||
|
target.injectItems( is, Actionable.MODULATE, src );
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if ( logInjections )
|
if ( logInjections )
|
||||||
{
|
{
|
||||||
for (IAEItemStack injec : injectedCache)
|
for (IAEItemStack injec : injectedCache)
|
||||||
target.injectItems( injec, Actionable.MODULATE, src );
|
{
|
||||||
|
IAEItemStack result = null;
|
||||||
|
added.add( result = target.injectItems( injec, Actionable.MODULATE, src ) );
|
||||||
|
|
||||||
|
if ( result != null )
|
||||||
|
{
|
||||||
|
failed = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( logExtracted )
|
if ( failed )
|
||||||
{
|
{
|
||||||
for (IAEItemStack extra : extractedCache)
|
for (IAEItemStack is : added)
|
||||||
target.extractItems( extra, Actionable.MODULATE, src );
|
target.extractItems( is, Actionable.MODULATE, src );
|
||||||
|
|
||||||
|
for (IAEItemStack is : pulled)
|
||||||
|
target.injectItems( is, Actionable.MODULATE, src );
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( logMissing && par != null )
|
if ( logMissing && par != null )
|
||||||
@@ -172,6 +213,8 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
|
|||||||
for (IAEItemStack extra : missingCache)
|
for (IAEItemStack extra : missingCache)
|
||||||
par.addMissing( extra );
|
par.addMissing( extra );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addMissing(IAEItemStack extra)
|
public void addMissing(IAEItemStack extra)
|
||||||
|
|||||||
@@ -198,7 +198,8 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
|||||||
return inventory;
|
return inventory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CraftingCPUCluster(WorldCoord _min, WorldCoord _max) {
|
public CraftingCPUCluster(WorldCoord _min, WorldCoord _max)
|
||||||
|
{
|
||||||
min = _min;
|
min = _min;
|
||||||
max = _max;
|
max = _max;
|
||||||
}
|
}
|
||||||
@@ -786,32 +787,39 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
|||||||
{
|
{
|
||||||
waitingFor.resetStatus();
|
waitingFor.resetStatus();
|
||||||
((CraftingJob) job).tree.setJob( ci, this, src );
|
((CraftingJob) job).tree.setJob( ci, this, src );
|
||||||
ci.commit( src );
|
if ( ci.commit( src ) )
|
||||||
finalOutput = job.getOutput();
|
{
|
||||||
waiting = false;
|
finalOutput = job.getOutput();
|
||||||
isComplete = false;
|
waiting = false;
|
||||||
markDirty();
|
isComplete = false;
|
||||||
|
markDirty();
|
||||||
|
|
||||||
updateCPU();
|
updateCPU();
|
||||||
String craftID = generateCraftingID();
|
String craftID = generateCraftingID();
|
||||||
|
|
||||||
myLastLink = new CraftingLink( generateLinkData( craftID, requestingMachine == null, false ), this );
|
myLastLink = new CraftingLink( generateLinkData( craftID, requestingMachine == null, false ), this );
|
||||||
|
|
||||||
if ( requestingMachine == null )
|
if ( requestingMachine == null )
|
||||||
return myLastLink;
|
return myLastLink;
|
||||||
|
|
||||||
ICraftingLink whatLink = new CraftingLink( generateLinkData( craftID, requestingMachine == null, true ), requestingMachine );
|
ICraftingLink whatLink = new CraftingLink( generateLinkData( craftID, requestingMachine == null, true ), requestingMachine );
|
||||||
|
|
||||||
submitLink( myLastLink );
|
submitLink( myLastLink );
|
||||||
submitLink( whatLink );
|
submitLink( whatLink );
|
||||||
|
|
||||||
IItemList<IAEItemStack> list;
|
IItemList<IAEItemStack> list;
|
||||||
getListOfItem( list = AEApi.instance().storage().createItemList(), CraftingItemList.ALL );
|
getListOfItem( list = AEApi.instance().storage().createItemList(), CraftingItemList.ALL );
|
||||||
|
|
||||||
for (IAEItemStack ge : list)
|
for (IAEItemStack ge : list)
|
||||||
postChange( ge, machineSrc );
|
postChange( ge, machineSrc );
|
||||||
|
|
||||||
return whatLink;
|
return whatLink;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tasks.clear();
|
||||||
|
inventory.getItemList().resetStatus();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (CraftBranchFailure e)
|
catch (CraftBranchFailure e)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user