Refactored the BaseActionSource (#3063)

* Refactored the BaseActionSource

It now uses an interface `IActionSource` instead of a concrete class and further
subclasses. 

Instead of relying on a specific class for a certain action type, it now
uses methods with Optional as return values to determine a player or
machine issuing an action. Refer to the JavaDocs for the exact behaviour.

* `IActionHost` no longer extends `IGridHost`

It never used the additional functionality and if needed the `IGridNode`
will also provide a reference to the corresponding `IGridHost`.

Due to most crafting related GUIs being hardcoded to `IGridHost`, 
they no longer work when `IActionHost` is not extending it. Actually
`IActionHost` is the better solution for it, as it prevents us from looking
the grid up via the `IGridHost` and potentially finding a wrong grid.

* Interfaces now only lock the currently worked slot.

This allows `DualityInterface#onChangeInventory` to update slots of the same interface, should they be the source for a requested item and therefore updating their working set accordingly to queue further crafting requests for unfulfilled stack requirements.
This commit is contained in:
yueh
2017-09-12 11:39:00 +02:00
committed by GitHub
parent 771a944058
commit 970630a90d
81 changed files with 572 additions and 465 deletions
@@ -21,7 +21,7 @@ package appeng.crafting;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.StorageChannel;
@@ -99,7 +99,7 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
this.par = parent;
}
public MECraftingInventory( final IMEMonitor<IAEItemStack> target, final BaseActionSource src, final boolean logExtracted, final boolean logInjections, final boolean logMissing )
public MECraftingInventory( final IMEMonitor<IAEItemStack> target, final IActionSource src, final boolean logExtracted, final boolean logInjections, final boolean logMissing )
{
this.target = target;
this.logExtracted = logExtracted;
@@ -181,7 +181,7 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
}
@Override
public IAEItemStack injectItems( final IAEItemStack input, final Actionable mode, final BaseActionSource src )
public IAEItemStack injectItems( final IAEItemStack input, final Actionable mode, final IActionSource src )
{
if( input == null )
{
@@ -201,7 +201,7 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
}
@Override
public IAEItemStack extractItems( final IAEItemStack request, final Actionable mode, final BaseActionSource src )
public IAEItemStack extractItems( final IAEItemStack request, final Actionable mode, final IActionSource src )
{
if( request == null )
{
@@ -265,7 +265,7 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
return this.localCache;
}
public boolean commit( final BaseActionSource src )
public boolean commit( final IActionSource src )
{
final IItemList<IAEItemStack> added = AEApi.instance().storage().createItemList();
final IItemList<IAEItemStack> pulled = AEApi.instance().storage().createItemList();