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

View file

@ -24,7 +24,7 @@
package appeng.api.networking.crafting;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.networking.storage.IBaseMonitor;
import appeng.api.storage.data.IAEItemStack;
@ -40,7 +40,7 @@ public interface ICraftingCPU extends IBaseMonitor<IAEItemStack>
/**
* @return the action source for the CPU.
*/
BaseActionSource getActionSource();
IActionSource getActionSource();
/**
* @return the available storage in bytes

View file

@ -33,7 +33,7 @@ import net.minecraft.world.World;
import appeng.api.networking.IGrid;
import appeng.api.networking.IGridCache;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.storage.data.IAEItemStack;
@ -63,7 +63,7 @@ public interface ICraftingGrid extends IGridCache
* @return a future which will at an undetermined point in the future get you the {@link ICraftingJob} do not wait
* on this, your be waiting forever.
*/
Future<ICraftingJob> beginCraftingJob( World world, IGrid grid, BaseActionSource actionSrc, IAEItemStack craftWhat, ICraftingCallback callback );
Future<ICraftingJob> beginCraftingJob( World world, IGrid grid, IActionSource actionSrc, IAEItemStack craftWhat, ICraftingCallback callback );
/**
* Submit the job to the Crafting system for processing.
@ -82,7 +82,7 @@ public interface ICraftingGrid extends IGridCache
* {@link ICraftingRequester} methods. if you send null, this object should be discarded after verifying the
* return state.
*/
ICraftingLink submitJob( ICraftingJob job, ICraftingRequester requestingMachine, ICraftingCPU target, boolean prioritizePower, BaseActionSource src );
ICraftingLink submitJob( ICraftingJob job, ICraftingRequester requestingMachine, ICraftingCPU target, boolean prioritizePower, IActionSource src );
/**
* @return list of all the crafting cpus on the grid

View file

@ -1,41 +0,0 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2013 AlgorithmX2
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package appeng.api.networking.security;
/**
* TODO: Consider refactoring.
*/
public class BaseActionSource
{
public boolean isPlayer()
{
return false;
}
public boolean isMachine()
{
return false;
}
}

View file

@ -24,11 +24,10 @@
package appeng.api.networking.security;
import appeng.api.networking.IGridHost;
import appeng.api.networking.IGridNode;
public interface IActionHost extends IGridHost
public interface IActionHost
{
/**

View file

@ -0,0 +1,77 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2013 AlgorithmX2
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package appeng.api.networking.security;
import java.util.Optional;
import javax.annotation.Nonnull;
import net.minecraft.entity.player.EntityPlayer;
/**
* The source of any action.
*
* This can either be a {@link EntityPlayer} or an {@link IActionHost}.
*
* In most cases this is used for security checks, but can be used to validate the source itself.
*
*/
public interface IActionSource
{
/**
* If present, AE will consider the player being the source for the action.
*
* This will take precedence over {@link IActionSource#machine()} in any case.
*
* @return An optional player issuing the action.
*/
@Nonnull
Optional<EntityPlayer> player();
/**
* If present, it indicates the {@link IActionHost} of the source.
*
* Should {@link IActionSource#player()} be absent, it will consider a machine as source.
*
* It is recommended to include the machine even when a player is present.
*
* @return An optional machine issuing the action or acting as proxy for a player.
*/
@Nonnull
Optional<IActionHost> machine();
/**
* An {@link IActionSource} can have multiple optional contexts.
*
* It is strongly recommended to limit the uses for absolutely necessary cases.
*
* Currently there are no public contexts made available by AE.
* An example would be the context interfaces use internally to avoid looping items between each other.
*/
@Nonnull
<T> Optional<T> context( @Nonnull Class<T> key );
}

View file

@ -1,44 +0,0 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2013 AlgorithmX2
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package appeng.api.networking.security;
/**
* TODO: Consider refactoring.
*/
public class MachineSource extends BaseActionSource
{
public final IActionHost via;
public MachineSource( final IActionHost v )
{
this.via = v;
}
@Override
public boolean isMachine()
{
return true;
}
}

View file

@ -1,49 +0,0 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2013 AlgorithmX2
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package appeng.api.networking.security;
import net.minecraft.entity.player.EntityPlayer;
/**
* TODO: Consider refactoring.
*/
public class PlayerSource extends BaseActionSource
{
public final EntityPlayer player;
public final IActionHost via;
public PlayerSource( final EntityPlayer p, final IActionHost v )
{
this.player = p;
this.via = v;
}
@Override
public boolean isPlayer()
{
return true;
}
}

View file

@ -24,7 +24,7 @@
package appeng.api.networking.storage;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEStack;
import appeng.api.storage.data.IItemList;
@ -50,5 +50,5 @@ public interface IStackWatcherHost
* @param src action source
* @param chan storage channel
*/
void onStackChange( IItemList o, IAEStack fullStack, IAEStack diffStack, BaseActionSource src, StorageChannel chan );
void onStackChange( IItemList o, IAEStack fullStack, IAEStack diffStack, IActionSource src, StorageChannel chan );
}

View file

@ -26,7 +26,7 @@ package appeng.api.networking.storage;
import appeng.api.networking.IGridCache;
import appeng.api.networking.IGridHost;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.storage.ICellContainer;
import appeng.api.storage.ICellProvider;
import appeng.api.storage.IStorageMonitorable;
@ -50,7 +50,7 @@ public interface IStorageGrid extends IGridCache, IStorageMonitorable
*
* @param input injected items
*/
void postAlterationOfStoredItems( StorageChannel chan, Iterable<? extends IAEStack> input, BaseActionSource src );
void postAlterationOfStoredItems( StorageChannel chan, Iterable<? extends IAEStack> input, IActionSource src );
/**
* Used to add a cell provider to the storage system

View file

@ -25,7 +25,7 @@ package appeng.api.storage;
import appeng.api.config.Actionable;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.storage.data.IAEStack;
import appeng.api.storage.data.IItemList;
@ -52,7 +52,7 @@ public interface IMEInventory<StackType extends IAEStack>
*
* @return returns the number of items not added.
*/
StackType injectItems( StackType input, Actionable type, BaseActionSource src );
StackType injectItems( StackType input, Actionable type, IActionSource src );
/**
* Extract the specified item from the ME Inventory
@ -62,7 +62,7 @@ public interface IMEInventory<StackType extends IAEStack>
*
* @return returns the number of items extracted, null
*/
StackType extractItems( StackType request, Actionable mode, BaseActionSource src );
StackType extractItems( StackType request, Actionable mode, IActionSource src );
/**
* request a full report of all available items, storage.

View file

@ -24,7 +24,7 @@
package appeng.api.storage;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.networking.storage.IBaseMonitor;
import appeng.api.storage.data.IAEStack;
@ -46,7 +46,7 @@ public interface IMEMonitorHandlerReceiver<StackType extends IAEStack>
*
* @param change done change
*/
void postChange( IBaseMonitor<StackType> monitor, Iterable<StackType> change, BaseActionSource actionSource );
void postChange( IBaseMonitor<StackType> monitor, Iterable<StackType> change, IActionSource actionSource );
/**
* called when the list updates its contents, this is mostly for handling power events.

View file

@ -35,7 +35,7 @@ import net.minecraftforge.fluids.FluidStack;
import appeng.api.networking.crafting.ICraftingLink;
import appeng.api.networking.crafting.ICraftingRequester;
import appeng.api.networking.energy.IEnergySource;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
@ -109,7 +109,7 @@ public interface IStorageHelper
*
* @return items that successfully extracted.
*/
IAEItemStack poweredExtraction( IEnergySource energy, IMEInventory<IAEItemStack> cell, IAEItemStack request, BaseActionSource src );
IAEItemStack poweredExtraction( IEnergySource energy, IMEInventory<IAEItemStack> cell, IAEItemStack request, IActionSource src );
/**
* use energy from energy, to inject input items into cell, at the request of src
@ -121,5 +121,5 @@ public interface IStorageHelper
*
* @return items that failed to insert.
*/
IAEItemStack poweredInsert( IEnergySource energy, IMEInventory<IAEItemStack> cell, IAEItemStack input, BaseActionSource src );
IAEItemStack poweredInsert( IEnergySource energy, IMEInventory<IAEItemStack> cell, IAEItemStack input, IActionSource src );
}

View file

@ -4,7 +4,7 @@ package appeng.api.storage;
import javax.annotation.Nullable;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionSource;
/**
@ -22,5 +22,5 @@ public interface IStorageMonitorableAccessor
* @return Null if the network cannot be accessed by the given action source (i.e. security doesn't permit it).
*/
@Nullable
IStorageMonitorable getInventory( BaseActionSource src );
IStorageMonitorable getInventory( IActionSource src );
}

View file

