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:
@@ -37,10 +37,8 @@ import appeng.api.networking.crafting.ICraftingCallback;
|
||||
import appeng.api.networking.crafting.ICraftingGrid;
|
||||
import appeng.api.networking.crafting.ICraftingJob;
|
||||
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.networking.security.IActionHost;
|
||||
import appeng.api.networking.security.MachineSource;
|
||||
import appeng.api.networking.security.PlayerSource;
|
||||
import appeng.api.networking.security.IActionSource;
|
||||
import appeng.api.networking.storage.IStorageGrid;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
@@ -66,7 +64,7 @@ public class CraftingJob implements Runnable, ICraftingJob
|
||||
private boolean simulate = false;
|
||||
private MECraftingInventory availableCheck;
|
||||
private long bytes = 0;
|
||||
private final BaseActionSource actionSrc;
|
||||
private final IActionSource actionSrc;
|
||||
private final ICraftingCallback callback;
|
||||
private boolean running = false;
|
||||
private boolean done = false;
|
||||
@@ -78,7 +76,7 @@ public class CraftingJob implements Runnable, ICraftingJob
|
||||
return w;
|
||||
}
|
||||
|
||||
public CraftingJob( final World w, final IGrid grid, final BaseActionSource actionSrc, final IAEItemStack what, final ICraftingCallback callback )
|
||||
public CraftingJob( final World w, final IGrid grid, final IActionSource actionSrc, final IAEItemStack what, final ICraftingCallback callback )
|
||||
{
|
||||
this.world = this.wrapWorld( w );
|
||||
this.output = what.copy();
|
||||
@@ -375,22 +373,21 @@ public class CraftingJob implements Runnable, ICraftingJob
|
||||
final long elapsedTime = timer.elapsed( TimeUnit.MILLISECONDS );
|
||||
final String actionSource;
|
||||
|
||||
if( this.actionSrc instanceof MachineSource )
|
||||
if( this.actionSrc.player().isPresent() )
|
||||
{
|
||||
final IActionHost machineSource = ( (MachineSource) this.actionSrc ).via;
|
||||
final EntityPlayer player = this.actionSrc.player().get();
|
||||
|
||||
actionSource = player.toString();
|
||||
}
|
||||
else if( this.actionSrc.machine().isPresent() )
|
||||
{
|
||||
final IActionHost machineSource = this.actionSrc.machine().get();
|
||||
final IGridNode actionableNode = machineSource.getActionableNode();
|
||||
final IGridHost machine = actionableNode.getMachine();
|
||||
final DimensionalCoord location = actionableNode.getGridBlock().getLocation();
|
||||
|
||||
actionSource = String.format( LOG_MACHINE_SOURCE_DETAILS, machine, location );
|
||||
}
|
||||
else if( this.actionSrc instanceof PlayerSource )
|
||||
{
|
||||
final PlayerSource source = (PlayerSource) this.actionSrc;
|
||||
final EntityPlayer player = source.player;
|
||||
|
||||
actionSource = player.toString();
|
||||
}
|
||||
else
|
||||
{
|
||||
actionSource = "[unknown source]";
|
||||
|
||||
Reference in New Issue
Block a user