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;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CraftingJob(World w, NBTTagCompound data) {
|
public CraftingJob(World w, NBTTagCompound data)
|
||||||
|
{
|
||||||
world = wrapWorld( w );
|
world = wrapWorld( w );
|
||||||
storage = AEApi.instance().storage().createItemList();
|
storage = AEApi.instance().storage().createItemList();
|
||||||
prophecies = new HashSet();
|
prophecies = new HashSet();
|
||||||
|
@ -65,7 +66,8 @@ public class CraftingJob implements Runnable, ICraftingJob
|
||||||
return availableCheck.extractItems( available, Actionable.MODULATE, this.actionSrc );
|
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 );
|
world = wrapWorld( w );
|
||||||
output = what.copy();
|
output = what.copy();
|
||||||
storage = AEApi.instance().storage().createItemList();
|
storage = AEApi.instance().storage().createItemList();
|
||||||
|
@ -76,6 +78,8 @@ public class CraftingJob implements Runnable, ICraftingJob
|
||||||
ICraftingGrid cc = grid.getCache( ICraftingGrid.class );
|
ICraftingGrid cc = grid.getCache( ICraftingGrid.class );
|
||||||
IStorageGrid sg = grid.getCache( IStorageGrid.class );
|
IStorageGrid sg = grid.getCache( IStorageGrid.class );
|
||||||
original = new MECraftingInventory( sg.getItemInventory(), false, false, false );
|
original = new MECraftingInventory( sg.getItemInventory(), false, false, false );
|
||||||
|
original.filterPermissions( actionSrc );
|
||||||
|
|
||||||
tree = getCraftingTree( cc, what );
|
tree = getCraftingTree( cc, what );
|
||||||
availableCheck = null;
|
availableCheck = null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,9 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
|
||||||
final IMEInventory<IAEItemStack> target;
|
final IMEInventory<IAEItemStack> target;
|
||||||
final IItemList<IAEItemStack> localCache;
|
final IItemList<IAEItemStack> localCache;
|
||||||
|
|
||||||
|
private BaseActionSource usePermissions = null;
|
||||||
|
private final IItemList<IAEItemStack> permissionsCache = AEApi.instance().storage().createItemList();
|
||||||
|
|
||||||
final boolean logExtracted;
|
final boolean logExtracted;
|
||||||
final IItemList<IAEItemStack> extractedCache;
|
final IItemList<IAEItemStack> extractedCache;
|
||||||
|
|
||||||
|
@ -25,7 +28,28 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
|
||||||
final boolean logMissing;
|
final boolean logMissing;
|
||||||
final IItemList<IAEItemStack> missingCache;
|
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();
|
localCache = AEApi.instance().storage().createItemList();
|
||||||
extractedCache = null;
|
extractedCache = null;
|
||||||
injectedCache = null;
|
injectedCache = null;
|
||||||
|
@ -37,11 +61,16 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
|
||||||
par = null;
|
par = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MECraftingInventory(MECraftingInventory parrent) {
|
public MECraftingInventory(MECraftingInventory parrent)
|
||||||
|
{
|
||||||
this.target = parrent;
|
this.target = parrent;
|
||||||
this.logExtracted = parrent.logExtracted;
|
this.logExtracted = parrent.logExtracted;
|
||||||
this.logInjections = parrent.logInjections;
|
this.logInjections = parrent.logInjections;
|
||||||
this.logMissing = parrent.logMissing;
|
this.logMissing = parrent.logMissing;
|
||||||
|
this.usePermissions = parrent.usePermissions;
|
||||||
|
|
||||||
|
for (IAEItemStack is : parrent.permissionsCache)
|
||||||
|
permissionsCache.add( is );
|
||||||
|
|
||||||
if ( logMissing )
|
if ( logMissing )
|
||||||
missingCache = AEApi.instance().storage().createItemList();
|
missingCache = AEApi.instance().storage().createItemList();
|
||||||
|
@ -63,12 +92,21 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
|
||||||
par = parrent;
|
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.target = target;
|
||||||
this.logExtracted = logExtracted;
|
this.logExtracted = logExtracted;
|
||||||
this.logInjections = logInjections;
|
this.logInjections = logInjections;
|
||||||
this.logMissing = logMissing;
|
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 )
|
if ( logMissing )
|
||||||
missingCache = AEApi.instance().storage().createItemList();
|
missingCache = AEApi.instance().storage().createItemList();
|
||||||
else
|
else
|
||||||
|
@ -88,12 +126,19 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
|
||||||
par = null;
|
par = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void filterPermissions(BaseActionSource src)
|
||||||
|
{
|
||||||
|
usePermissions = src;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IAEItemStack injectItems(IAEItemStack input, Actionable mode, BaseActionSource src)
|
public IAEItemStack injectItems(IAEItemStack input, Actionable mode, BaseActionSource src)
|
||||||
{
|
{
|
||||||
if ( input == null )
|
if ( input == null )
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
filter( input, src );
|
||||||
|
|
||||||
if ( mode == Actionable.MODULATE )
|
if ( mode == Actionable.MODULATE )
|
||||||
{
|
{
|
||||||
if ( logInjections )
|
if ( logInjections )
|
||||||
|
@ -110,6 +155,8 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
|
||||||
if ( request == null )
|
if ( request == null )
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
filter( request, src );
|
||||||
|
|
||||||
IAEItemStack list = localCache.findPrecise( request );
|
IAEItemStack list = localCache.findPrecise( request );
|
||||||
if ( list == null || list.getStackSize() == 0 )
|
if ( list == null || list.getStackSize() == 0 )
|
||||||
return null;
|
return null;
|
||||||
|
@ -160,7 +207,7 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
|
||||||
boolean failed = false;
|
boolean failed = false;
|
||||||
|
|
||||||
if ( logExtracted )
|
if ( logExtracted )
|
||||||
{
|
{
|
||||||
for (IAEItemStack extra : extractedCache)
|
for (IAEItemStack extra : extractedCache)
|
||||||
{
|
{
|
||||||
IAEItemStack result = null;
|
IAEItemStack result = null;
|
||||||
|
@ -227,5 +274,12 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
|
||||||
IAEItemStack list = localCache.findPrecise( what );
|
IAEItemStack list = localCache.findPrecise( what );
|
||||||
if ( list != null )
|
if ( list != null )
|
||||||
list.setStackSize( 0 );
|
list.setStackSize( 0 );
|
||||||
|
|
||||||
|
if ( usePermissions != null )
|
||||||
|
{
|
||||||
|
IAEItemStack hmm = what.copy();
|
||||||
|
hmm.setStackSize( 1 );
|
||||||
|
permissionsCache.add( hmm );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue