Allow security hand shakes for monitorables.
This commit is contained in:
@@ -3,6 +3,7 @@ package appeng.core.features.registries.entries;
|
|||||||
import net.minecraft.inventory.IInventory;
|
import net.minecraft.inventory.IInventory;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
import appeng.api.networking.security.BaseActionSource;
|
||||||
import appeng.api.storage.IExternalStorageHandler;
|
import appeng.api.storage.IExternalStorageHandler;
|
||||||
import appeng.api.storage.IMEInventory;
|
import appeng.api.storage.IMEInventory;
|
||||||
import appeng.api.storage.StorageChannel;
|
import appeng.api.storage.StorageChannel;
|
||||||
@@ -18,7 +19,7 @@ public class ExternalIInv implements IExternalStorageHandler
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IMEInventory getInventory(TileEntity te, ForgeDirection d, StorageChannel channel)
|
public IMEInventory getInventory(TileEntity te, ForgeDirection d, StorageChannel channel, BaseActionSource src)
|
||||||
{
|
{
|
||||||
if ( channel == StorageChannel.ITEMS && te instanceof IInventory )
|
if ( channel == StorageChannel.ITEMS && te instanceof IInventory )
|
||||||
return new MEMonitorIInventory( (IInventory) te, d );
|
return new MEMonitorIInventory( (IInventory) te, d );
|
||||||
|
|||||||
@@ -478,6 +478,29 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt
|
|||||||
{
|
{
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public IStorageMonitorable getMonitorable(ForgeDirection side, BaseActionSource src, IStorageMonitorable myInterface)
|
||||||
|
{
|
||||||
|
if ( Platform.canAccess( gridProxy, src ) )
|
||||||
|
return myInterface;
|
||||||
|
|
||||||
|
final DualityInterface di = this;
|
||||||
|
|
||||||
|
return new IStorageMonitorable() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IMEMonitor<IAEItemStack> getItemInventory()
|
||||||
|
{
|
||||||
|
return new InterfaceInventory( di );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IMEMonitor<IAEFluidStack> getFluidInventory()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package appeng.integration.modules.helpers;
|
|||||||
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
import appeng.api.networking.security.BaseActionSource;
|
||||||
import appeng.api.storage.IExternalStorageHandler;
|
import appeng.api.storage.IExternalStorageHandler;
|
||||||
import appeng.api.storage.IMEInventory;
|
import appeng.api.storage.IMEInventory;
|
||||||
import appeng.api.storage.StorageChannel;
|
import appeng.api.storage.StorageChannel;
|
||||||
@@ -17,7 +18,7 @@ public class BCPipeHandler implements IExternalStorageHandler
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IMEInventory getInventory(TileEntity te, ForgeDirection d, StorageChannel chan)
|
public IMEInventory getInventory(TileEntity te, ForgeDirection d, StorageChannel chan, BaseActionSource src)
|
||||||
{
|
{
|
||||||
if ( chan == StorageChannel.ITEMS )
|
if ( chan == StorageChannel.ITEMS )
|
||||||
return new BCPipeInventory( te, d );
|
return new BCPipeInventory( te, d );
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package appeng.integration.modules.helpers;
|
|||||||
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
import appeng.api.networking.security.BaseActionSource;
|
||||||
import appeng.api.storage.IExternalStorageHandler;
|
import appeng.api.storage.IExternalStorageHandler;
|
||||||
import appeng.api.storage.IMEInventory;
|
import appeng.api.storage.IMEInventory;
|
||||||
import appeng.api.storage.StorageChannel;
|
import appeng.api.storage.StorageChannel;
|
||||||
@@ -17,7 +18,7 @@ public class FactorizationHandler implements IExternalStorageHandler
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IMEInventory getInventory(TileEntity te, ForgeDirection d, StorageChannel chan)
|
public IMEInventory getInventory(TileEntity te, ForgeDirection d, StorageChannel chan, BaseActionSource src)
|
||||||
{
|
{
|
||||||
if ( chan == StorageChannel.ITEMS )
|
if ( chan == StorageChannel.ITEMS )
|
||||||
return FZ.instance.getFactorizationBarrel( te );
|
return FZ.instance.getFactorizationBarrel( te );
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package appeng.integration.modules.helpers;
|
|||||||
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
import appeng.api.networking.security.BaseActionSource;
|
||||||
import appeng.api.storage.IExternalStorageHandler;
|
import appeng.api.storage.IExternalStorageHandler;
|
||||||
import appeng.api.storage.IMEInventory;
|
import appeng.api.storage.IMEInventory;
|
||||||
import appeng.api.storage.StorageChannel;
|
import appeng.api.storage.StorageChannel;
|
||||||
@@ -17,7 +18,7 @@ public class MFRDSUHandler implements IExternalStorageHandler
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IMEInventory getInventory(TileEntity te, ForgeDirection d, StorageChannel chan)
|
public IMEInventory getInventory(TileEntity te, ForgeDirection d, StorageChannel chan, BaseActionSource src)
|
||||||
{
|
{
|
||||||
if ( chan == StorageChannel.ITEMS )
|
if ( chan == StorageChannel.ITEMS )
|
||||||
return DSU.instance.getDSU( te );
|
return DSU.instance.getDSU( te );
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package appeng.me.storage;
|
|||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
import appeng.api.implementations.tiles.ITileStorageMonitorable;
|
import appeng.api.implementations.tiles.ITileStorageMonitorable;
|
||||||
|
import appeng.api.networking.security.BaseActionSource;
|
||||||
import appeng.api.storage.IExternalStorageHandler;
|
import appeng.api.storage.IExternalStorageHandler;
|
||||||
import appeng.api.storage.IMEInventory;
|
import appeng.api.storage.IMEInventory;
|
||||||
import appeng.api.storage.IStorageMonitorable;
|
import appeng.api.storage.IStorageMonitorable;
|
||||||
@@ -24,7 +25,7 @@ public class AEExternalHandler implements IExternalStorageHandler
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IMEInventory getInventory(TileEntity te, ForgeDirection d, StorageChannel channel)
|
public IMEInventory getInventory(TileEntity te, ForgeDirection d, StorageChannel channel, BaseActionSource src)
|
||||||
{
|
{
|
||||||
if ( te instanceof TileCondenser )
|
if ( te instanceof TileCondenser )
|
||||||
{
|
{
|
||||||
@@ -37,7 +38,7 @@ public class AEExternalHandler implements IExternalStorageHandler
|
|||||||
if ( te instanceof ITileStorageMonitorable )
|
if ( te instanceof ITileStorageMonitorable )
|
||||||
{
|
{
|
||||||
ITileStorageMonitorable iface = (ITileStorageMonitorable) te;
|
ITileStorageMonitorable iface = (ITileStorageMonitorable) te;
|
||||||
IStorageMonitorable sm = iface.getMonitorable( d );
|
IStorageMonitorable sm = iface.getMonitorable( d, src );
|
||||||
|
|
||||||
if ( channel == StorageChannel.ITEMS && sm != null )
|
if ( channel == StorageChannel.ITEMS && sm != null )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import net.minecraftforge.common.util.ForgeDirection;
|
|||||||
import appeng.api.implementations.tiles.ISegmentedInventory;
|
import appeng.api.implementations.tiles.ISegmentedInventory;
|
||||||
import appeng.api.implementations.tiles.ITileStorageMonitorable;
|
import appeng.api.implementations.tiles.ITileStorageMonitorable;
|
||||||
import appeng.api.networking.IGridNode;
|
import appeng.api.networking.IGridNode;
|
||||||
|
import appeng.api.networking.security.BaseActionSource;
|
||||||
import appeng.api.networking.ticking.IGridTickable;
|
import appeng.api.networking.ticking.IGridTickable;
|
||||||
import appeng.api.networking.ticking.TickRateModulation;
|
import appeng.api.networking.ticking.TickRateModulation;
|
||||||
import appeng.api.networking.ticking.TickingRequest;
|
import appeng.api.networking.ticking.TickingRequest;
|
||||||
@@ -277,8 +278,8 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISeg
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IStorageMonitorable getMonitorable(ForgeDirection side)
|
public IStorageMonitorable getMonitorable(ForgeDirection side, BaseActionSource src)
|
||||||
{
|
{
|
||||||
return this;
|
return duality.getMonitorable( side, src, this );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -219,7 +219,7 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
|
|||||||
IExternalStorageHandler esh = AEApi.instance().registries().externalStorage().getHandler( target, side.getOpposite(), StorageChannel.ITEMS );
|
IExternalStorageHandler esh = AEApi.instance().registries().externalStorage().getHandler( target, side.getOpposite(), StorageChannel.ITEMS );
|
||||||
if ( esh != null )
|
if ( esh != null )
|
||||||
{
|
{
|
||||||
IMEInventory inv = esh.getInventory( target, side.getOpposite(), StorageChannel.ITEMS );
|
IMEInventory inv = esh.getInventory( target, side.getOpposite(), StorageChannel.ITEMS, mySrc );
|
||||||
|
|
||||||
if ( inv instanceof MEMonitorIInventory )
|
if ( inv instanceof MEMonitorIInventory )
|
||||||
((MEMonitorIInventory) inv).mySource = new MachineSource( this );
|
((MEMonitorIInventory) inv).mySource = new MachineSource( this );
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import net.minecraftforge.common.util.ForgeDirection;
|
|||||||
import appeng.api.implementations.tiles.ISegmentedInventory;
|
import appeng.api.implementations.tiles.ISegmentedInventory;
|
||||||
import appeng.api.implementations.tiles.ITileStorageMonitorable;
|
import appeng.api.implementations.tiles.ITileStorageMonitorable;
|
||||||
import appeng.api.networking.IGridNode;
|
import appeng.api.networking.IGridNode;
|
||||||
|
import appeng.api.networking.security.BaseActionSource;
|
||||||
import appeng.api.networking.ticking.IGridTickable;
|
import appeng.api.networking.ticking.IGridTickable;
|
||||||
import appeng.api.networking.ticking.TickRateModulation;
|
import appeng.api.networking.ticking.TickRateModulation;
|
||||||
import appeng.api.networking.ticking.TickingRequest;
|
import appeng.api.networking.ticking.TickingRequest;
|
||||||
@@ -191,9 +192,9 @@ public class TileInterface extends AENetworkInvTile implements IGridTickable, IS
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IStorageMonitorable getMonitorable(ForgeDirection side)
|
public IStorageMonitorable getMonitorable(ForgeDirection side, BaseActionSource src)
|
||||||
{
|
{
|
||||||
return this;
|
return duality.getMonitorable( side, src, this );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -706,9 +706,11 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IStorageMonitorable getMonitorable(ForgeDirection side)
|
public IStorageMonitorable getMonitorable(ForgeDirection side, BaseActionSource src)
|
||||||
{
|
{
|
||||||
|
if ( Platform.canAccess( gridProxy, src ) )
|
||||||
return this;
|
return this;
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getStorageType()
|
public ItemStack getStorageType()
|
||||||
|
|||||||
@@ -62,7 +62,10 @@ import appeng.api.networking.IGrid;
|
|||||||
import appeng.api.networking.energy.IEnergyGrid;
|
import appeng.api.networking.energy.IEnergyGrid;
|
||||||
import appeng.api.networking.energy.IEnergySource;
|
import appeng.api.networking.energy.IEnergySource;
|
||||||
import appeng.api.networking.security.BaseActionSource;
|
import appeng.api.networking.security.BaseActionSource;
|
||||||
|
import appeng.api.networking.security.IActionHost;
|
||||||
import appeng.api.networking.security.ISecurityGrid;
|
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.networking.storage.IStorageGrid;
|
||||||
import appeng.api.storage.IMEInventory;
|
import appeng.api.storage.IMEInventory;
|
||||||
import appeng.api.storage.IMEMonitorHandlerReceiver;
|
import appeng.api.storage.IMEMonitorHandlerReceiver;
|
||||||
@@ -76,7 +79,9 @@ import appeng.api.util.AEItemDefinition;
|
|||||||
import appeng.core.AELog;
|
import appeng.core.AELog;
|
||||||
import appeng.core.AppEng;
|
import appeng.core.AppEng;
|
||||||
import appeng.core.sync.GuiBridge;
|
import appeng.core.sync.GuiBridge;
|
||||||
|
import appeng.me.GridAccessException;
|
||||||
import appeng.me.GridNode;
|
import appeng.me.GridNode;
|
||||||
|
import appeng.me.helpers.AENetworkProxy;
|
||||||
import appeng.server.AccessType;
|
import appeng.server.AccessType;
|
||||||
import appeng.util.item.AEItemStack;
|
import appeng.util.item.AEItemStack;
|
||||||
import appeng.util.item.AESharedNBT;
|
import appeng.util.item.AESharedNBT;
|
||||||
@@ -1516,4 +1521,27 @@ public class Platform
|
|||||||
player.rotationYaw = player.prevCameraYaw = player.cameraYaw = yaw;
|
player.rotationYaw = player.prevCameraYaw = player.cameraYaw = yaw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean canAccess(AENetworkProxy gridProxy, BaseActionSource src)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if ( src.isPlayer() )
|
||||||
|
{
|
||||||
|
return gridProxy.getSecurity().hasPermission( ((PlayerSource) src).player, SecurityPermissions.BUILD );
|
||||||
|
}
|
||||||
|
else if ( src.isMachine() )
|
||||||
|
{
|
||||||
|
IActionHost te = ((MachineSource) src).via;
|
||||||
|
int playerID = te.getActionableNode().getPlayerID();
|
||||||
|
return gridProxy.getSecurity().hasPermission( playerID, SecurityPermissions.BUILD );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
catch (GridAccessException gae)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user