Fix Crafting Dupe on Calculation, Test Item types for real quantities as they are needed.
This commit is contained in:
parent
73cda63a78
commit
57d23dd2a7
2 changed files with 64 additions and 6 deletions
|
@ -47,7 +47,8 @@ public class CraftingJob implements Runnable, ICraftingJob
|
|||
return output;
|
||||
}
|
||||
|
||||
public CraftingJob(World w, NBTTagCompound data) {
|
||||
public CraftingJob(World w, NBTTagCompound data)
|
||||
{
|
||||
world = wrapWorld( w );
|
||||
storage = AEApi.instance().storage().createItemList();
|
||||
prophecies = new HashSet();
|
||||
|
@ -65,7 +66,8 @@ public class CraftingJob implements Runnable, ICraftingJob
|
|||
return availableCheck.extractItems( available, Actionable.MODULATE, this.actionSrc );
|
||||
}
|
||||
|
||||
public CraftingJob(World w, IGrid grid, BaseActionSource actionSrc, IAEItemStack what, ICraftingCallback callback) {
|
||||
public CraftingJob(World w, IGrid grid, BaseActionSource actionSrc, IAEItemStack what, ICraftingCallback callback)
|
||||
{
|
||||
world = wrapWorld( w );
|
||||
output = what.copy();
|
||||
storage = AEApi.instance().storage().createItemList();
|
||||
|
@ -76,6 +78,8 @@ public class CraftingJob implements Runnable, ICraftingJob
|
|||
ICraftingGrid cc = grid.getCache( ICraftingGrid.class );
|
||||
IStorageGrid sg = grid.getCache( IStorageGrid.class );
|
||||
original = new MECraftingInventory( sg.getItemInventory(), false, false, false );
|
||||
original.filterPermissions( actionSrc );
|
||||
|
||||
tree = getCraftingTree( cc, what );
|
||||
availableCheck = null;
|
||||
}
|
||||
|
|
|
@ -16,6 +16,9 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
|
|||
final IMEInventory<IAEItemStack> target;
|
||||
final IItemList<IAEItemStack> localCache;
|
||||
|
||||
private BaseActionSource usePermissions = null;
|
||||
private final IItemList<IAEItemStack> permissionsCache = AEApi.instance().storage().createItemList();
|
||||
|
||||
final boolean logExtracted;
|
||||
final IItemList<IAEItemStack> extractedCache;
|
||||
|
||||
|
@ -25,7 +28,28 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
|
|||
final boolean logMissing;
|
||||
final IItemList<IAEItemStack> missingCache;
|
||||
|
||||
public MECraftingInventory() {
|
||||
private void filter(IAEItemStack input, BaseActionSource src)
|
||||
{
|
||||
if ( usePermissions != null && input != null )
|
||||
{
|
||||
if ( permissionsCache.findPrecise( input ) == null )
|
||||
{
|
||||
IAEItemStack what = input.copy();
|
||||
what.setStackSize( 1 );
|
||||
permissionsCache.add( what );
|
||||
|
||||
IAEItemStack localItem = localCache.findPrecise( input );
|
||||
if ( localItem != null )
|
||||
{
|
||||
IAEItemStack realSize = target.extractItems( input, Actionable.SIMULATE, usePermissions );
|
||||
localItem.setStackSize( realSize == null ? 0 : realSize.getStackSize() );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public MECraftingInventory()
|
||||
{
|
||||
localCache = AEApi.instance().storage().createItemList();
|
||||
extractedCache = null;
|
||||
injectedCache = null;
|
||||
|
@ -37,11 +61,16 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
|
|||
par = null;
|
||||
}
|
||||
|
||||
public MECraftingInventory(MECraftingInventory parrent) {
|
||||
public MECraftingInventory(MECraftingInventory parrent)
|
||||
{
|
||||
this.target = parrent;
|
||||
this.logExtracted = parrent.logExtracted;
|
||||
this.logInjections = parrent.logInjections;
|
||||
this.logMissing = parrent.logMissing;
|
||||
this.usePermissions = parrent.usePermissions;
|
||||
|
||||
for (IAEItemStack is : parrent.permissionsCache)
|
||||
permissionsCache.add( is );
|
||||
|
||||
if ( logMissing )
|
||||
missingCache = AEApi.instance().storage().createItemList();
|
||||
|
@ -63,12 +92,21 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
|
|||
par = parrent;
|
||||
}
|
||||
|
||||
public MECraftingInventory(IMEInventory<IAEItemStack> target, boolean logExtracted, boolean logInjections, boolean logMissing) {
|
||||
public MECraftingInventory(IMEInventory<IAEItemStack> target, boolean logExtracted, boolean logInjections, boolean logMissing)
|
||||
{
|
||||
this.target = target;
|
||||
this.logExtracted = logExtracted;
|
||||
this.logInjections = logInjections;
|
||||
this.logMissing = logMissing;
|
||||
|
||||
if ( target instanceof MECraftingInventory )
|
||||
{
|
||||
MECraftingInventory parrent = (MECraftingInventory) target;
|
||||
this.usePermissions = parrent.usePermissions;
|
||||
for (IAEItemStack is : parrent.permissionsCache)
|
||||
permissionsCache.add( is );
|
||||
}
|
||||
|
||||
if ( logMissing )
|
||||
missingCache = AEApi.instance().storage().createItemList();
|
||||
else
|
||||
|
@ -88,12 +126,19 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
|
|||
par = null;
|
||||
}
|
||||
|
||||
public void filterPermissions(BaseActionSource src)
|
||||
{
|
||||
usePermissions = src;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack injectItems(IAEItemStack input, Actionable mode, BaseActionSource src)
|
||||
{
|
||||
if ( input == null )
|
||||
return null;
|
||||
|
||||
filter( input, src );
|
||||
|
||||
if ( mode == Actionable.MODULATE )
|
||||
{
|
||||
if ( logInjections )
|
||||
|
@ -110,6 +155,8 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
|
|||
if ( request == null )
|
||||
return null;
|
||||
|
||||
filter( request, src );
|
||||
|
||||
IAEItemStack list = localCache.findPrecise( request );
|
||||
if ( list == null || list.getStackSize() == 0 )
|
||||
return null;
|
||||
|
@ -160,7 +207,7 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
|
|||
boolean failed = false;
|
||||
|
||||
if ( logExtracted )
|
||||
{
|
||||
{
|
||||
for (IAEItemStack extra : extractedCache)
|
||||
{
|
||||
IAEItemStack result = null;
|
||||
|
@ -227,5 +274,12 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
|
|||
IAEItemStack list = localCache.findPrecise( what );
|
||||
if ( list != null )
|
||||
list.setStackSize( 0 );
|
||||
|
||||
if ( usePermissions != null )
|
||||
{
|
||||
IAEItemStack hmm = what.copy();
|
||||
hmm.setStackSize( 1 );
|
||||
permissionsCache.add( hmm );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue