diff --git a/crafting/CraftingJob.java b/crafting/CraftingJob.java index f0b608d0d..5ddf0e77a 100644 --- a/crafting/CraftingJob.java +++ b/crafting/CraftingJob.java @@ -77,8 +77,7 @@ public class CraftingJob implements Runnable, ICraftingJob this.callback = callback; ICraftingGrid cc = grid.getCache( ICraftingGrid.class ); IStorageGrid sg = grid.getCache( IStorageGrid.class ); - original = new MECraftingInventory( sg.getItemInventory(), false, false, false ); - original.filterPermissions( actionSrc ); + original = new MECraftingInventory( sg.getItemInventory(), actionSrc, false, false, false ); tree = getCraftingTree( cc, what ); availableCheck = null; diff --git a/crafting/MECraftingInventory.java b/crafting/MECraftingInventory.java index bfc986946..781afe642 100644 --- a/crafting/MECraftingInventory.java +++ b/crafting/MECraftingInventory.java @@ -4,6 +4,7 @@ import appeng.api.AEApi; import appeng.api.config.Actionable; import appeng.api.networking.security.BaseActionSource; import appeng.api.storage.IMEInventory; +import appeng.api.storage.IMEMonitor; import appeng.api.storage.StorageChannel; import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IItemList; @@ -16,9 +17,6 @@ public class MECraftingInventory implements IMEInventory final IMEInventory target; final IItemList localCache; - private BaseActionSource usePermissions = null; - private final IItemList permissionsCache = AEApi.instance().storage().createItemList(); - final boolean logExtracted; final IItemList extractedCache; @@ -28,26 +26,6 @@ public class MECraftingInventory implements IMEInventory final boolean logMissing; final IItemList 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() { localCache = AEApi.instance().storage().createItemList(); @@ -67,10 +45,6 @@ public class MECraftingInventory implements IMEInventory 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(); @@ -92,20 +66,41 @@ public class MECraftingInventory implements IMEInventory par = parrent; } - public MECraftingInventory(IMEInventory target, boolean logExtracted, boolean logInjections, boolean logMissing) + public MECraftingInventory(IMEMonitor target, BaseActionSource src, 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 + missingCache = null; + + 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 target, boolean logExtracted, boolean logInjections, boolean logMissing) + { + this.target = target; + this.logExtracted = logExtracted; + this.logInjections = logInjections; + this.logMissing = logMissing; if ( logMissing ) missingCache = AEApi.instance().storage().createItemList(); @@ -126,19 +121,12 @@ public class MECraftingInventory implements IMEInventory 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 ) @@ -155,8 +143,6 @@ public class MECraftingInventory implements IMEInventory if ( request == null ) return null; - filter( request, src ); - IAEItemStack list = localCache.findPrecise( request ); if ( list == null || list.getStackSize() == 0 ) return null; @@ -274,12 +260,5 @@ public class MECraftingInventory implements IMEInventory IAEItemStack list = localCache.findPrecise( what ); if ( list != null ) list.setStackSize( 0 ); - - if ( usePermissions != null ) - { - IAEItemStack hmm = what.copy(); - hmm.setStackSize( 1 ); - permissionsCache.add( hmm ); - } } }