diff --git a/core/AppEng.java b/core/AppEng.java index 747998ca0..e4e2dc9dc 100644 --- a/core/AppEng.java +++ b/core/AppEng.java @@ -1,8 +1,15 @@ package appeng.core; import java.io.File; +import java.util.HashMap; import java.util.concurrent.TimeUnit; +import appeng.api.config.TunnelType; +import appeng.core.api.IIMCHandler; +import appeng.core.api.imc.IMCGrinder; +import appeng.core.api.imc.IMCMatterCannon; +import appeng.core.api.imc.IMCP2PAttunement; +import appeng.core.api.imc.IMCSpatial; import appeng.core.crash.CrashEnhancement; import appeng.core.crash.CrashInfo; import appeng.core.features.AEFeature; @@ -21,6 +28,8 @@ import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLInterModComms; +import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.event.FMLServerAboutToStartEvent; @@ -42,6 +51,8 @@ public class AppEng public final static String modid = "appliedenergistics2"; public final static String name = "Applied Energistics 2"; + HashMap IMCHandlers = new HashMap(); + public static AppEng instance; public final static String dependencies = @@ -51,8 +62,7 @@ public class AppEng "after:gregtech_addon;after:Mekanism;after:IC2;after:ThermalExpansion;after:BuildCraft|Core;" + // depend on version of forge used for build. - "required-after:AppliedEnergistics2-Core;" + - "required-after:Forge@[" // require forge. + "required-after:AppliedEnergistics2-Core;" + "required-after:Forge@[" // require forge. + net.minecraftforge.common.ForgeVersion.majorVersion + "." // majorVersion + net.minecraftforge.common.ForgeVersion.minorVersion + "." // minorVersion + net.minecraftforge.common.ForgeVersion.revisionVersion + "." // revisionVersion @@ -61,6 +71,15 @@ public class AppEng public AppEng() { instance = this; + IMCHandlers.put( "whitelist-spatial", new IMCSpatial() ); + IMCHandlers.put( "add-grindable", new IMCGrinder() ); + IMCHandlers.put( "add-mattercannon-ammo", new IMCMatterCannon() ); + + for (TunnelType type : TunnelType.values()) + { + IMCHandlers.put( "add-p2p-attunement-" + type.name().replace( '_', '-' ).toLowerCase(), new IMCP2PAttunement() ); + } + for (CrashInfo ci : CrashInfo.values()) FMLCommonHandler.instance().registerCrashCallable( new CrashEnhancement( ci ) ); } @@ -147,6 +166,27 @@ public class AppEng AELog.info( "PostInit ( end " + star.elapsed( TimeUnit.MILLISECONDS ) + "ms )" ); } + @EventHandler + public void processIMC(FMLInterModComms.IMCEvent event) + { + for (IMCMessage m : event.getMessages()) + { + try + { + IIMCHandler handler = IMCHandlers.get( m.key ); + if ( handler != null ) + handler.post( m ); + else + throw new RuntimeException( "Invalid IMC Called: " + m.key ); + } + catch (Throwable t) + { + AELog.warning( "Problem detected when processing IMC " + m.key + " from " + m.getSender() ); + AELog.error( t ); + } + } + } + @EventHandler public void serverStopping(FMLServerStoppingEvent event) { diff --git a/core/api/IIMCHandler.java b/core/api/IIMCHandler.java new file mode 100644 index 000000000..8925700bf --- /dev/null +++ b/core/api/IIMCHandler.java @@ -0,0 +1,10 @@ +package appeng.core.api; + +import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage; + +public interface IIMCHandler +{ + + void post(IMCMessage m); + +} diff --git a/core/api/imc/IMCGrinder.java b/core/api/imc/IMCGrinder.java new file mode 100644 index 000000000..3d48708e0 --- /dev/null +++ b/core/api/imc/IMCGrinder.java @@ -0,0 +1,79 @@ +/* Example: + +NBTTagCompound msg = new NBTTagCompound(); +NBTTagCompound in = new NBTTagCompound(); +NBTTagCompound out = new NBTTagCompound(); + +new ItemStack( Blocks.iron_ore ).writeToNBT( in ); +new ItemStack( Items.iron_ingot ).writeToNBT( out ); +msg.setTag( "in", in ); +msg.setTag( "out", out ); +msg.setInteger( "turns", 8 ); + +FMLInterModComms.sendMessage( "appliedenergistics2", "add-grindable", msg ); + + -- or -- + +NBTTagCompound msg = new NBTTagCompound(); +NBTTagCompound in = new NBTTagCompound(); +NBTTagCompound out = new NBTTagCompound(); +NBTTagCompound optional = new NBTTagCompound(); + +new ItemStack( Blocks.iron_ore ).writeToNBT( in ); +new ItemStack( Items.iron_ingot ).writeToNBT( out ); +new ItemStack( Blocks.gravel ).writeToNBT( optional ); +msg.setTag( "in", in ); +msg.setTag( "out", out ); +msg.setTag( "optional", optional ); +msg.setFloat( "chance", 0.5 ); +msg.setInteger( "turns", 8 ); + +FMLInterModComms.sendMessage( "appliedenergistics2", "add-grindable", msg ); + + */ +package appeng.core.api.imc; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import appeng.api.AEApi; +import appeng.core.api.IIMCHandler; +import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage; + +public class IMCGrinder implements IIMCHandler +{ + + @Override + public void post(IMCMessage m) + { + NBTTagCompound msg = m.getNBTValue(); + NBTTagCompound inTag = (NBTTagCompound) msg.getTag( "in" ); + NBTTagCompound outTag = (NBTTagCompound) msg.getTag( "out" ); + + ItemStack in = ItemStack.loadItemStackFromNBT( inTag ); + ItemStack out = ItemStack.loadItemStackFromNBT( outTag ); + + int turns = msg.getInteger( "turns" ); + + if ( in == null ) + throw new RuntimeException( "invalid input" ); + + if ( out == null ) + throw new RuntimeException( "invalid output" ); + + if ( msg.hasKey( "optional" ) ) + { + NBTTagCompound optionalTag = (NBTTagCompound) msg.getTag( "optional" ); + ItemStack optional = ItemStack.loadItemStackFromNBT( optionalTag ); + + if ( optional == null ) + throw new RuntimeException( "invalid optional" ); + + float chance = msg.getFloat( "chance" ); + + AEApi.instance().registries().grinder().addRecipe( in, out, optional, chance, turns ); + } + else + AEApi.instance().registries().grinder().addRecipe( in, out, turns ); + } + +} diff --git a/core/api/imc/IMCMatterCannon.java b/core/api/imc/IMCMatterCannon.java new file mode 100644 index 000000000..d50b77003 --- /dev/null +++ b/core/api/imc/IMCMatterCannon.java @@ -0,0 +1,38 @@ +/* Example: + +NBTTagCompound msg = new NBTTagCompound(); +NBTTagCompound item = new NBTTagCompound(); + +new ItemStack( Blocks.anvil ).writeToNBT( item ); +msg.setTag( "item", item ); +msg.setDouble( "weight", 32.0 ); + +FMLInterModComms.sendMessage( "appliedenergistics2", "add-mattercannon-ammo", msg ); + + */ +package appeng.core.api.imc; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import appeng.api.AEApi; +import appeng.core.api.IIMCHandler; +import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage; + +public class IMCMatterCannon implements IIMCHandler +{ + + @Override + public void post(IMCMessage m) + { + NBTTagCompound msg = m.getNBTValue(); + NBTTagCompound item = (NBTTagCompound) msg.getTag( "item" ); + + ItemStack ammo = ItemStack.loadItemStackFromNBT( item ); + double weight = msg.getDouble( "weight" ); + + if ( ammo == null ) + throw new RuntimeException( "invalid item" ); + + AEApi.instance().registries().matterCannon().registerAmmo( ammo, weight ); + } +} diff --git a/core/api/imc/IMCP2PAttunement.java b/core/api/imc/IMCP2PAttunement.java new file mode 100644 index 000000000..d5fea50f7 --- /dev/null +++ b/core/api/imc/IMCP2PAttunement.java @@ -0,0 +1,41 @@ +/* Example: + +FMLInterModComms.sendMessage( "appliedenergistics2", "add-p2p-attunement-me", new ItemStack( myBlockOrItem ) ); +FMLInterModComms.sendMessage( "appliedenergistics2", "add-p2p-attunement-bc-power", new ItemStack( myBlockOrItem ) ); +FMLInterModComms.sendMessage( "appliedenergistics2", "add-p2p-attunement-ic2-power", new ItemStack( myBlockOrItem ) ); +FMLInterModComms.sendMessage( "appliedenergistics2", "add-p2p-attunement-redstone", new ItemStack( myBlockOrItem ) ); +FMLInterModComms.sendMessage( "appliedenergistics2", "add-p2p-attunement-fluid", new ItemStack( myBlockOrItem ) ); +FMLInterModComms.sendMessage( "appliedenergistics2", "add-p2p-attunement-item", new ItemStack( myBlockOrItem ) ); + + */ +package appeng.core.api.imc; + +import net.minecraft.item.ItemStack; +import appeng.api.AEApi; +import appeng.api.config.TunnelType; +import appeng.core.api.IIMCHandler; +import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage; + +public class IMCP2PAttunement implements IIMCHandler +{ + + @Override + public void post(IMCMessage m) + { + String key = m.key.substring( "add-p2p-attunement-".length() ).replace( '-', '_' ).toUpperCase(); + + TunnelType type = TunnelType.valueOf( key ); + + if ( type != null ) + { + ItemStack is = m.getItemStackValue(); + if ( is != null ) + AEApi.instance().registries().p2pTunnel().addNewAttunement( is, type ); + else + throw new RuntimeException( "invalid item" ); + } + else + throw new RuntimeException( "invalid type" ); + } + +} diff --git a/core/api/imc/IMCSpatial.java b/core/api/imc/IMCSpatial.java new file mode 100644 index 000000000..bc6eb6995 --- /dev/null +++ b/core/api/imc/IMCSpatial.java @@ -0,0 +1,32 @@ +/* Example: + +FMLInterModComms.sendMessage( "appliedenergistics2", "whitelist-spatial", "mymod.tileentities.MyTileEntity" ); + + */ +package appeng.core.api.imc; + +import appeng.api.AEApi; +import appeng.core.AELog; +import appeng.core.api.IIMCHandler; +import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage; + +public class IMCSpatial implements IIMCHandler +{ + + @Override + public void post(IMCMessage m) + { + + try + { + Class classInstance = Class.forName( m.getStringValue() ); + AEApi.instance().registries().moveable().whiteListTileEntity( classInstance ); + } + catch (ClassNotFoundException e) + { + AELog.info( "Bad Class Registered: " + m.getStringValue() + " by " + m.getSender() ); + } + + } + +} diff --git a/core/features/registries/entries/ExternalIInv.java b/core/features/registries/entries/ExternalIInv.java index 2ccd25af5..9d971cc3f 100644 --- a/core/features/registries/entries/ExternalIInv.java +++ b/core/features/registries/entries/ExternalIInv.java @@ -3,6 +3,7 @@ package appeng.core.features.registries.entries; import net.minecraft.inventory.IInventory; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; +import appeng.api.networking.security.BaseActionSource; import appeng.api.storage.IExternalStorageHandler; import appeng.api.storage.IMEInventory; import appeng.api.storage.StorageChannel; @@ -18,7 +19,7 @@ public class ExternalIInv implements IExternalStorageHandler } @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 ) return new MEMonitorIInventory( (IInventory) te, d ); diff --git a/helpers/DualityInterface.java b/helpers/DualityInterface.java index 45985e3e4..6c0cec917 100644 --- a/helpers/DualityInterface.java +++ b/helpers/DualityInterface.java @@ -158,10 +158,10 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt IAEItemStack req = config.getAEStackInSlot( slot ); if ( req != null && req.getStackSize() <= 0 ) { - config.setInventorySlotContents(slot, null); + config.setInventorySlotContents( slot, null ); req = null; } - + ItemStack Stored = storage.getStackInSlot( slot ); if ( req == null && Stored != null ) @@ -478,6 +478,29 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt { // 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 getItemInventory() + { + return new InterfaceInventory( di ); + } + + @Override + public IMEMonitor getFluidInventory() + { + return null; + } + }; }; } diff --git a/hooks/TickHandler.java b/hooks/TickHandler.java index 47f997746..c59c89701 100644 --- a/hooks/TickHandler.java +++ b/hooks/TickHandler.java @@ -14,6 +14,7 @@ import appeng.tile.AEBaseTile; import appeng.util.Platform; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.TickEvent; +import cpw.mods.fml.common.gameevent.TickEvent.Phase; import cpw.mods.fml.common.gameevent.TickEvent.Type; public class TickHandler @@ -104,7 +105,7 @@ public class TickHandler @SubscribeEvent public void onTick(TickEvent ev) { - if ( ev.type == Type.SERVER ) + if ( ev.type == Type.SERVER && ev.phase == Phase.END ) { HandlerRep repo = getRepo(); while (!repo.tiles.isEmpty()) diff --git a/integration/modules/helpers/BCPipeHandler.java b/integration/modules/helpers/BCPipeHandler.java index da361ddfe..07296841a 100644 --- a/integration/modules/helpers/BCPipeHandler.java +++ b/integration/modules/helpers/BCPipeHandler.java @@ -2,6 +2,7 @@ package appeng.integration.modules.helpers; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; +import appeng.api.networking.security.BaseActionSource; import appeng.api.storage.IExternalStorageHandler; import appeng.api.storage.IMEInventory; import appeng.api.storage.StorageChannel; @@ -17,7 +18,7 @@ public class BCPipeHandler implements IExternalStorageHandler } @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 ) return new BCPipeInventory( te, d ); diff --git a/integration/modules/helpers/FactorizationHandler.java b/integration/modules/helpers/FactorizationHandler.java index 5810cba64..de40fc4bf 100644 --- a/integration/modules/helpers/FactorizationHandler.java +++ b/integration/modules/helpers/FactorizationHandler.java @@ -2,6 +2,7 @@ package appeng.integration.modules.helpers; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; +import appeng.api.networking.security.BaseActionSource; import appeng.api.storage.IExternalStorageHandler; import appeng.api.storage.IMEInventory; import appeng.api.storage.StorageChannel; @@ -17,7 +18,7 @@ public class FactorizationHandler implements IExternalStorageHandler } @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 ) return FZ.instance.getFactorizationBarrel( te ); diff --git a/integration/modules/helpers/MFRDSUHandler.java b/integration/modules/helpers/MFRDSUHandler.java index 6dcc77351..3c7a3141a 100644 --- a/integration/modules/helpers/MFRDSUHandler.java +++ b/integration/modules/helpers/MFRDSUHandler.java @@ -2,6 +2,7 @@ package appeng.integration.modules.helpers; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; +import appeng.api.networking.security.BaseActionSource; import appeng.api.storage.IExternalStorageHandler; import appeng.api.storage.IMEInventory; import appeng.api.storage.StorageChannel; @@ -17,7 +18,7 @@ public class MFRDSUHandler implements IExternalStorageHandler } @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 ) return DSU.instance.getDSU( te ); diff --git a/me/storage/AEExternalHandler.java b/me/storage/AEExternalHandler.java index c64048b8a..de03ba4f6 100644 --- a/me/storage/AEExternalHandler.java +++ b/me/storage/AEExternalHandler.java @@ -3,6 +3,7 @@ package appeng.me.storage; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; import appeng.api.implementations.tiles.ITileStorageMonitorable; +import appeng.api.networking.security.BaseActionSource; import appeng.api.storage.IExternalStorageHandler; import appeng.api.storage.IMEInventory; import appeng.api.storage.IStorageMonitorable; @@ -24,7 +25,7 @@ public class AEExternalHandler implements IExternalStorageHandler } @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 ) { @@ -37,7 +38,7 @@ public class AEExternalHandler implements IExternalStorageHandler if ( te instanceof ITileStorageMonitorable ) { ITileStorageMonitorable iface = (ITileStorageMonitorable) te; - IStorageMonitorable sm = iface.getMonitorable( d ); + IStorageMonitorable sm = iface.getMonitorable( d, src ); if ( channel == StorageChannel.ITEMS && sm != null ) { diff --git a/parts/misc/PartInterface.java b/parts/misc/PartInterface.java index 178a5c7fa..5f8d4fd55 100644 --- a/parts/misc/PartInterface.java +++ b/parts/misc/PartInterface.java @@ -12,6 +12,7 @@ import net.minecraftforge.common.util.ForgeDirection; import appeng.api.implementations.tiles.ISegmentedInventory; import appeng.api.implementations.tiles.ITileStorageMonitorable; import appeng.api.networking.IGridNode; +import appeng.api.networking.security.BaseActionSource; import appeng.api.networking.ticking.IGridTickable; import appeng.api.networking.ticking.TickRateModulation; import appeng.api.networking.ticking.TickingRequest; @@ -277,8 +278,8 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISeg } @Override - public IStorageMonitorable getMonitorable(ForgeDirection side) + public IStorageMonitorable getMonitorable(ForgeDirection side, BaseActionSource src) { - return this; + return duality.getMonitorable( side, src, this ); } } diff --git a/parts/misc/PartStorageBus.java b/parts/misc/PartStorageBus.java index 93a4abb14..fe3ad25bb 100644 --- a/parts/misc/PartStorageBus.java +++ b/parts/misc/PartStorageBus.java @@ -219,7 +219,7 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC IExternalStorageHandler esh = AEApi.instance().registries().externalStorage().getHandler( target, side.getOpposite(), StorageChannel.ITEMS ); 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 ) ((MEMonitorIInventory) inv).mySource = new MachineSource( this ); diff --git a/parts/reporting/PartDarkMonitor.java b/parts/reporting/PartDarkMonitor.java index dfbb7b30c..2b1963f83 100644 --- a/parts/reporting/PartDarkMonitor.java +++ b/parts/reporting/PartDarkMonitor.java @@ -13,8 +13,7 @@ public class PartDarkMonitor extends PartMonitor { public PartDarkMonitor(ItemStack is) { - super( PartDarkMonitor.class, is,false ); - + super( PartDarkMonitor.class, is, false ); notLightSource = false; } diff --git a/parts/reporting/PartMonitor.java b/parts/reporting/PartMonitor.java index abbeff5e3..be6b850d3 100644 --- a/parts/reporting/PartMonitor.java +++ b/parts/reporting/PartMonitor.java @@ -111,12 +111,12 @@ public class PartMonitor extends AEBasePart implements IPartMonitor, IPowerChann } public PartMonitor(ItemStack is) { - super( PartMonitor.class, is ); + this( PartMonitor.class, is, false ); } - protected PartMonitor(Class c, ItemStack is, boolean requireChannel ) { + protected PartMonitor(Class c, ItemStack is, boolean requireChannel) { super( c, is ); - + if ( requireChannel ) proxy.setFlags( GridFlags.REQUIRE_CHANNEL ); else diff --git a/tile/misc/TileInterface.java b/tile/misc/TileInterface.java index e466ccabc..a54c2f636 100644 --- a/tile/misc/TileInterface.java +++ b/tile/misc/TileInterface.java @@ -10,6 +10,7 @@ import net.minecraftforge.common.util.ForgeDirection; import appeng.api.implementations.tiles.ISegmentedInventory; import appeng.api.implementations.tiles.ITileStorageMonitorable; import appeng.api.networking.IGridNode; +import appeng.api.networking.security.BaseActionSource; import appeng.api.networking.ticking.IGridTickable; import appeng.api.networking.ticking.TickRateModulation; import appeng.api.networking.ticking.TickingRequest; @@ -191,9 +192,9 @@ public class TileInterface extends AENetworkInvTile implements IGridTickable, IS } @Override - public IStorageMonitorable getMonitorable(ForgeDirection side) + public IStorageMonitorable getMonitorable(ForgeDirection side, BaseActionSource src) { - return this; + return duality.getMonitorable( side, src, this ); } @Override diff --git a/tile/storage/TileChest.java b/tile/storage/TileChest.java index 8fc320066..bc22dc251 100644 --- a/tile/storage/TileChest.java +++ b/tile/storage/TileChest.java @@ -706,9 +706,11 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan } @Override - public IStorageMonitorable getMonitorable(ForgeDirection side) + public IStorageMonitorable getMonitorable(ForgeDirection side, BaseActionSource src) { - return this; + if ( Platform.canAccess( gridProxy, src ) ) + return this; + return null; } public ItemStack getStorageType() diff --git a/util/Platform.java b/util/Platform.java index e16d811ea..7caf2f3a2 100644 --- a/util/Platform.java +++ b/util/Platform.java @@ -62,7 +62,10 @@ import appeng.api.networking.IGrid; 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.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; @@ -77,7 +80,9 @@ import appeng.api.util.AEItemDefinition; import appeng.core.AELog; import appeng.core.AppEng; import appeng.core.sync.GuiBridge; +import appeng.me.GridAccessException; import appeng.me.GridNode; +import appeng.me.helpers.AENetworkProxy; import appeng.server.AccessType; import appeng.util.item.AEItemStack; import appeng.util.item.AESharedNBT; @@ -1567,4 +1572,27 @@ public class Platform return null; } + 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; + } + } + }