@ -32,7 +32,7 @@ import com.google.common.collect.ImmutableList;
import appeng.api.config.AccessRestriction;
import appeng.api.config.Actionable;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.storage.data.IAEStack;
import appeng.api.storage.data.IItemList;
@ -81,7 +81,7 @@ public class MEMonitorHandler<StackType extends IAEStack> implements IMEMonitor<
}
@Override
public StackType injectItems( final StackType input, final Actionable mode, final BaseActionSource src )
public StackType injectItems( final StackType input, final Actionable mode, final IActionSource src )
{
if( mode == Actionable.SIMULATE )
{
@ -95,7 +95,7 @@ public class MEMonitorHandler<StackType extends IAEStack> implements IMEMonitor<
return this.internalHandler;
}
private StackType monitorDifference( final IAEStack original, final StackType leftOvers, final boolean extraction, final BaseActionSource src )
private StackType monitorDifference( final IAEStack original, final StackType leftOvers, final boolean extraction, final IActionSource src )
{
final StackType diff = (StackType) original.copy();
@ -116,12 +116,12 @@ public class MEMonitorHandler<StackType extends IAEStack> implements IMEMonitor<
return leftOvers;
}
protected void postChangesToListeners( final Iterable<StackType> changes, final BaseActionSource src )
protected void postChangesToListeners( final Iterable<StackType> changes, final IActionSource src )
{
this.notifyListenersOfChange( changes, src );
}
protected void notifyListenersOfChange( final Iterable<StackType> diff, final BaseActionSource src )
protected void notifyListenersOfChange( final Iterable<StackType> diff, final IActionSource src )
{
this.hasChanged = true;// need to update the cache.
final Iterator<Entry<IMEMonitorHandlerReceiver<StackType>, Object>> i = this.getListeners();
@ -146,7 +146,7 @@ public class MEMonitorHandler<StackType extends IAEStack> implements IMEMonitor<
}
@Override
public StackType extractItems( final StackType request, final Actionable mode, final BaseActionSource src )
public StackType extractItems( final StackType request, final Actionable mode, final IActionSource src )
{
if( mode == Actionable.SIMULATE )
{

View file

@ -19,7 +19,7 @@
package appeng.capabilities;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.storage.IStorageMonitorable;
import appeng.api.storage.IStorageMonitorableAccessor;
@ -28,7 +28,7 @@ class NullMENetworkAccessor implements IStorageMonitorableAccessor
{
@Override
public IStorageMonitorable getInventory( BaseActionSource src )
public IStorageMonitorable getInventory( IActionSource src )
{
return null;
}

View file

@ -51,10 +51,9 @@ import appeng.api.networking.IGrid;
import appeng.api.networking.IGridNode;
import appeng.api.networking.energy.IEnergyGrid;
import appeng.api.networking.energy.IEnergySource;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionHost;
import appeng.api.networking.security.IActionSource;
import appeng.api.networking.security.ISecurityGrid;
import appeng.api.networking.security.PlayerSource;
import appeng.api.parts.IPart;
import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.data.IAEItemStack;
@ -77,6 +76,7 @@ import appeng.core.sync.packets.PacketPartialItem;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.helpers.ICustomNameObject;
import appeng.helpers.InventoryAction;
import appeng.me.helpers.PlayerSource;
import appeng.util.InventoryAdaptor;
import appeng.util.Platform;
import appeng.util.inv.AdaptorItemHandler;
@ -87,7 +87,7 @@ import appeng.util.item.AEItemStack;
public abstract class AEBaseContainer extends Container
{
private final InventoryPlayer invPlayer;
private final BaseActionSource mySrc;
private final IActionSource mySrc;
private final HashSet<Integer> locked = new HashSet<>();
private final TileEntity tileEntity;
private final IPart part;
@ -280,7 +280,7 @@ public abstract class AEBaseContainer extends Container
this.clientRequestedTargetItem = stack == null ? null : stack.copy();
}
public BaseActionSource getActionSource()
public IActionSource getActionSource()
{
return this.mySrc;
}

View file

@ -27,13 +27,13 @@ import net.minecraft.world.World;
import appeng.api.config.SecurityPermissions;
import appeng.api.networking.IGrid;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionHost;
import appeng.api.networking.security.PlayerSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEItemStack;
import appeng.container.AEBaseContainer;
import appeng.container.slot.SlotInaccessible;
import appeng.me.helpers.PlayerSource;
import appeng.tile.inventory.AppEngInternalInventory;
@ -69,7 +69,7 @@ public class ContainerCraftAmount extends AEBaseContainer
return this.getPlayerInv().player.world;
}
public BaseActionSource getActionSrc()
public IActionSource getActionSrc()
{
return new PlayerSource( this.getPlayerInv().player, (IActionHost) this.getTarget() );
}

View file

@ -44,9 +44,8 @@ import appeng.api.networking.crafting.ICraftingCPU;
import appeng.api.networking.crafting.ICraftingGrid;
import appeng.api.networking.crafting.ICraftingJob;
import appeng.api.networking.crafting.ICraftingLink;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionHost;
import appeng.api.networking.security.PlayerSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.networking.storage.IStorageGrid;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.ITerminalHost;
@ -60,6 +59,7 @@ import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketMEInventoryUpdate;
import appeng.core.sync.packets.PacketSwitchGuis;
import appeng.helpers.WirelessTerminalGuiObject;
import appeng.me.helpers.PlayerSource;
import appeng.parts.reporting.PartCraftingTerminal;
import appeng.parts.reporting.PartPatternTerminal;
import appeng.parts.reporting.PartTerminal;
@ -361,7 +361,7 @@ public class ContainerCraftConfirm extends AEBaseContainer
}
}
private BaseActionSource getActionSrc()
private IActionSource getActionSrc()
{
return new PlayerSource( this.getPlayerInv().player, (IActionHost) this.getTarget() );
}

View file

@ -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 )
{

View file

@ -47,7 +47,8 @@ import appeng.api.networking.IGridHost;
import appeng.api.networking.IGridNode;
import appeng.api.networking.energy.IEnergyGrid;
import appeng.api.networking.energy.IEnergySource;
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.parts.IPart;
import appeng.api.storage.IMEMonitor;
@ -122,9 +123,22 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa
{
this.setPowerSource( (IEnergySource) monitorable );
}
else if( monitorable instanceof IGridHost )
else if( monitorable instanceof IGridHost || monitorable instanceof IActionHost )
{
final IGridNode node = ( (IGridHost) monitorable ).getGridNode( AEPartLocation.INTERNAL );
final IGridNode node;
if( monitorable instanceof IGridHost )
{
node = ( (IGridHost) monitorable ).getGridNode( AEPartLocation.INTERNAL );
}
else if( monitorable instanceof IActionHost )
{
node = ( (IActionHost) monitorable ).getActionableNode();
}
else
{
node = null;
}
if( node != null )
{
this.networkNode = node;
@ -374,7 +388,7 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa
}
@Override
public void postChange( final IBaseMonitor<IAEItemStack> monitor, final Iterable<IAEItemStack> change, final BaseActionSource source )
public void postChange( final IBaseMonitor<IAEItemStack> monitor, final Iterable<IAEItemStack> change, final IActionSource source )
{
for( final IAEItemStack is : change )
{

View file

@ -43,7 +43,6 @@ import net.minecraftforge.items.wrapper.PlayerInvWrapper;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.definitions.IDefinitions;
import appeng.api.networking.security.MachineSource;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEItemStack;
@ -59,6 +58,7 @@ import appeng.container.slot.SlotRestrictedInput;
import appeng.core.sync.packets.PacketPatternSlot;
import appeng.helpers.IContainerCraftingPacket;
import appeng.items.storage.ItemViewCell;
import appeng.me.helpers.MachineSource;
import appeng.parts.reporting.PartPatternTerminal;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.util.InventoryAdaptor;

View file

@ -36,7 +36,7 @@ import net.minecraftforge.items.IItemHandler;
import appeng.api.config.Actionable;
import appeng.api.networking.energy.IEnergySource;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.IStorageMonitorable;
import appeng.api.storage.data.IAEItemStack;
@ -61,12 +61,12 @@ public class SlotCraftingTerm extends AppEngCraftingSlot
private final IItemHandler craftInv;
private final IItemHandler pattern;
private final BaseActionSource mySrc;
private final IActionSource mySrc;
private final IEnergySource energySrc;
private final IStorageMonitorable storage;
private final IContainerCraftingPacket container;
public SlotCraftingTerm( final EntityPlayer player, final BaseActionSource mySrc, final IEnergySource energySrc, final IStorageMonitorable storage, final IItemHandler cMatrix, final IItemHandler secondMatrix, final IItemHandler output, final int x, final int y, final IContainerCraftingPacket ccp )
public SlotCraftingTerm( final EntityPlayer player, final IActionSource mySrc, final IEnergySource energySrc, final IStorageMonitorable storage, final IItemHandler cMatrix, final IItemHandler secondMatrix, final IItemHandler output, final int x, final int y, final IContainerCraftingPacket ccp )
{
super( player, cMatrix, output, 0, x, y );
this.energySrc = energySrc;

View file

@ -27,7 +27,7 @@ import net.minecraftforge.items.IItemHandler;
import appeng.api.AEApi;
import appeng.api.networking.energy.IEnergySource;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.storage.IStorageMonitorable;
import appeng.core.sync.AppEngPacket;
import appeng.core.sync.packets.PacketPatternSlot;
@ -40,7 +40,7 @@ public class SlotPatternTerm extends SlotCraftingTerm
private final int groupNum;
private final IOptionalSlotHost host;
public SlotPatternTerm( final EntityPlayer player, final BaseActionSource mySrc, final IEnergySource energySrc, final IStorageMonitorable storage, final IItemHandler cMatrix, final IItemHandler secondMatrix, final IItemHandler output, final int x, final int y, final IOptionalSlotHost h, final int groupNumber, final IContainerCraftingPacket c )
public SlotPatternTerm( final EntityPlayer player, final IActionSource mySrc, final IEnergySource energySrc, final IStorageMonitorable storage, final IItemHandler cMatrix, final IItemHandler secondMatrix, final IItemHandler output, final int x, final int y, final IOptionalSlotHost h, final int groupNumber, final IContainerCraftingPacket c )
{
super( player, mySrc, energySrc, storage, cMatrix, secondMatrix, output, x, y, c );

View file

@ -30,7 +30,7 @@ import net.minecraftforge.fluids.FluidStack;
import appeng.api.networking.crafting.ICraftingLink;
import appeng.api.networking.crafting.ICraftingRequester;
import appeng.api.networking.energy.IEnergySource;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.IStorageHelper;
import appeng.api.storage.data.IAEFluidStack;
@ -90,13 +90,13 @@ public class ApiStorage implements IStorageHelper
}
@Override
public IAEItemStack poweredExtraction( final IEnergySource energy, final IMEInventory<IAEItemStack> cell, final IAEItemStack request, final BaseActionSource src )
public IAEItemStack poweredExtraction( final IEnergySource energy, final IMEInventory<IAEItemStack> cell, final IAEItemStack request, final IActionSource src )
{
return Platform.poweredExtraction( energy, cell, request, src );
}
@Override
public IAEItemStack poweredInsert( final IEnergySource energy, final IMEInventory<IAEItemStack> cell, final IAEItemStack input, final BaseActionSource src )
public IAEItemStack poweredInsert( final IEnergySource energy, final IMEInventory<IAEItemStack> cell, final IAEItemStack input, final IActionSource src )
{
return Platform.poweredInsert( energy, cell, input, src );
}

View file

@ -28,11 +28,10 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import appeng.api.networking.IGrid;
import appeng.api.networking.IGridHost;
import appeng.api.networking.IGridNode;
import appeng.api.networking.crafting.ICraftingGrid;
import appeng.api.networking.crafting.ICraftingJob;
import appeng.api.util.AEPartLocation;
import appeng.api.networking.security.IActionHost;
import appeng.container.ContainerOpenContext;
import appeng.container.implementations.ContainerCraftAmount;
import appeng.container.implementations.ContainerCraftConfirm;
@ -77,10 +76,10 @@ public class PacketCraftRequest extends AppEngPacket
{
final ContainerCraftAmount cca = (ContainerCraftAmount) player.openContainer;
final Object target = cca.getTarget();
if( target instanceof IGridHost )
if( target instanceof IActionHost )
{
final IGridHost gh = (IGridHost) target;
final IGridNode gn = gh.getGridNode( AEPartLocation.INTERNAL );
final IActionHost ah = (IActionHost) target;
final IGridNode gn = ah.getActionableNode();
if( gn == null )
{
return;

View file

@ -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]";

View file

@ -33,7 +33,7 @@ import appeng.api.config.Actionable;
import appeng.api.config.FuzzyMode;
import appeng.api.networking.crafting.ICraftingGrid;
import appeng.api.networking.crafting.ICraftingPatternDetails;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import appeng.me.cluster.implementations.CraftingCPUCluster;
@ -117,7 +117,7 @@ public class CraftingTreeNode
return this.parent.notRecursive( details );
}
IAEItemStack request( final MECraftingInventory inv, long l, final BaseActionSource src ) throws CraftBranchFailure, InterruptedException
IAEItemStack request( final MECraftingInventory inv, long l, final IActionSource src ) throws CraftBranchFailure, InterruptedException
{
this.job.handlePausing();
@ -346,7 +346,7 @@ public class CraftingTreeNode
}
}
public void setJob( final MECraftingInventory storage, final CraftingCPUCluster craftingCPUCluster, final BaseActionSource src ) throws CraftBranchFailure
public void setJob( final MECraftingInventory storage, final CraftingCPUCluster craftingCPUCluster, final IActionSource src ) throws CraftBranchFailure
{
for( final IAEItemStack i : this.used )
{

View file

@ -33,7 +33,7 @@ import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.networking.crafting.ICraftingGrid;
import appeng.api.networking.crafting.ICraftingPatternDetails;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import appeng.container.ContainerNull;
@ -184,7 +184,7 @@ public class CraftingTreeProcess
return ( remaining / stackSize ) + ( remaining % stackSize != 0 ? 1 : 0 );
}
void request( final MECraftingInventory inv, final long i, final BaseActionSource src ) throws CraftBranchFailure, InterruptedException
void request( final MECraftingInventory inv, final long i, final IActionSource src ) throws CraftBranchFailure, InterruptedException
{
this.job.handlePausing();
@ -297,7 +297,7 @@ public class CraftingTreeProcess
}
}
void setJob( final MECraftingInventory storage, final CraftingCPUCluster craftingCPUCluster, final BaseActionSource src ) throws CraftBranchFailure
void setJob( final MECraftingInventory storage, final CraftingCPUCluster craftingCPUCluster, final IActionSource src ) throws CraftBranchFailure
{
craftingCPUCluster.addCrafting( this.details, this.crafts );

View file

@ -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();

View file

@ -25,6 +25,7 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Optional;
import javax.annotation.Nullable;
@ -66,9 +67,8 @@ import appeng.api.networking.crafting.ICraftingProvider;
import appeng.api.networking.crafting.ICraftingProviderHelper;
import appeng.api.networking.energy.IEnergySource;
import appeng.api.networking.events.MENetworkCraftingPatternChange;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionHost;
import appeng.api.networking.security.MachineSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.networking.ticking.IGridTickable;
import appeng.api.networking.ticking.TickRateModulation;
import appeng.api.networking.ticking.TickingRequest;
@ -88,6 +88,7 @@ import appeng.capabilities.Capabilities;
import appeng.core.settings.TickRates;
import appeng.me.GridAccessException;
import appeng.me.helpers.AENetworkProxy;
import appeng.me.helpers.MachineSource;
import appeng.me.storage.MEMonitorIInventory;
import appeng.me.storage.MEMonitorPassThrough;
import appeng.me.storage.NullInventory;
@ -118,8 +119,8 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
private final MultiCraftingTracker craftingTracker;
private final AENetworkProxy gridProxy;
private final IInterfaceHost iHost;
private final BaseActionSource mySource;
private final BaseActionSource interfaceRequestSource;
private final IActionSource mySource;
private final IActionSource interfaceRequestSource;
private final ConfigManager cm = new ConfigManager( this );
private final AppEngInternalAEInventory config = new AppEngInternalAEInventory( this, NUMBER_OF_CONFIG_SLOTS );
private final AppEngInternalInventory storage = new AppEngInternalInventory( this, NUMBER_OF_STORAGE_SLOTS );
@ -132,7 +133,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
private List<ICraftingPatternDetails> craftingList = null;
private List<ItemStack> waitingToSend = null;
private IMEInventory<IAEItemStack> destination;
private boolean isWorking = false;
private int isWorking = -1;
private final Accessor accessor = new Accessor();
public DualityInterface( final AENetworkProxy networkProxy, final IInterfaceHost ih )
@ -164,7 +165,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
@Override
public void onChangeInventory( final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removed, final ItemStack added )
{
if( this.isWorking )
if( this.isWorking == slot )
{
return;
}
@ -407,34 +408,34 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
req = null;
}
final ItemStack Stored = this.storage.getStackInSlot( slot );
final ItemStack stored = this.storage.getStackInSlot( slot );
if( req == null && !Stored.isEmpty() )
if( req == null && !stored.isEmpty() )
{
final IAEItemStack work = AEApi.instance().storage().createItemStack( Stored );
final IAEItemStack work = AEApi.instance().storage().createItemStack( stored );
this.requireWork[slot] = work.setStackSize( -work.getStackSize() );
return;
}
else if( req != null )
{
if( Stored.isEmpty() ) // need to add stuff!
if( stored.isEmpty() ) // need to add stuff!
{
this.requireWork[slot] = req.copy();
return;
}
else if( req.isSameType( Stored ) ) // same type ( qty different? )!
else if( req.isSameType( stored ) ) // same type ( qty different? )!
{
if( req.getStackSize() != Stored.getCount() )
if( req.getStackSize() != stored.getCount() )
{
this.requireWork[slot] = req.copy();
this.requireWork[slot].setStackSize( req.getStackSize() - Stored.getCount() );
this.requireWork[slot].setStackSize( req.getStackSize() - stored.getCount() );
return;
}
}
else
// Stored != null; dispose!
{
final IAEItemStack work = AEApi.instance().storage().createItemStack( Stored );
final IAEItemStack work = AEApi.instance().storage().createItemStack( stored );
this.requireWork[slot] = work.setStackSize( -work.getStackSize() );
return;
}
@ -657,7 +658,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
private boolean usePlan( final int x, final IAEItemStack itemStack )
{
final InventoryAdaptor adaptor = this.getAdaptor( x );
this.isWorking = true;
this.isWorking = x;
boolean changed = false;
try
@ -742,7 +743,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
this.updatePlan( x );
}
this.isWorking = false;
this.isWorking = -1;
return changed;
}
@ -865,7 +866,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
this.craftingTracker.cancel();
}
public IStorageMonitorable getMonitorable( final BaseActionSource src, final IStorageMonitorable myInterface )
public IStorageMonitorable getMonitorable( final IActionSource src, final IStorageMonitorable myInterface )
{
if( Platform.canAccess( this.gridProxy, src ) )
{
@ -1275,10 +1276,34 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
private class InterfaceRequestSource extends MachineSource
{
private final InterfaceRequestContext context;
public InterfaceRequestSource( final IActionHost v )
public InterfaceRequestSource( IActionHost v )
{
super( v );
this.context = new InterfaceRequestContext();
}
@Override
public <T> Optional<T> context( Class<T> key )
{
if( key == InterfaceRequestContext.class )
{
return (Optional<T>) Optional.of( this.context );
}
return super.context( key );
}
}
private class InterfaceRequestContext implements Comparable<Integer>
{
@Override
public int compareTo( Integer o )
{
return Integer.compare( DualityInterface.this.priority, o );
}
}
@ -1292,9 +1317,12 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
}
@Override
public IAEItemStack injectItems( final IAEItemStack input, final Actionable type, final BaseActionSource src )
public IAEItemStack injectItems( final IAEItemStack input, final Actionable type, final IActionSource src )
{
if( src instanceof InterfaceRequestSource )
final Optional<InterfaceRequestContext> context = src.context( InterfaceRequestContext.class );
final boolean isInterface = context.isPresent();
if( isInterface )
{
return input;
}
@ -1303,9 +1331,12 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
}
@Override
public IAEItemStack extractItems( final IAEItemStack request, final Actionable type, final BaseActionSource src )
public IAEItemStack extractItems( final IAEItemStack request, final Actionable type, final IActionSource src )
{
if( src instanceof InterfaceRequestSource )
final Optional<InterfaceRequestContext> context = src.context( InterfaceRequestContext.class );
final boolean hasLowerOrEqualPriority = context.map( c -> c.compareTo( DualityInterface.this.priority ) <= 0 ).orElse( false );
if( hasLowerOrEqualPriority )
{
return null;
}
@ -1319,7 +1350,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
@Nullable
@Override
public IStorageMonitorable getInventory( BaseActionSource src )
public IStorageMonitorable getInventory( IActionSource src )
{
return DualityInterface.this.getMonitorable( src, DualityInterface.this );
}

View file

@ -23,7 +23,7 @@ import net.minecraft.item.ItemStack;
import net.minecraftforge.items.IItemHandler;
import appeng.api.networking.IGridNode;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionSource;
public interface IContainerCraftingPacket
@ -44,7 +44,7 @@ public interface IContainerCraftingPacket
/**
* @return who are we?
*/
BaseActionSource getActionSource();
IActionSource getActionSource();
/**
* @return consume items?

View file

@ -33,7 +33,7 @@ import appeng.api.networking.crafting.ICraftingGrid;
import appeng.api.networking.crafting.ICraftingJob;
import appeng.api.networking.crafting.ICraftingLink;
import appeng.api.networking.crafting.ICraftingRequester;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.storage.data.IAEItemStack;
import appeng.util.InventoryAdaptor;
@ -81,7 +81,7 @@ public class MultiCraftingTracker
}
}
public boolean handleCrafting( final int x, final long itemToCraft, final IAEItemStack ais, final InventoryAdaptor d, final World w, final IGrid g, final ICraftingGrid cg, final BaseActionSource mySrc )
public boolean handleCrafting( final int x, final long itemToCraft, final IAEItemStack ais, final InventoryAdaptor d, final World w, final IGrid g, final ICraftingGrid cg, final IActionSource mySrc )
{
if( ais != null && d.simulateAdd( ais.getItemStack() ).isEmpty() )
{

View file

@ -32,11 +32,10 @@ import appeng.api.features.IWirelessTermHandler;
import appeng.api.implementations.guiobjects.IPortableCell;
import appeng.api.implementations.tiles.IWirelessAccessPoint;
import appeng.api.networking.IGrid;
import appeng.api.networking.IGridHost;
import appeng.api.networking.IGridNode;
import appeng.api.networking.IMachineSet;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionHost;
import appeng.api.networking.security.IActionSource;
import appeng.api.networking.storage.IStorageGrid;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.IMEMonitorHandlerReceiver;
@ -44,8 +43,6 @@ import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import appeng.api.util.AECableType;
import appeng.api.util.AEPartLocation;
import appeng.api.util.DimensionalCoord;
import appeng.api.util.IConfigManager;
import appeng.container.interfaces.IInventorySlotAware;
@ -87,9 +84,9 @@ public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, II
// :P
}
if( obj instanceof IGridHost )
if( obj instanceof IActionHost )
{
final IGridNode n = ( (IGridHost) obj ).getGridNode( AEPartLocation.INTERNAL );
final IGridNode n = ( (IActionHost) obj ).getActionableNode();
if( n != null )
{
this.targetGrid = n.getGrid();
@ -225,7 +222,7 @@ public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, II
}
@Override
public IAEItemStack injectItems( final IAEItemStack input, final Actionable type, final BaseActionSource src )
public IAEItemStack injectItems( final IAEItemStack input, final Actionable type, final IActionSource src )
{
if( this.itemStorage != null )
{
@ -235,7 +232,7 @@ public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, II
}
@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( this.itemStorage != null )
{
@ -280,24 +277,6 @@ public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, II
return this.wth.getConfigManager( this.effectiveItem );
}
@Override
public IGridNode getGridNode( final AEPartLocation dir )
{
return this.getActionableNode();
}
@Override
public AECableType getCableConnectionType( final AEPartLocation dir )
{
return AECableType.NONE;
}
@Override
public void securityBreak()
{
}
@Override
public IGridNode getActionableNode()
{

View file

@ -22,7 +22,6 @@ package appeng.integration.modules.jei;
import java.util.ArrayList;
import java.util.List;
import mezz.jei.api.recipe.IRecipeCategory;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.I18n;
import net.minecraft.item.ItemStack;
@ -35,6 +34,7 @@ import mezz.jei.api.gui.IDrawableStatic;
import mezz.jei.api.gui.IGuiItemStackGroup;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.IRecipeCategory;
import appeng.api.AEApi;
import appeng.api.config.CondenserOutput;

View file

@ -19,13 +19,13 @@
package appeng.integration.modules.jei;
import mezz.jei.api.recipe.IRecipeWrapperFactory;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import mezz.jei.api.IGuiHelper;
import mezz.jei.api.gui.IDrawable;
import mezz.jei.api.recipe.IRecipeWrapper;
import mezz.jei.api.recipe.IRecipeWrapperFactory;
import appeng.api.config.CondenserOutput;
import appeng.core.AppEng;

View file

@ -26,7 +26,6 @@ import javax.annotation.Nullable;
import com.google.common.base.Splitter;
import mezz.jei.api.recipe.IRecipeWrapper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.I18n;
import net.minecraft.item.ItemStack;
@ -34,6 +33,7 @@ import net.minecraftforge.fml.client.config.HoverChecker;
import mezz.jei.api.gui.IDrawable;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.IRecipeWrapper;
import appeng.api.config.CondenserOutput;

View file

@ -19,17 +19,17 @@
package appeng.integration.modules.jei;
import mezz.jei.api.IJeiHelpers;
import mezz.jei.api.recipe.IRecipeCategory;
import mezz.jei.api.recipe.IRecipeCategoryRegistration;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.ResourceLocation;
import mezz.jei.api.IGuiHelper;
import mezz.jei.api.IJeiHelpers;
import mezz.jei.api.gui.IDrawable;
import mezz.jei.api.gui.IGuiItemStackGroup;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.IRecipeCategory;
import mezz.jei.api.recipe.IRecipeCategoryRegistration;
import appeng.core.AppEng;

View file

@ -20,9 +20,9 @@ package appeng.integration.modules.jei;
import mezz.jei.api.recipe.IRecipeWrapper;
import mezz.jei.api.recipe.IRecipeWrapperFactory;
import appeng.api.features.IGrinderRecipe;
import mezz.jei.api.recipe.IRecipeWrapperFactory;
class GrinderRecipeHandler implements IRecipeWrapperFactory<IGrinderRecipe>

View file

@ -23,13 +23,13 @@ import java.awt.Color;
import java.util.ArrayList;
import java.util.List;
import mezz.jei.api.recipe.IRecipeWrapper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.item.ItemStack;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.IRecipeWrapper;
import appeng.api.features.IGrinderRecipe;

View file

@ -19,8 +19,6 @@
package appeng.integration.modules.jei;
import mezz.jei.api.recipe.IRecipeCategory;
import mezz.jei.api.recipe.IRecipeCategoryRegistration;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.ResourceLocation;
@ -32,6 +30,7 @@ import mezz.jei.api.gui.IDrawableStatic;
import mezz.jei.api.gui.IGuiItemStackGroup;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.IRecipeCategory;
import appeng.core.AppEng;

View file

@ -20,9 +20,9 @@ package appeng.integration.modules.jei;
import mezz.jei.api.recipe.IRecipeWrapper;
import mezz.jei.api.recipe.IRecipeWrapperFactory;
import appeng.api.features.IInscriberRecipe;
import mezz.jei.api.recipe.IRecipeWrapperFactory;
class InscriberRecipeHandler implements IRecipeWrapperFactory<IInscriberRecipe>

View file

@ -23,10 +23,10 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import mezz.jei.api.recipe.IRecipeWrapper;
import net.minecraft.item.ItemStack;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.IRecipeWrapper;
import appeng.api.features.IInscriberRecipe;

View file

@ -23,9 +23,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import appeng.api.features.IGrinderRecipe;
import appeng.recipes.game.ShapedRecipe;
import appeng.recipes.game.ShapelessRecipe;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
@ -43,6 +40,7 @@ import appeng.api.config.CondenserOutput;
import appeng.api.definitions.IDefinitions;
import appeng.api.definitions.IItemDefinition;
import appeng.api.definitions.IMaterials;
import appeng.api.features.IGrinderRecipe;
import appeng.api.features.IInscriberRecipe;
import appeng.container.implementations.ContainerCraftingTerm;
import appeng.container.implementations.ContainerPatternTerm;
@ -51,6 +49,8 @@ import appeng.core.features.AEFeature;
import appeng.core.localization.GuiText;
import appeng.integration.Integrations;
import appeng.items.parts.ItemFacade;
import appeng.recipes.game.ShapedRecipe;
import appeng.recipes.game.ShapelessRecipe;
@mezz.jei.api.JEIPlugin

View file

@ -24,10 +24,10 @@ import java.util.List;
import com.google.common.collect.Lists;
import mezz.jei.api.recipe.IRecipeWrapper;
import net.minecraft.item.ItemStack;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.IRecipeWrapper;
import appeng.api.exceptions.MissingIngredientError;
import appeng.api.exceptions.RegistrationError;

View file

@ -58,7 +58,6 @@ import appeng.api.config.FuzzyMode;
import appeng.api.implementations.items.IItemGroup;
import appeng.api.implementations.items.IStorageCell;
import appeng.api.implementations.tiles.IColorableTile;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.storage.ICellInventory;
import appeng.api.storage.ICellInventoryHandler;
import appeng.api.storage.IMEInventory;
@ -77,6 +76,7 @@ import appeng.items.contents.CellConfig;
import appeng.items.contents.CellUpgrades;
import appeng.items.misc.ItemPaintBall;
import appeng.items.tools.powered.powersink.AEBasePoweredItem;
import appeng.me.helpers.BaseActionSource;
import appeng.me.storage.CellInventoryHandler;
import appeng.tile.misc.TilePaint;
import appeng.util.ItemSorters;

View file

@ -52,7 +52,6 @@ import appeng.api.config.Actionable;
import appeng.api.config.FuzzyMode;
import appeng.api.config.Upgrades;
import appeng.api.implementations.items.IStorageCell;
import appeng.api.networking.security.PlayerSource;
import appeng.api.storage.ICellInventory;
import appeng.api.storage.ICellInventoryHandler;
import appeng.api.storage.IMEInventory;
@ -76,6 +75,7 @@ import appeng.items.contents.CellConfig;
import appeng.items.contents.CellUpgrades;
import appeng.items.misc.ItemPaintBall;
import appeng.items.tools.powered.powersink.AEBasePoweredItem;
import appeng.me.helpers.PlayerSource;
import appeng.me.storage.CellInventoryHandler;
import appeng.tile.misc.TilePaint;
import appeng.util.LookDirection;

View file

@ -67,7 +67,7 @@ import appeng.api.networking.events.MENetworkCraftingCpuChange;
import appeng.api.networking.events.MENetworkCraftingPatternChange;
import appeng.api.networking.events.MENetworkEventSubscribe;
import appeng.api.networking.events.MENetworkPostCacheConstruction;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.networking.storage.IStorageGrid;
import appeng.api.storage.ICellProvider;
import appeng.api.storage.IMEInventoryHandler;
@ -80,6 +80,7 @@ import appeng.crafting.CraftingLink;
import appeng.crafting.CraftingLinkNexus;
import appeng.crafting.CraftingWatcher;
import appeng.me.cluster.implementations.CraftingCPUCluster;
import appeng.me.helpers.BaseActionSource;
import appeng.me.helpers.GenericInterestManager;
import appeng.tile.crafting.TileCraftingStorageTile;
import appeng.tile.crafting.TileCraftingTile;
@ -431,7 +432,7 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
}
@Override
public IAEStack injectItems( IAEStack input, final Actionable type, final BaseActionSource src )
public IAEStack injectItems( IAEStack input, final Actionable type, final IActionSource src )
{
for( final CraftingCPUCluster cpu : this.craftingCPUClusters )
{
@ -442,7 +443,7 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
}
@Override
public IAEStack extractItems( final IAEStack request, final Actionable mode, final BaseActionSource src )
public IAEStack extractItems( final IAEStack request, final Actionable mode, final IActionSource src )
{
return null;
}
@ -498,7 +499,7 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
}
@Override
public Future<ICraftingJob> beginCraftingJob( final World world, final IGrid grid, final BaseActionSource actionSrc, final IAEItemStack slotItem, final ICraftingCallback cb )
public Future<ICraftingJob> beginCraftingJob( final World world, final IGrid grid, final IActionSource actionSrc, final IAEItemStack slotItem, final ICraftingCallback cb )
{
if( world == null || grid == null || actionSrc == null || slotItem == null )
{
@ -511,7 +512,7 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
}
@Override
public ICraftingLink submitJob( final ICraftingJob job, final ICraftingRequester requestingMachine, final ICraftingCPU target, final boolean prioritizePower, final BaseActionSource src )
public ICraftingLink submitJob( final ICraftingJob job, final ICraftingRequester requestingMachine, final ICraftingCPU target, final boolean prioritizePower, final IActionSource src )
{
if( job.isSimulation() )
{

View file

@ -34,10 +34,9 @@ import appeng.api.networking.IGridNode;
import appeng.api.networking.IGridStorage;
import appeng.api.networking.events.MENetworkCellArrayUpdate;
import appeng.api.networking.events.MENetworkEventSubscribe;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionHost;
import appeng.api.networking.security.IActionSource;
import appeng.api.networking.security.ISecurityGrid;
import appeng.api.networking.security.MachineSource;
import appeng.api.networking.storage.IStackWatcher;
import appeng.api.networking.storage.IStackWatcherHost;
import appeng.api.networking.storage.IStorageGrid;
@ -50,7 +49,9 @@ import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IAEStack;
import appeng.api.storage.data.IItemList;
import appeng.me.helpers.BaseActionSource;
import appeng.me.helpers.GenericInterestManager;
import appeng.me.helpers.MachineSource;
import appeng.me.storage.ItemWatcher;
import appeng.me.storage.NetworkInventoryHandler;
@ -161,7 +162,7 @@ public class GridStorageCache implements IStorageGrid
this.inactiveCellProviders.remove( cc );
this.activeCellProviders.add( cc );
BaseActionSource actionSrc = new BaseActionSource();
IActionSource actionSrc = new BaseActionSource();
if( cc instanceof IActionHost )
{
actionSrc = new MachineSource( (IActionHost) cc );
@ -188,7 +189,7 @@ public class GridStorageCache implements IStorageGrid
this.activeCellProviders.remove( cc );
this.inactiveCellProviders.add( cc );
BaseActionSource actionSrc = new BaseActionSource();
IActionSource actionSrc = new BaseActionSource();
if( cc instanceof IActionHost )
{
@ -254,7 +255,7 @@ public class GridStorageCache implements IStorageGrid
tracker.applyChanges();
}
private void postChangesToNetwork( final StorageChannel chan, final int upOrDown, final IItemList availableItems, final BaseActionSource src )
private void postChangesToNetwork( final StorageChannel chan, final int upOrDown, final IItemList availableItems, final IActionSource src )
{
switch( chan )
{
@ -317,7 +318,7 @@ public class GridStorageCache implements IStorageGrid
}
@Override
public void postAlterationOfStoredItems( final StorageChannel chan, final Iterable<? extends IAEStack> input, final BaseActionSource src )
public void postAlterationOfStoredItems( final StorageChannel chan, final Iterable<? extends IAEStack> input, final IActionSource src )
{
if( chan == StorageChannel.ITEMS )
{
@ -371,9 +372,9 @@ public class GridStorageCache implements IStorageGrid
final StorageChannel channel;
final int up_or_down;
final IItemList list;
final BaseActionSource src;
final IActionSource src;
public CellChangeTrackerRecord( final StorageChannel channel, final int i, final IMEInventoryHandler<? extends IAEStack> h, final BaseActionSource actionSrc )
public CellChangeTrackerRecord( final StorageChannel channel, final int i, final IMEInventoryHandler<? extends IAEStack> h, final IActionSource actionSrc )
{
this.channel = channel;
this.up_or_down = i;
@ -404,7 +405,7 @@ public class GridStorageCache implements IStorageGrid
final List<CellChangeTrackerRecord> data = new LinkedList<>();
public void postChanges( final StorageChannel channel, final int i, final IMEInventoryHandler<? extends IAEStack> h, final BaseActionSource actionSrc )
public void postChanges( final StorageChannel channel, final int i, final IMEInventoryHandler<? extends IAEStack> h, final IActionSource actionSrc )
{
this.data.add( new CellChangeTrackerRecord( channel, i, h, actionSrc ) );
}

View file

@ -36,7 +36,7 @@ import com.google.common.collect.Lists;
import appeng.api.config.AccessRestriction;
import appeng.api.config.Actionable;
import appeng.api.networking.events.MENetworkStorageEvent;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.IMEMonitorHandlerReceiver;
@ -86,7 +86,7 @@ public class NetworkMonitor<T extends IAEStack<T>> implements IMEMonitor<T>
}
@Override
public T extractItems( final T request, final Actionable mode, final BaseActionSource src )
public T extractItems( final T request, final Actionable mode, final IActionSource src )
{
if( mode == Actionable.SIMULATE )
{
@ -150,7 +150,7 @@ public class NetworkMonitor<T extends IAEStack<T>> implements IMEMonitor<T>
}
@Override
public T injectItems( final T input, final Actionable mode, final BaseActionSource src )
public T injectItems( final T input, final Actionable mode, final IActionSource src )
{
if( mode == Actionable.SIMULATE )
{
@ -207,7 +207,7 @@ public class NetworkMonitor<T extends IAEStack<T>> implements IMEMonitor<T>
return this.listeners.entrySet().iterator();
}
private T monitorDifference( final IAEStack original, final T leftOvers, final boolean extraction, final BaseActionSource src )
private T monitorDifference( final IAEStack original, final T leftOvers, final boolean extraction, final IActionSource src )
{
final T diff = (T) original.copy();
@ -228,7 +228,7 @@ public class NetworkMonitor<T extends IAEStack<T>> implements IMEMonitor<T>
return leftOvers;
}
private void notifyListenersOfChange( final Iterable<T> diff, final BaseActionSource src )
private void notifyListenersOfChange( final Iterable<T> diff, final IActionSource src )
{
this.hasChanged = true;
final Iterator<Entry<IMEMonitorHandlerReceiver<T>, Object>> i = this.getListeners();
@ -248,12 +248,12 @@ public class NetworkMonitor<T extends IAEStack<T>> implements IMEMonitor<T>
}
}
private void postChangesToListeners( final Iterable<T> changes, final BaseActionSource src )
private void postChangesToListeners( final Iterable<T> changes, final IActionSource src )
{
this.postChange( true, changes, src );
}
protected void postChange( final boolean add, final Iterable<T> changes, final BaseActionSource src )
protected void postChange( final boolean add, final Iterable<T> changes, final IActionSource src )
{
if( this.localDepthSemaphore > 0 || GLOBAL_DEPTH.contains( this ) )
{

View file

@ -55,8 +55,7 @@ import appeng.api.networking.crafting.ICraftingPatternDetails;
import appeng.api.networking.crafting.ICraftingRequester;
import appeng.api.networking.energy.IEnergyGrid;
import appeng.api.networking.events.MENetworkCraftingCpuChange;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.MachineSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.networking.storage.IStorageGrid;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.IMEMonitorHandlerReceiver;
@ -73,6 +72,7 @@ import appeng.crafting.CraftingWatcher;
import appeng.crafting.MECraftingInventory;
import appeng.me.cache.CraftingGridCache;
import appeng.me.cluster.IAECluster;
import appeng.me.helpers.MachineSource;
import appeng.tile.crafting.TileCraftingMonitorTile;
import appeng.tile.crafting.TileCraftingTile;
import appeng.util.Platform;
@ -236,7 +236,7 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU
return false;
}
public IAEStack injectItems( final IAEStack input, final Actionable type, final BaseActionSource src )
public IAEStack injectItems( final IAEStack input, final Actionable type, final IActionSource src )
{
if( !( input instanceof IAEItemStack ) )
{
@ -365,7 +365,7 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU
return input;
}
private void postChange( final IAEItemStack diff, final BaseActionSource src )
private void postChange( final IAEItemStack diff, final IActionSource src )
{
final Iterator<Entry<IMEMonitorHandlerReceiver<IAEItemStack>, Object>> i = this.getListeners();
@ -469,7 +469,7 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU
{
return null;
}
return (TileCraftingTile) this.machineSrc.via;
return (TileCraftingTile) this.machineSrc.machine().get();
}
private IGrid getGrid()
@ -844,7 +844,7 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU
this.markDirty();
}
public ICraftingLink submitJob( final IGrid g, final ICraftingJob job, final BaseActionSource src, final ICraftingRequester requestingMachine )
public ICraftingLink submitJob( final IGrid g, final ICraftingJob job, final IActionSource src, final ICraftingRequester requestingMachine )
{
if( !this.tasks.isEmpty() || !this.waitingFor.isEmpty() )
{
@ -935,7 +935,7 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU
}
@Override
public BaseActionSource getActionSource()
public IActionSource getActionSource()
{
return this.machineSrc;
}

View file

@ -0,0 +1,50 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.me.helpers;
import java.util.Optional;
import net.minecraft.entity.player.EntityPlayer;
import appeng.api.networking.security.IActionHost;
import appeng.api.networking.security.IActionSource;
public class BaseActionSource implements IActionSource
{
@Override
public Optional<EntityPlayer> player()
{
return Optional.empty();
}
@Override
public Optional<IActionHost> machine()
{
return Optional.empty();
}
@Override
public <T> Optional<T> context( Class<T> key )
{
return Optional.empty();
}
}

View file

@ -0,0 +1,58 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.me.helpers;
import java.util.Optional;
import net.minecraft.entity.player.EntityPlayer;
import appeng.api.networking.security.IActionHost;
import appeng.api.networking.security.IActionSource;
public class MachineSource implements IActionSource
{
private final IActionHost via;
public MachineSource( final IActionHost v )
{
this.via = v;
}
@Override
public Optional<EntityPlayer> player()
{
return Optional.empty();
}
@Override
public Optional<IActionHost> machine()
{
return Optional.of( this.via );
}
@Override
public <T> Optional<T> context( Class<T> key )
{
return Optional.empty();
}
}

View file

@ -0,0 +1,62 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.me.helpers;
import java.util.Optional;
import com.google.common.base.Preconditions;
import net.minecraft.entity.player.EntityPlayer;
import appeng.api.networking.security.IActionHost;
import appeng.api.networking.security.IActionSource;
public class PlayerSource implements IActionSource
{
private final EntityPlayer player;
private final IActionHost via;
public PlayerSource( final EntityPlayer p, final IActionHost v )
{
Preconditions.checkNotNull( p );
this.player = p;
this.via = v;
}
@Override
public Optional<EntityPlayer> player()
{
return Optional.of( this.player );
}
@Override
public Optional<IActionHost> machine()
{
return Optional.ofNullable( this.via );
}
@Override
public <T> Optional<T> context( Class<T> key )
{
return Optional.empty();
}
}

View file

@ -33,7 +33,7 @@ import appeng.api.config.Actionable;
import appeng.api.config.FuzzyMode;
import appeng.api.exceptions.AppEngException;
import appeng.api.implementations.items.IStorageCell;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.storage.ICellInventory;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.IMEInventoryHandler;
@ -202,7 +202,7 @@ public class CellInventory implements ICellInventory
}
@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 )
{
@ -299,7 +299,7 @@ public class CellInventory implements ICellInventory
}
@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 )
{

View file

@ -24,7 +24,7 @@ import net.minecraft.item.ItemStack;
import appeng.api.AEApi;
import appeng.api.config.AccessRestriction;
import appeng.api.config.Actionable;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEItemStack;
@ -58,7 +58,7 @@ public class CreativeCellInventory implements IMEInventoryHandler<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 )
{
final IAEItemStack local = this.itemListCache.findPrecise( input );
if( local == null )
@ -70,7 +70,7 @@ public class CreativeCellInventory implements IMEInventoryHandler<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 )
{
final IAEItemStack local = this.itemListCache.findPrecise( request );
if( local == null )

View file

@ -23,7 +23,7 @@ import net.minecraft.item.ItemStack;
import appeng.api.config.Actionable;
import appeng.api.implementations.tiles.IChestOrDrive;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.storage.ICellHandler;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.data.IAEStack;
@ -46,7 +46,7 @@ public class DriveWatcher<T extends IAEStack<T>> extends MEInventoryHandler<T>
}
@Override
public T injectItems( final T input, final Actionable type, final BaseActionSource src )
public T injectItems( final T input, final Actionable type, final IActionSource src )
{
final long size = input.getStackSize();
@ -67,7 +67,7 @@ public class DriveWatcher<T extends IAEStack<T>> extends MEInventoryHandler<T>
}
@Override
public T extractItems( final T request, final Actionable type, final BaseActionSource src )
public T extractItems( final T request, final Actionable type, final IActionSource src )
{
final T a = super.extractItems( request, type, src );

View file

@ -19,7 +19,7 @@
package appeng.me.storage;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.networking.ticking.TickRateModulation;
@ -28,6 +28,6 @@ public interface ITickingMonitor
TickRateModulation onTick();
void setActionSource( BaseActionSource actionSource );
void setActionSource( IActionSource actionSource );
}

View file

@ -22,7 +22,7 @@ package appeng.me.storage;
import appeng.api.config.AccessRestriction;
import appeng.api.config.Actionable;
import appeng.api.config.IncludeExclude;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.StorageChannel;
@ -96,7 +96,7 @@ public class MEInventoryHandler<T extends IAEStack<T>> implements IMEInventoryHa
}
@Override
public T injectItems( final T input, final Actionable type, final BaseActionSource src )
public T injectItems( final T input, final Actionable type, final IActionSource src )
{
if( !this.canAccept( input ) )
{
@ -107,7 +107,7 @@ public class MEInventoryHandler<T extends IAEStack<T>> implements IMEInventoryHa
}
@Override
public T extractItems( final T request, final Actionable type, final BaseActionSource src )
public T extractItems( final T request, final Actionable type, final IActionSource src )
{
if( !this.hasReadAccess )
{

View file

@ -32,7 +32,7 @@ import appeng.api.AEApi;
import appeng.api.config.AccessRestriction;
import appeng.api.config.Actionable;
import appeng.api.config.StorageFilter;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.networking.ticking.TickRateModulation;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.IMEMonitorHandlerReceiver;
@ -51,7 +51,7 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>, ITickingMo
private final IItemList<IAEItemStack> list = AEApi.instance().storage().createItemList();
private final HashMap<IMEMonitorHandlerReceiver<IAEItemStack>, Object> listeners = new HashMap<>();
private final NavigableMap<Integer, CachedItemStack> memory;
private BaseActionSource mySource;
private IActionSource mySource;
private StorageFilter mode = StorageFilter.EXTRACTABLE_ONLY;
public MEMonitorIInventory( final InventoryAdaptor adaptor )
@ -73,7 +73,7 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>, ITickingMo
}
@Override
public IAEItemStack injectItems( final IAEItemStack input, final Actionable type, final BaseActionSource src )
public IAEItemStack injectItems( final IAEItemStack input, final Actionable type, final IActionSource src )
{
ItemStack out = ItemStack.EMPTY;
@ -103,7 +103,7 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>, ITickingMo
}
@Override
public IAEItemStack extractItems( final IAEItemStack request, final Actionable type, final BaseActionSource src )
public IAEItemStack extractItems( final IAEItemStack request, final Actionable type, final IActionSource src )
{
ItemStack out = ItemStack.EMPTY;
@ -325,13 +325,13 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>, ITickingMo
this.mode = mode;
}
private BaseActionSource getActionSource()
private IActionSource getActionSource()
{
return this.mySource;
}
@Override
public void setActionSource( final BaseActionSource mySource )
public void setActionSource( final IActionSource mySource )
{
this.mySource = mySource;
}

View file

@ -23,7 +23,7 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.networking.storage.IBaseMonitor;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.IMEMonitor;
@ -39,7 +39,7 @@ public class MEMonitorPassThrough<T extends IAEStack<T>> extends MEPassThrough<T
{
private final HashMap<IMEMonitorHandlerReceiver<T>, Object> listeners = new HashMap<>();
private BaseActionSource changeSource;
private IActionSource changeSource;
private IMEMonitor<T> monitor;
public MEMonitorPassThrough( final IMEInventory<T> i, final StorageChannel channel )
@ -118,7 +118,7 @@ public class MEMonitorPassThrough<T extends IAEStack<T>> extends MEPassThrough<T
}
@Override
public void postChange( final IBaseMonitor<T> monitor, final Iterable<T> change, final BaseActionSource source )
public void postChange( final IBaseMonitor<T> monitor, final Iterable<T> change, final IActionSource source )
{
final Iterator<Entry<IMEMonitorHandlerReceiver<T>, Object>> i = this.listeners.entrySet().iterator();
while( i.hasNext() )
@ -155,12 +155,12 @@ public class MEMonitorPassThrough<T extends IAEStack<T>> extends MEPassThrough<T
}
}
private BaseActionSource getChangeSource()
private IActionSource getChangeSource()
{
return this.changeSource;
}
public void setChangeSource( final BaseActionSource changeSource )
public void setChangeSource( final IActionSource changeSource )
{
this.changeSource = changeSource;
}

View file

@ -21,7 +21,7 @@ package appeng.me.storage;
import appeng.api.config.AccessRestriction;
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.IMEInventoryHandler;
import appeng.api.storage.StorageChannel;
@ -52,13 +52,13 @@ public class MEPassThrough<T extends IAEStack<T>> implements IMEInventoryHandler
}
@Override
public T injectItems( final T input, final Actionable type, final BaseActionSource src )
public T injectItems( final T input, final Actionable type, final IActionSource src )
{
return this.internal.injectItems( input, type, src );
}
@Override
public T extractItems( final T request, final Actionable type, final BaseActionSource src )
public T extractItems( final T request, final Actionable type, final IActionSource src )
{
return this.internal.extractItems( request, type, src );
}

View file

@ -32,10 +32,8 @@ import appeng.api.config.Actionable;
import appeng.api.config.SecurityPermissions;
import appeng.api.networking.IGrid;
import appeng.api.networking.IGridNode;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.networking.security.ISecurityGrid;
import appeng.api.networking.security.MachineSource;
import appeng.api.networking.security.PlayerSource;
import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEStack;
@ -77,7 +75,7 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
}
@Override
public T injectItems( T input, final Actionable type, final BaseActionSource src )
public T injectItems( T input, final Actionable type, final IActionSource src )
{
if( this.diveList( this, type ) )
{
@ -137,20 +135,20 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
return false;
}
private boolean testPermission( final BaseActionSource src, final SecurityPermissions permission )
private boolean testPermission( final IActionSource src, final SecurityPermissions permission )
{
if( src.isPlayer() )
if( src.player().isPresent() )
{
if( !this.security.hasPermission( ( (PlayerSource) src ).player, permission ) )
if( !this.security.hasPermission( src.player().get(), permission ) )
{
return true;
}
}
else if( src.isMachine() )
else if( src.machine().isPresent() )
{
if( this.security.isAvailable() )
{
final IGridNode n = ( (MachineSource) src ).via.getActionableNode();
final IGridNode n = src.machine().get().getActionableNode();
if( n == null )
{
return true;
@ -197,7 +195,7 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
}
@Override
public T extractItems( T request, final Actionable mode, final BaseActionSource src )
public T extractItems( T request, final Actionable mode, final IActionSource src )
{
if( this.diveList( this, mode ) )
{

View file

@ -21,7 +21,7 @@ package appeng.me.storage;
import appeng.api.config.AccessRestriction;
import appeng.api.config.Actionable;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEStack;
@ -32,13 +32,13 @@ public class NullInventory<T extends IAEStack<T>> implements IMEInventoryHandler
{
@Override
public T injectItems( final T input, final Actionable mode, final BaseActionSource src )
public T injectItems( final T input, final Actionable mode, final IActionSource src )
{
return input;
}
@Override
public T extractItems( final T request, final Actionable mode, final BaseActionSource src )
public T extractItems( final T request, final Actionable mode, final IActionSource src )
{
return null;
}

View file

@ -26,8 +26,7 @@ import appeng.api.config.AccessRestriction;
import appeng.api.config.Actionable;
import appeng.api.config.SecurityPermissions;
import appeng.api.implementations.items.IBiometricCard;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.PlayerSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEItemStack;
@ -48,7 +47,7 @@ public class SecurityStationInventory implements IMEInventoryHandler<IAEItemStac
}
@Override
public IAEItemStack injectItems( final IAEItemStack input, final Actionable type, final BaseActionSource src )
public IAEItemStack injectItems( final IAEItemStack input, final Actionable type, final IActionSource src )
{
if( this.hasPermission( src ) )
{
@ -70,13 +69,13 @@ public class SecurityStationInventory implements IMEInventoryHandler<IAEItemStac
return input;
}
private boolean hasPermission( final BaseActionSource src )
private boolean hasPermission( final IActionSource src )
{
if( src.isPlayer() )
if( src.player().isPresent() )
{
try
{
return this.securityTile.getProxy().getSecurity().hasPermission( ( (PlayerSource) src ).player, SecurityPermissions.SECURITY );
return this.securityTile.getProxy().getSecurity().hasPermission( src.player().get(), SecurityPermissions.SECURITY );
}
catch( final GridAccessException e )
{
@ -87,7 +86,7 @@ public class SecurityStationInventory implements IMEInventoryHandler<IAEItemStac
}
@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( this.hasPermission( src ) )
{

View file

@ -44,8 +44,7 @@ import appeng.api.networking.energy.IEnergyGrid;
import appeng.api.networking.events.MENetworkChannelsChanged;
import appeng.api.networking.events.MENetworkEventSubscribe;
import appeng.api.networking.events.MENetworkPowerStatusChange;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.MachineSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.networking.storage.IStorageGrid;
import appeng.api.networking.ticking.IGridTickable;
import appeng.api.networking.ticking.TickRateModulation;
@ -63,6 +62,7 @@ import appeng.core.sync.packets.PacketTransitionEffect;
import appeng.hooks.TickHandler;
import appeng.items.parts.PartModels;
import appeng.me.GridAccessException;
import appeng.me.helpers.MachineSource;
import appeng.parts.PartBasicState;
import appeng.util.IWorldCallable;
import appeng.util.Platform;
@ -80,7 +80,7 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
return MODELS.getModels();
}
private final BaseActionSource mySrc = new MachineSource( this );
private final IActionSource mySrc = new MachineSource( this );
private boolean isAccepting = true;
private boolean breaking = false;

View file

@ -42,8 +42,7 @@ import appeng.api.networking.crafting.ICraftingGrid;
import appeng.api.networking.crafting.ICraftingLink;
import appeng.api.networking.crafting.ICraftingRequester;
import appeng.api.networking.energy.IEnergyGrid;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.MachineSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.networking.ticking.TickRateModulation;
import appeng.api.networking.ticking.TickingRequest;
import appeng.api.parts.IPartCollisionHelper;
@ -60,6 +59,7 @@ import appeng.helpers.MultiCraftingTracker;
import appeng.helpers.Reflected;
import appeng.items.parts.PartModels;
import appeng.me.GridAccessException;
import appeng.me.helpers.MachineSource;
import appeng.parts.PartModel;
import appeng.util.InventoryAdaptor;
import appeng.util.Platform;
@ -81,7 +81,7 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
public static final IPartModel MODELS_HAS_CHANNEL = new PartModel( MODEL_BASE, new ResourceLocation( AppEng.MOD_ID, "part/export_bus_has_channel" ) );
private final MultiCraftingTracker craftingTracker = new MultiCraftingTracker( this, 9 );
private final BaseActionSource mySrc;
private final IActionSource mySrc;
private long itemToSend = 1;
private boolean didSomething = false;
private int nextSlot = 0;

View file

@ -57,7 +57,7 @@ import appeng.api.networking.events.MENetworkCellArrayUpdate;
import appeng.api.networking.events.MENetworkChannelsChanged;
import appeng.api.networking.events.MENetworkEventSubscribe;
import appeng.api.networking.events.MENetworkPowerStatusChange;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.parts.IPart;
import appeng.api.parts.IPartCollisionHelper;
import appeng.api.parts.IPartHost;
@ -427,7 +427,7 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
}
@Override
public IAEItemStack injectItems( final IAEItemStack input, final Actionable type, final BaseActionSource src )
public IAEItemStack injectItems( final IAEItemStack input, final Actionable type, final IActionSource src )
{
if( this.blocked || input == null || input.getStackSize() <= 0 )
{
@ -599,7 +599,7 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
}
@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 )
{
return null;
}

View file

@ -36,8 +36,7 @@ import appeng.api.config.Upgrades;
import appeng.api.networking.IGridNode;
import appeng.api.networking.energy.IEnergyGrid;
import appeng.api.networking.energy.IEnergySource;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.MachineSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.networking.ticking.TickRateModulation;
import appeng.api.networking.ticking.TickingRequest;
import appeng.api.parts.IPartCollisionHelper;
@ -52,6 +51,7 @@ import appeng.core.sync.GuiBridge;
import appeng.helpers.Reflected;
import appeng.items.parts.PartModels;
import appeng.me.GridAccessException;
import appeng.me.helpers.MachineSource;
import appeng.parts.PartModel;
import appeng.util.InventoryAdaptor;
import appeng.util.Platform;
@ -70,7 +70,7 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
@PartModels
public static final IPartModel MODELS_HAS_CHANNEL = new PartModel( MODEL_BASE, new ResourceLocation( AppEng.MOD_ID, "part/import_bus_has_channel" ) );
private final BaseActionSource source;
private final IActionSource source;
private IMEInventory<IAEItemStack> destination = null;
private IAEItemStack lastItemChecked = null;
private int itemToSend; // used in tickingRequest

View file

@ -54,7 +54,7 @@ import appeng.api.networking.events.MENetworkChannelsChanged;
import appeng.api.networking.events.MENetworkCraftingPatternChange;
import appeng.api.networking.events.MENetworkEventSubscribe;
import appeng.api.networking.events.MENetworkPowerStatusChange;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.networking.storage.IBaseMonitor;
import appeng.api.networking.storage.IStackWatcher;
import appeng.api.networking.storage.IStackWatcherHost;
@ -354,7 +354,7 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH
}
@Override
public void onStackChange( final IItemList o, final IAEStack fullStack, final IAEStack diffStack, final BaseActionSource src, final StorageChannel chan )
public void onStackChange( final IItemList o, final IAEStack fullStack, final IAEStack diffStack, final IActionSource src, final StorageChannel chan )
{
if( chan == StorageChannel.ITEMS && fullStack.equals( this.config.getAEStackInSlot( 0 ) ) && this.getInstalledUpgrades( Upgrades.FUZZY ) == 0 )
{
@ -391,7 +391,7 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH
}
@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 )
{
this.updateReportingValue( (IMEMonitor<IAEItemStack>) monitor );
}

View file

@ -30,7 +30,7 @@ import net.minecraft.item.ItemStack;
import net.minecraftforge.items.IItemHandler;
import appeng.api.config.Actionable;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.networking.storage.IBaseMonitor;
import appeng.api.networking.ticking.TickRateModulation;
import appeng.api.storage.IMEInventory;
@ -52,7 +52,7 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
private final Map<IMEMonitorHandlerReceiver<IAEItemStack>, Object> listeners = new HashMap<>();
private BaseActionSource mySource;
private IActionSource mySource;
private final IItemHandler itemHandler;
@ -66,7 +66,7 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
}
@Override
public IAEItemStack injectItems( IAEItemStack iox, Actionable type, BaseActionSource src )
public IAEItemStack injectItems( IAEItemStack iox, Actionable type, IActionSource src )
{
ItemStack orgInput = iox.getItemStack();
ItemStack remaining = orgInput;
@ -96,7 +96,7 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
}
@Override
public IAEItemStack extractItems( IAEItemStack request, Actionable mode, BaseActionSource src )
public IAEItemStack extractItems( IAEItemStack request, Actionable mode, IActionSource src )
{
ItemStack requestedItemStack = request.getItemStack();
@ -317,7 +317,7 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
}
@Override
public void setActionSource( final BaseActionSource mySource )
public void setActionSource( final IActionSource mySource )
{
this.mySource = mySource;
}

View file

@ -49,8 +49,7 @@ import appeng.api.networking.events.MENetworkCellArrayUpdate;
import appeng.api.networking.events.MENetworkChannelsChanged;
import appeng.api.networking.events.MENetworkEventSubscribe;
import appeng.api.networking.events.MENetworkPowerStatusChange;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.MachineSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.networking.storage.IBaseMonitor;
import appeng.api.networking.ticking.IGridTickable;
import appeng.api.networking.ticking.ITickManager;
@ -81,6 +80,7 @@ import appeng.helpers.IPriorityHost;
import appeng.helpers.Reflected;
import appeng.items.parts.PartModels;
import appeng.me.GridAccessException;
import appeng.me.helpers.MachineSource;
import appeng.me.storage.ITickingMonitor;
import appeng.me.storage.MEInventoryHandler;
import appeng.me.storage.MEMonitorIInventory;
@ -107,7 +107,7 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
@PartModels
public static final IPartModel MODELS_HAS_CHANNEL = new PartModel( MODEL_BASE, new ResourceLocation( AppEng.MOD_ID, "part/storage_bus_has_channel" ) );
private final BaseActionSource mySrc;
private final IActionSource mySrc;
private final AppEngInternalAEInventory Config = new AppEngInternalAEInventory( this, 63 );
private int priority = 0;
private boolean cached = false;
@ -251,7 +251,7 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
}
@Override
public void postChange( final IBaseMonitor<IAEItemStack> monitor, final Iterable<IAEItemStack> change, final BaseActionSource source )
public void postChange( final IBaseMonitor<IAEItemStack> monitor, final Iterable<IAEItemStack> change, final IActionSource source )
{
try
{

View file

@ -36,7 +36,7 @@ import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.api.implementations.parts.IPartStorageMonitor;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.networking.storage.IStackWatcher;
import appeng.api.networking.storage.IStackWatcherHost;
import appeng.api.parts.IPartModel;
@ -287,7 +287,7 @@ public abstract class AbstractPartMonitor extends AbstractPartDisplay implements
}
@Override
public void onStackChange( final IItemList o, final IAEStack fullStack, final IAEStack diffStack, final BaseActionSource src, final StorageChannel chan )
public void onStackChange( final IItemList o, final IAEStack fullStack, final IAEStack diffStack, final IActionSource src, final StorageChannel chan )
{
if( this.configuredItem != null )
{

View file

@ -30,7 +30,6 @@ import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.Vec3d;
import appeng.api.networking.energy.IEnergySource;
import appeng.api.networking.security.PlayerSource;
import appeng.api.parts.IPartModel;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.data.IAEItemStack;
@ -38,6 +37,7 @@ import appeng.core.AppEng;
import appeng.helpers.Reflected;
import appeng.items.parts.PartModels;
import appeng.me.GridAccessException;
import appeng.me.helpers.PlayerSource;
import appeng.parts.PartModel;
import appeng.util.InventoryAdaptor;
import appeng.util.Platform;

View file

@ -21,7 +21,7 @@ package appeng.tile.misc;
import appeng.api.config.AccessRestriction;
import appeng.api.config.Actionable;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.IMEMonitorHandlerReceiver;
import appeng.api.storage.StorageChannel;
@ -41,7 +41,7 @@ class CondenserFluidInventory implements IMEMonitor<IAEFluidStack>
}
@Override
public IAEFluidStack injectItems( final IAEFluidStack input, final Actionable mode, final BaseActionSource src )
public IAEFluidStack injectItems( final IAEFluidStack input, final Actionable mode, final IActionSource src )
{
if( mode == Actionable.SIMULATE )
{
@ -56,7 +56,7 @@ class CondenserFluidInventory implements IMEMonitor<IAEFluidStack>
}
@Override
public IAEFluidStack extractItems( final IAEFluidStack request, final Actionable mode, final BaseActionSource src )
public IAEFluidStack extractItems( final IAEFluidStack request, final Actionable mode, final IActionSource src )
{
return null;
}

View file

@ -21,7 +21,7 @@ package appeng.tile.misc;
import appeng.api.config.AccessRestriction;
import appeng.api.config.Actionable;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.IMEMonitorHandlerReceiver;
import appeng.api.storage.StorageChannel;
@ -41,7 +41,7 @@ class CondenserItemInventory implements IMEMonitor<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( mode == Actionable.MODULATE && input != null )
{
@ -52,7 +52,7 @@ class CondenserItemInventory implements IMEMonitor<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 )
{
return null;
}

View file

@ -38,7 +38,7 @@ import appeng.api.config.CondenserOutput;
import appeng.api.config.Settings;
import appeng.api.definitions.IMaterials;
import appeng.api.implementations.items.IStorageComponent;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.IStorageMonitorable;
import appeng.api.storage.IStorageMonitorableAccessor;
@ -336,7 +336,7 @@ public class TileCondenser extends AEBaseInvTile implements IConfigManagerHost,
@Nullable
@Override
public IStorageMonitorable getInventory( BaseActionSource src )
public IStorageMonitorable getInventory( IActionSource src )
{
return this;
}

View file

@ -64,11 +64,9 @@ import appeng.api.networking.events.MENetworkEventSubscribe;
import appeng.api.networking.events.MENetworkPowerStatusChange;
import appeng.api.networking.events.MENetworkPowerStorage;
import appeng.api.networking.events.MENetworkPowerStorage.PowerEventType;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionHost;
import appeng.api.networking.security.IActionSource;
import appeng.api.networking.security.ISecurityGrid;
import appeng.api.networking.security.MachineSource;
import appeng.api.networking.security.PlayerSource;
import appeng.api.networking.storage.IBaseMonitor;
import appeng.api.networking.storage.IStorageGrid;
import appeng.api.storage.ICellHandler;
@ -89,6 +87,7 @@ import appeng.api.util.IConfigManager;
import appeng.capabilities.Capabilities;
import appeng.helpers.IPriorityHost;
import appeng.me.GridAccessException;
import appeng.me.helpers.MachineSource;
import appeng.me.storage.MEInventoryHandler;
import appeng.tile.grid.AENetworkPowerTile;
import appeng.tile.inventory.AppEngInternalInventory;
@ -111,7 +110,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
private final AppEngInternalInventory cellInventory = new AppEngInternalInventory( this, 1 );
private final IItemHandler internalInventory = new WrapperChainedItemHandler( this.inputInventory, this.cellInventory );
private final BaseActionSource mySrc = new MachineSource( this );
private final IActionSource mySrc = new MachineSource( this );
private final IConfigManager config = new ConfigManager( this );
private ItemStack storageType = ItemStack.EMPTY;
private long lastStateChange = 0;
@ -797,9 +796,9 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
}
@Override
public void postChange( final IBaseMonitor<T> monitor, final Iterable<T> change, final BaseActionSource source )
public void postChange( final IBaseMonitor<T> monitor, final Iterable<T> change, final IActionSource source )
{
if( source == TileChest.this.mySrc || ( source instanceof PlayerSource && ( (PlayerSource) source ).via == TileChest.this ) )
if( source == TileChest.this.mySrc || source.machine().map( machine -> machine == TileChest.this ).orElse( false ) )
{
try
{
@ -843,9 +842,9 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
}
@Override
public T injectItems( final T input, final Actionable mode, final BaseActionSource src )
public T injectItems( final T input, final Actionable mode, final IActionSource src )
{
if( src.isPlayer() && !this.securityCheck( ( (PlayerSource) src ).player, SecurityPermissions.INJECT ) )
if( src.player().map( player -> !this.securityCheck( player, SecurityPermissions.INJECT ) ).orElse( false ) )
{
return input;
}
@ -887,9 +886,9 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
}
@Override
public T extractItems( final T request, final Actionable mode, final BaseActionSource src )
public T extractItems( final T request, final Actionable mode, final IActionSource src )
{
if( src.isPlayer() && !this.securityCheck( ( (PlayerSource) src ).player, SecurityPermissions.EXTRACT ) )
if( src.player().map( player -> !this.securityCheck( player, SecurityPermissions.EXTRACT ) ).orElse( false ) )
{
return null;
}
@ -930,7 +929,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
{
@Nullable
@Override
public IStorageMonitorable getInventory( BaseActionSource src )
public IStorageMonitorable getInventory( IActionSource src )
{
if( Platform.canAccess( TileChest.this.getProxy(), src ) )
{

View file

@ -37,8 +37,7 @@ import appeng.api.networking.events.MENetworkCellArrayUpdate;
import appeng.api.networking.events.MENetworkChannelsChanged;
import appeng.api.networking.events.MENetworkEventSubscribe;
import appeng.api.networking.events.MENetworkPowerStatusChange;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.MachineSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.networking.storage.IStorageGrid;
import appeng.api.storage.ICellHandler;
import appeng.api.storage.IMEInventory;
@ -50,6 +49,7 @@ import appeng.api.util.AEPartLocation;
import appeng.api.util.DimensionalCoord;
import appeng.helpers.IPriorityHost;
import appeng.me.GridAccessException;
import appeng.me.helpers.MachineSource;
import appeng.me.storage.DriveWatcher;
import appeng.me.storage.MEInventoryHandler;
import appeng.tile.grid.AENetworkInvTile;
@ -69,7 +69,7 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior
private final AppEngInternalInventory inv = new AppEngInternalInventory( this, 10, 1 );
private final ICellHandler[] handlersBySlot = new ICellHandler[10];
private final DriveWatcher<IAEItemStack>[] invBySlot = new DriveWatcher[10];
private final BaseActionSource mySrc;
private final IActionSource mySrc;
private boolean isCached = false;
private List<MEInventoryHandler> items = new LinkedList<>();
private List<MEInventoryHandler> fluids = new LinkedList<>();

View file

@ -41,8 +41,7 @@ import appeng.api.implementations.IUpgradeableHost;
import appeng.api.networking.GridFlags;
import appeng.api.networking.IGridNode;
import appeng.api.networking.energy.IEnergySource;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.MachineSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.networking.ticking.IGridTickable;
import appeng.api.networking.ticking.TickRateModulation;
import appeng.api.networking.ticking.TickingRequest;
@ -59,6 +58,7 @@ import appeng.api.util.DimensionalCoord;
import appeng.api.util.IConfigManager;
import appeng.core.settings.TickRates;
import appeng.me.GridAccessException;
import appeng.me.helpers.MachineSource;
import appeng.parts.automation.BlockUpgradeInventory;
import appeng.parts.automation.UpgradeInventory;
import appeng.tile.grid.AENetworkInvTile;
@ -87,7 +87,7 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
private final IItemHandler outputCellsExt = new WrapperFilteredItemHandler( this.outputCells, AEItemFilters.EXTRACT_ONLY );
private final UpgradeInventory upgrades;
private final BaseActionSource mySrc;
private final IActionSource mySrc;
private YesNo lastRedstoneState;
private ItemStack currentCell;
private IMEInventory<IAEFluidStack> cachedFluid;

View file

@ -71,11 +71,9 @@ import net.minecraftforge.common.util.FakePlayerFactory;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.ModContainer;
import net.minecraftforge.fml.common.registry.ForgeRegistries;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.registries.IForgeRegistry;
import appeng.api.AEApi;
import appeng.api.config.AccessRestriction;
@ -94,11 +92,9 @@ import appeng.api.networking.IGrid;
import appeng.api.networking.IGridNode;
import appeng.api.networking.energy.IEnergyGrid;
import appeng.api.networking.energy.IEnergySource;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionHost;
import appeng.api.networking.security.IActionSource;
import appeng.api.networking.security.ISecurityGrid;
import appeng.api.networking.security.MachineSource;
import appeng.api.networking.security.PlayerSource;
import appeng.api.networking.storage.IStorageGrid;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.IMEMonitor;
@ -1162,7 +1158,7 @@ public class Platform
return 0;
}
public static <StackType extends IAEStack> StackType poweredExtraction( final IEnergySource energy, final IMEInventory<StackType> cell, final StackType request, final BaseActionSource src )
public static <StackType extends IAEStack> StackType poweredExtraction( final IEnergySource energy, final IMEInventory<StackType> cell, final StackType request, final IActionSource src )
{
final StackType possible = cell.extractItems( (StackType) request.copy(), Actionable.SIMULATE, src );
@ -1183,9 +1179,9 @@ public class Platform
possible.setStackSize( itemToExtract );
final StackType ret = cell.extractItems( possible, Actionable.MODULATE, src );
if( ret != null && src.isPlayer() )
if( ret != null )
{
Stats.ItemsExtracted.addToPlayer( ( (PlayerSource) src ).player, (int) ret.getStackSize() );
src.player().ifPresent( player -> Stats.ItemsExtracted.addToPlayer( player, (int) ret.getStackSize() ) );
}
return ret;
@ -1194,7 +1190,7 @@ public class Platform
return null;
}
public static <StackType extends IAEStack> StackType poweredInsert( final IEnergySource energy, final IMEInventory<StackType> cell, final StackType input, final BaseActionSource src )
public static <StackType extends IAEStack> StackType poweredInsert( final IEnergySource energy, final IMEInventory<StackType> cell, final StackType input, final IActionSource src )
{
final StackType possible = cell.injectItems( (StackType) input.copy(), Actionable.SIMULATE, src );
@ -1220,22 +1216,22 @@ public class Platform
input.setStackSize( itemToAdd );
split.add( cell.injectItems( input, Actionable.MODULATE, src ) );
if( src.isPlayer() )
src.player().ifPresent( player ->
{
final long diff = original - split.getStackSize();
Stats.ItemsInserted.addToPlayer( ( (PlayerSource) src ).player, (int) diff );
}
Stats.ItemsInserted.addToPlayer( player, (int) diff );
} );
return split;
}
final StackType ret = cell.injectItems( input, Actionable.MODULATE, src );
if( src.isPlayer() )
src.player().ifPresent( player ->
{
final long diff = ret == null ? input.getStackSize() : input.getStackSize() - ret.getStackSize();
Stats.ItemsInserted.addToPlayer( ( (PlayerSource) src ).player, (int) diff );
}
Stats.ItemsInserted.addToPlayer( player, (int) diff );
} );
return ret;
}
@ -1243,7 +1239,7 @@ public class Platform
return input;
}
public static void postChanges( final IStorageGrid gs, final ItemStack removed, final ItemStack added, final BaseActionSource src )
public static void postChanges( final IStorageGrid gs, final ItemStack removed, final ItemStack added, final IActionSource src )
{
final IItemList<IAEItemStack> itemChanges = AEApi.instance().storage().createItemList();
final IItemList<IAEFluidStack> fluidChanges = AEApi.instance().storage().createFluidList();
@ -1291,7 +1287,7 @@ public class Platform
gs.postAlterationOfStoredItems( StorageChannel.ITEMS, itemChanges, src );
}
public static <T extends IAEStack<T>> void postListChanges( final IItemList<T> before, final IItemList<T> after, final IMEMonitorHandlerReceiver<T> meMonitorPassthrough, final BaseActionSource source )
public static <T extends IAEStack<T>> void postListChanges( final IItemList<T> before, final IItemList<T> after, final IMEMonitorHandlerReceiver<T> meMonitorPassthrough, final IActionSource source )
{
final LinkedList<T> changes = new LinkedList<>();
@ -1431,17 +1427,17 @@ public class Platform
player.rotationYaw = player.prevCameraYaw = player.cameraYaw = yaw;
}
public static boolean canAccess( final AENetworkProxy gridProxy, final BaseActionSource src )
public static boolean canAccess( final AENetworkProxy gridProxy, final IActionSource src )
{
try
{
if( src.isPlayer() )
if( src.player().isPresent() )
{
return gridProxy.getSecurity().hasPermission( ( (PlayerSource) src ).player, SecurityPermissions.BUILD );
return gridProxy.getSecurity().hasPermission( src.player().get(), SecurityPermissions.BUILD );
}
else if( src.isMachine() )
else if( src.machine().isPresent() )
{
final IActionHost te = ( (MachineSource) src ).via;
final IActionHost te = src.machine().get();
final IGridNode n = te.getActionableNode();
if( n == null )
{
@ -1462,7 +1458,7 @@ public class Platform
}
}
public static ItemStack extractItemsByRecipe( final IEnergySource energySrc, final BaseActionSource mySrc, final IMEMonitor<IAEItemStack> src, final World w, final IRecipe r, final ItemStack output, final InventoryCrafting ci, final ItemStack providedTemplate, final int slot, final IItemList<IAEItemStack> items, final Actionable realForFake, final IPartitionList<IAEItemStack> filter )
public static ItemStack extractItemsByRecipe( final IEnergySource energySrc, final IActionSource mySrc, final IMEMonitor<IAEItemStack> src, final World w, final IRecipe r, final ItemStack output, final InventoryCrafting ci, final ItemStack providedTemplate, final int slot, final IItemList<IAEItemStack> items, final Actionable realForFake, final IPartitionList<IAEItemStack> filter )
{
if( energySrc.extractAEPower( 1, Actionable.SIMULATE, PowerMultiplier.CONFIG ) > 0.9 )
{

View file

@ -28,7 +28,7 @@ import net.minecraft.item.ItemStack;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.config.FuzzyMode;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
@ -40,10 +40,10 @@ public class IMEAdaptor extends InventoryAdaptor
{
private final IMEInventory<IAEItemStack> target;
private final BaseActionSource src;
private final IActionSource src;
private int maxSlots = 0;
public IMEAdaptor( final IMEInventory<IAEItemStack> input, final BaseActionSource src )
public IMEAdaptor( final IMEInventory<IAEItemStack> input, final IActionSource src )
{
this.target = input;
this.src = src;