Undo broken caching feature; replace with special case for IMEMonitors should at least be more optimized then two loops.
This commit is contained in:
@@ -77,8 +77,7 @@ public class CraftingJob implements Runnable, ICraftingJob
|
|||||||
this.callback = callback;
|
this.callback = callback;
|
||||||
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(), actionSrc, false, false, false );
|
||||||
original.filterPermissions( actionSrc );
|
|
||||||
|
|
||||||
tree = getCraftingTree( cc, what );
|
tree = getCraftingTree( cc, what );
|
||||||
availableCheck = null;
|
availableCheck = null;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import appeng.api.AEApi;
|
|||||||
import appeng.api.config.Actionable;
|
import appeng.api.config.Actionable;
|
||||||
import appeng.api.networking.security.BaseActionSource;
|
import appeng.api.networking.security.BaseActionSource;
|
||||||
import appeng.api.storage.IMEInventory;
|
import appeng.api.storage.IMEInventory;
|
||||||
|
import appeng.api.storage.IMEMonitor;
|
||||||
import appeng.api.storage.StorageChannel;
|
import appeng.api.storage.StorageChannel;
|
||||||
import appeng.api.storage.data.IAEItemStack;
|
import appeng.api.storage.data.IAEItemStack;
|
||||||
import appeng.api.storage.data.IItemList;
|
import appeng.api.storage.data.IItemList;
|
||||||
@@ -16,9 +17,6 @@ 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;
|
||||||
|
|
||||||
@@ -28,26 +26,6 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
|
|||||||
final boolean logMissing;
|
final boolean logMissing;
|
||||||
final IItemList<IAEItemStack> missingCache;
|
final IItemList<IAEItemStack> missingCache;
|
||||||
|
|
||||||
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()
|
public MECraftingInventory()
|
||||||
{
|
{
|
||||||
localCache = AEApi.instance().storage().createItemList();
|
localCache = AEApi.instance().storage().createItemList();
|
||||||
@@ -67,10 +45,6 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
|
|||||||
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();
|
||||||
@@ -92,20 +66,41 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
|
|||||||
par = parrent;
|
par = parrent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MECraftingInventory(IMEInventory<IAEItemStack> target, boolean logExtracted, boolean logInjections, boolean logMissing)
|
public MECraftingInventory(IMEMonitor<IAEItemStack> target, BaseActionSource src, 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 )
|
if ( logMissing )
|
||||||
{
|
missingCache = AEApi.instance().storage().createItemList();
|
||||||
MECraftingInventory parrent = (MECraftingInventory) target;
|
else
|
||||||
this.usePermissions = parrent.usePermissions;
|
missingCache = null;
|
||||||
for (IAEItemStack is : parrent.permissionsCache)
|
|
||||||
permissionsCache.add( is );
|
if ( logExtracted )
|
||||||
}
|
extractedCache = AEApi.instance().storage().createItemList();
|
||||||
|
else
|
||||||
|
extractedCache = null;
|
||||||
|
|
||||||
|
if ( logInjections )
|
||||||
|
injectedCache = AEApi.instance().storage().createItemList();
|
||||||
|
else
|
||||||
|
injectedCache = null;
|
||||||
|
|
||||||
|
localCache = AEApi.instance().storage().createItemList();
|
||||||
|
for ( IAEItemStack is : target.getStorageList() )
|
||||||
|
localCache.add( target.extractItems(is, Actionable.SIMULATE, src ) );
|
||||||
|
|
||||||
|
par = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MECraftingInventory(IMEInventory<IAEItemStack> target, boolean logExtracted, boolean logInjections, boolean logMissing)
|
||||||
|
{
|
||||||
|
this.target = target;
|
||||||
|
this.logExtracted = logExtracted;
|
||||||
|
this.logInjections = logInjections;
|
||||||
|
this.logMissing = logMissing;
|
||||||
|
|
||||||
if ( logMissing )
|
if ( logMissing )
|
||||||
missingCache = AEApi.instance().storage().createItemList();
|
missingCache = AEApi.instance().storage().createItemList();
|
||||||
@@ -126,19 +121,12 @@ 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 )
|
||||||
@@ -155,8 +143,6 @@ 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;
|
||||||
@@ -274,12 +260,5 @@ 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 );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user