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:
@@ -28,16 +28,14 @@ import net.minecraft.inventory.IContainerListener;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.IGridHost;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.crafting.CraftingItemList;
|
||||
import appeng.api.networking.crafting.ICraftingCPU;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.networking.security.IActionHost;
|
||||
import appeng.api.networking.security.IActionSource;
|
||||
import appeng.api.networking.storage.IBaseMonitor;
|
||||
import appeng.api.storage.IMEMonitorHandlerReceiver;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.core.AELog;
|
||||
@@ -65,15 +63,11 @@ public class ContainerCraftingCPU extends AEBaseContainer implements IMEMonitorH
|
||||
public ContainerCraftingCPU( final InventoryPlayer ip, final Object te )
|
||||
{
|
||||
super( ip, te );
|
||||
final IGridHost host = (IGridHost) ( te instanceof IGridHost ? te : null );
|
||||
final IActionHost host = (IActionHost) ( te instanceof IActionHost ? te : null );
|
||||
|
||||
if( host != null )
|
||||
if( host != null && host.getActionableNode() != null )
|
||||
{
|
||||
this.findNode( host, AEPartLocation.INTERNAL );
|
||||
for( final AEPartLocation d : AEPartLocation.SIDE_LOCATIONS )
|
||||
{
|
||||
this.findNode( host, d );
|
||||
}
|
||||
this.setNetwork( host.getActionableNode().getGrid() );
|
||||
}
|
||||
|
||||
if( te instanceof TileCraftingTile )
|
||||
@@ -87,18 +81,6 @@ public class ContainerCraftingCPU extends AEBaseContainer implements IMEMonitorH
|
||||
}
|
||||
}
|
||||
|
||||
private void findNode( final IGridHost host, final AEPartLocation d )
|
||||
{
|
||||
if( this.getNetwork() == null )
|
||||
{
|
||||
final IGridNode node = host.getGridNode( d );
|
||||
if( node != null )
|
||||
{
|
||||
this.setNetwork( node.getGrid() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void setCPU( final ICraftingCPU c )
|
||||
{
|
||||
if( c == this.getMonitor() )
|
||||
@@ -238,7 +220,7 @@ public class ContainerCraftingCPU extends AEBaseContainer implements IMEMonitorH
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postChange( final IBaseMonitor<IAEItemStack> monitor, final Iterable<IAEItemStack> change, final BaseActionSource actionSource )
|
||||
public void postChange( final IBaseMonitor<IAEItemStack> monitor, final Iterable<IAEItemStack> change, final IActionSource actionSource )
|
||||
{
|
||||
for( IAEItemStack is : change )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user