Security Update.
This commit is contained in:
parent
803e62fcc7
commit
851d3cca7c
|
@ -13,7 +13,10 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.networking.IGridHost;
|
||||
import appeng.api.networking.energy.IEnergySource;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.networking.security.PlayerSource;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
|
@ -37,6 +40,8 @@ public abstract class AEBaseContainer extends Container
|
|||
final TileEntity tileEntity;
|
||||
final IPart part;
|
||||
|
||||
BaseActionSource mySrc;
|
||||
|
||||
protected IMEInventoryHandler<IAEItemStack> cellInv;
|
||||
protected IEnergySource powerSrc;
|
||||
|
||||
|
@ -53,6 +58,7 @@ public abstract class AEBaseContainer extends Container
|
|||
invPlayer = ip;
|
||||
tileEntity = myTile;
|
||||
part = myPart;
|
||||
mySrc = new PlayerSource( ip.player, (IGridHost) (myTile instanceof IGridHost ? myTile : (myPart instanceof IGridHost ? myPart : null)) );
|
||||
}
|
||||
|
||||
public boolean canDragIntoSlot(Slot s)
|
||||
|
@ -339,7 +345,7 @@ public abstract class AEBaseContainer extends Container
|
|||
{
|
||||
if ( powerSrc == null || cellInv == null )
|
||||
return input;
|
||||
IAEItemStack ais = Platform.poweredInsert( powerSrc, cellInv, AEApi.instance().storage().createItemStack( input ) );
|
||||
IAEItemStack ais = Platform.poweredInsert( powerSrc, cellInv, AEApi.instance().storage().createItemStack( input ), mySrc );
|
||||
if ( ais == null )
|
||||
return null;
|
||||
return ais.getItemStack();
|
||||
|
@ -422,7 +428,7 @@ public abstract class AEBaseContainer extends Container
|
|||
if ( myItem != null )
|
||||
ais.setStackSize( ais.getStackSize() - myItem.stackSize );
|
||||
|
||||
ais = Platform.poweredExtraction( powerSrc, cellInv, ais );
|
||||
ais = Platform.poweredExtraction( powerSrc, cellInv, ais, mySrc );
|
||||
if ( ais != null )
|
||||
adp.addItems( ais.getItemStack() );
|
||||
}
|
||||
|
@ -437,7 +443,7 @@ public abstract class AEBaseContainer extends Container
|
|||
{
|
||||
IAEItemStack ais = slotItem.copy();
|
||||
ais.setStackSize( ais.getItemStack().getMaxStackSize() );
|
||||
ais = Platform.poweredExtraction( powerSrc, cellInv, ais );
|
||||
ais = Platform.poweredExtraction( powerSrc, cellInv, ais, mySrc );
|
||||
if ( ais != null )
|
||||
player.inventory.setItemStack( ais.getItemStack() );
|
||||
else
|
||||
|
@ -448,7 +454,7 @@ public abstract class AEBaseContainer extends Container
|
|||
else
|
||||
{
|
||||
IAEItemStack ais = AEApi.instance().storage().createItemStack( player.inventory.getItemStack() );
|
||||
ais = Platform.poweredInsert( powerSrc, cellInv, ais );
|
||||
ais = Platform.poweredInsert( powerSrc, cellInv, ais, mySrc );
|
||||
if ( ais != null )
|
||||
player.inventory.setItemStack( ais.getItemStack() );
|
||||
else
|
||||
|
@ -468,7 +474,7 @@ public abstract class AEBaseContainer extends Container
|
|||
IAEItemStack ais = slotItem.copy();
|
||||
long stackSize = Math.min( ais.getItemStack().getMaxStackSize(), ais.getStackSize() );
|
||||
ais.setStackSize( (stackSize + 1) >> 1 );
|
||||
ais = Platform.poweredExtraction( powerSrc, cellInv, ais );
|
||||
ais = Platform.poweredExtraction( powerSrc, cellInv, ais, mySrc );
|
||||
if ( ais != null )
|
||||
player.inventory.setItemStack( ais.getItemStack() );
|
||||
else
|
||||
|
@ -480,7 +486,7 @@ public abstract class AEBaseContainer extends Container
|
|||
{
|
||||
IAEItemStack ais = AEApi.instance().storage().createItemStack( player.inventory.getItemStack() );
|
||||
ais.setStackSize( 1 );
|
||||
ais = Platform.poweredInsert( powerSrc, cellInv, ais );
|
||||
ais = Platform.poweredInsert( powerSrc, cellInv, ais, mySrc );
|
||||
if ( ais == null )
|
||||
{
|
||||
ItemStack is = player.inventory.getItemStack();
|
||||
|
|
|
@ -9,14 +9,15 @@ import net.minecraft.network.packet.Packet;
|
|||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import appeng.api.implementations.IMEChest;
|
||||
import appeng.api.implementations.IStorageMonitorable;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.IGridHost;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.energy.IEnergyGrid;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.IMEMonitorHandlerReciever;
|
||||
import appeng.api.storage.IStorageMonitorable;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.container.AEBaseContainer;
|
||||
|
@ -153,7 +154,7 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IMEMonito
|
|||
}
|
||||
|
||||
@Override
|
||||
public void postChange(IAEItemStack change)
|
||||
public void postChange(IMEMonitor<IAEItemStack> monitor, IAEItemStack change, BaseActionSource source)
|
||||
{
|
||||
items.add( change );
|
||||
}
|
||||
|
|
|
@ -2,10 +2,14 @@ package appeng.core.api;
|
|||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import appeng.api.networking.energy.IEnergySource;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.IStorageHelper;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEFluidStack;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import appeng.util.item.ItemList;
|
||||
|
@ -31,4 +35,16 @@ public class ApiStorage implements IStorageHelper
|
|||
return new ItemList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack poweredExtraction(IEnergySource energy, IMEInventory<IAEItemStack> cell, IAEItemStack request, BaseActionSource src)
|
||||
{
|
||||
return Platform.poweredExtraction( energy, cell, request, src );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack poweredInsert(IEnergySource energy, IMEInventory<IAEItemStack> cell, IAEItemStack input, BaseActionSource src)
|
||||
{
|
||||
return Platform.poweredInsert( energy, cell, input, src );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
45
me/cache/NetworkMonitor.java
vendored
45
me/cache/NetworkMonitor.java
vendored
|
@ -1,12 +1,16 @@
|
|||
package appeng.me.cache;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.Set;
|
||||
|
||||
import appeng.api.networking.events.MENetworkStorageEvent;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
import appeng.api.storage.MEMonitorHandler;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.me.storage.ItemWatcher;
|
||||
|
||||
public class NetworkMonitor<T extends IAEStack<T>> extends MEMonitorHandler<T>
|
||||
{
|
||||
|
@ -16,6 +20,11 @@ public class NetworkMonitor<T extends IAEStack<T>> extends MEMonitorHandler<T>
|
|||
|
||||
boolean sendEvent = false;
|
||||
|
||||
public void forceUpdate()
|
||||
{
|
||||
hasChanged = true;
|
||||
}
|
||||
|
||||
public NetworkMonitor(GridStorageCache cache, StorageChannel chan) {
|
||||
super( null );
|
||||
myGridCache = cache;
|
||||
|
@ -24,8 +33,21 @@ public class NetworkMonitor<T extends IAEStack<T>> extends MEMonitorHandler<T>
|
|||
|
||||
final static public LinkedList depth = new LinkedList();
|
||||
|
||||
private BaseActionSource src;
|
||||
|
||||
public void setSource(BaseActionSource src)
|
||||
{
|
||||
this.src = src;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void postChange(T diff)
|
||||
protected BaseActionSource getSource()
|
||||
{
|
||||
return src;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void postChange(T diff, BaseActionSource src)
|
||||
{
|
||||
if ( depth.contains( this ) )
|
||||
return;
|
||||
|
@ -33,7 +55,26 @@ public class NetworkMonitor<T extends IAEStack<T>> extends MEMonitorHandler<T>
|
|||
depth.push( this );
|
||||
|
||||
sendEvent = true;
|
||||
super.postChange( diff );
|
||||
super.postChange( diff, src );
|
||||
|
||||
if ( myGridCache.interests.containsKey( diff ) )
|
||||
{
|
||||
Set<ItemWatcher> list = myGridCache.interests.get( diff );
|
||||
if ( !list.isEmpty() )
|
||||
{
|
||||
IItemList<T> myStorageList = getStorageList();
|
||||
|
||||
IAEStack fullStack = myStorageList.findPrecise( diff );
|
||||
if ( fullStack == null )
|
||||
{
|
||||
fullStack = diff.copy();
|
||||
fullStack.setStackSize( 0 );
|
||||
}
|
||||
|
||||
for (ItemWatcher iw : list)
|
||||
iw.getHost().onStackChange( myStorageList, fullStack, diff, src, getChannel() );
|
||||
}
|
||||
}
|
||||
|
||||
Object last = depth.pop();
|
||||
if ( last != this )
|
||||
|
|
|
@ -11,6 +11,7 @@ import net.minecraftforge.common.ForgeDirection;
|
|||
import appeng.api.AEApi;
|
||||
import appeng.api.config.AccessRestriction;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.networking.ticking.TickRateModulation;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
|
@ -56,6 +57,8 @@ public class MEMonitorIInventory implements IMEInventory<IAEItemStack>, IMEMonit
|
|||
final IItemList<IAEItemStack> list = new ItemList();
|
||||
final HashMap<IMEMonitorHandlerReciever<IAEItemStack>, Object> listeners = new HashMap();
|
||||
|
||||
public BaseActionSource mySource;
|
||||
|
||||
@Override
|
||||
public void addListener(IMEMonitorHandlerReciever<IAEItemStack> l, Object verificationToken)
|
||||
{
|
||||
|
@ -241,7 +244,7 @@ public class MEMonitorIInventory implements IMEInventory<IAEItemStack>, IMEMonit
|
|||
Entry<IMEMonitorHandlerReciever<IAEItemStack>, Object> l = i.next();
|
||||
IMEMonitorHandlerReciever<IAEItemStack> key = l.getKey();
|
||||
if ( key.isValid( l.getValue() ) )
|
||||
key.postChange( a );
|
||||
key.postChange( this, a, mySource );
|
||||
else
|
||||
i.remove();
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.util.HashMap;
|
|||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.IMEMonitorHandlerReciever;
|
||||
|
@ -18,6 +19,8 @@ public class MEMonitorPassthu<T extends IAEStack<T>> extends MEPassthru<T> imple
|
|||
HashMap<IMEMonitorHandlerReciever<T>, Object> listeners = new HashMap();
|
||||
IMEMonitor<T> monitor;
|
||||
|
||||
public BaseActionSource changeSource;
|
||||
|
||||
public MEMonitorPassthu(IMEInventory<T> i) {
|
||||
super( i );
|
||||
if ( i instanceof IMEMonitor )
|
||||
|
@ -42,7 +45,7 @@ public class MEMonitorPassthu<T extends IAEStack<T>> extends MEPassthru<T> imple
|
|||
if ( monitor != null )
|
||||
monitor.addListener( this, monitor );
|
||||
|
||||
Platform.postListChanges( before, after, this );
|
||||
Platform.postListChanges( before, after, this, changeSource );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -72,7 +75,7 @@ public class MEMonitorPassthu<T extends IAEStack<T>> extends MEPassthru<T> imple
|
|||
}
|
||||
|
||||
@Override
|
||||
public void postChange(T change)
|
||||
public void postChange(IMEMonitor<T> monitor, T change, BaseActionSource source)
|
||||
{
|
||||
Iterator<Entry<IMEMonitorHandlerReciever<T>, Object>> i = listeners.entrySet().iterator();
|
||||
while (i.hasNext())
|
||||
|
@ -80,7 +83,7 @@ public class MEMonitorPassthu<T extends IAEStack<T>> extends MEPassthru<T> imple
|
|||
Entry<IMEMonitorHandlerReciever<T>, Object> e = i.next();
|
||||
IMEMonitorHandlerReciever<T> recv = e.getKey();
|
||||
if ( recv.isValid( e.getValue() ) )
|
||||
recv.postChange( change );
|
||||
recv.postChange( this, change, source );
|
||||
else
|
||||
i.remove();
|
||||
}
|
||||
|
|
|
@ -11,6 +11,8 @@ import appeng.api.config.Settings;
|
|||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.energy.IEnergyGrid;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.networking.security.MachineSource;
|
||||
import appeng.api.networking.ticking.IGridTickable;
|
||||
import appeng.api.networking.ticking.TickRateModulation;
|
||||
import appeng.api.parts.IPartCollsionHelper;
|
||||
|
@ -26,10 +28,13 @@ import appeng.util.Platform;
|
|||
public class PartExportBus extends PartSharedItemBus implements IGridTickable
|
||||
{
|
||||
|
||||
BaseActionSource mySrc;
|
||||
|
||||
public PartExportBus(ItemStack is) {
|
||||
super( PartExportBus.class, is );
|
||||
settings.registerSetting( Settings.REDSTONE_OUTPUT, RedstoneMode.IGNORE );
|
||||
settings.registerSetting( Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE );
|
||||
settings.registerSetting( Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
|
||||
mySrc = new MachineSource( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -155,7 +160,7 @@ public class PartExportBus extends PartSharedItemBus implements IGridTickable
|
|||
{
|
||||
ais = ais.copy();
|
||||
ais.setStackSize( canFit );
|
||||
IAEItemStack itemsToAdd = Platform.poweredExtraction( energy, inv, ais );
|
||||
IAEItemStack itemsToAdd = Platform.poweredExtraction( energy, inv, ais, mySrc );
|
||||
|
||||
if ( itemsToAdd != null )
|
||||
{
|
||||
|
@ -193,7 +198,7 @@ public class PartExportBus extends PartSharedItemBus implements IGridTickable
|
|||
|
||||
public RedstoneMode getRSMode()
|
||||
{
|
||||
return (RedstoneMode) settings.getSetting( Settings.REDSTONE_OUTPUT );
|
||||
return (RedstoneMode) settings.getSetting( Settings.REDSTONE_CONTROLLED );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -12,6 +12,10 @@ import appeng.api.config.RedstoneMode;
|
|||
import appeng.api.config.Settings;
|
||||
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.ticking.IGridTickable;
|
||||
import appeng.api.networking.ticking.TickRateModulation;
|
||||
import appeng.api.networking.ticking.TickingRequest;
|
||||
|
@ -30,10 +34,15 @@ import appeng.util.inv.IInventoryDestination;
|
|||
public class PartImportBus extends PartSharedItemBus implements IGridTickable, IInventoryDestination
|
||||
{
|
||||
|
||||
BaseActionSource mySrc;
|
||||
IMEInventory<IAEItemStack> destination = null;
|
||||
IAEItemStack lastItemChecked = null;
|
||||
|
||||
public PartImportBus(ItemStack is) {
|
||||
super( PartImportBus.class, is );
|
||||
settings.registerSetting( Settings.REDSTONE_OUTPUT, RedstoneMode.IGNORE );
|
||||
settings.registerSetting( Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE );
|
||||
settings.registerSetting( Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
|
||||
mySrc = new MachineSource( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -51,9 +60,6 @@ public class PartImportBus extends PartSharedItemBus implements IGridTickable, I
|
|||
return false;
|
||||
}
|
||||
|
||||
IMEInventory<IAEItemStack> destination = null;
|
||||
IAEItemStack lastItemChecked = null;
|
||||
|
||||
@Override
|
||||
public boolean canInsert(ItemStack stack)
|
||||
{
|
||||
|
@ -165,6 +171,7 @@ public class PartImportBus extends PartSharedItemBus implements IGridTickable, I
|
|||
|
||||
itemToSend = Math.min( itemToSend, (int) (0.01 + proxy.getEnergy().extractAEPower( itemToSend, Actionable.SIMULATE, PowerMultiplier.CONFIG )) );
|
||||
IMEMonitor<IAEItemStack> inv = proxy.getStorage().getItemInventory();
|
||||
IEnergyGrid energy = proxy.getEnergy();
|
||||
|
||||
boolean Configured = false;
|
||||
for (int x = 0; x < availableSlots(); x++)
|
||||
|
@ -175,7 +182,7 @@ public class PartImportBus extends PartSharedItemBus implements IGridTickable, I
|
|||
Configured = true;
|
||||
while (itemToSend > 0)
|
||||
{
|
||||
if ( importStuff( myAdaptor, ais, inv ) )
|
||||
if ( importStuff( myAdaptor, ais, inv, energy ) )
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -185,7 +192,7 @@ public class PartImportBus extends PartSharedItemBus implements IGridTickable, I
|
|||
{
|
||||
while (itemToSend > 0)
|
||||
{
|
||||
if ( importStuff( myAdaptor, null, inv ) )
|
||||
if ( importStuff( myAdaptor, null, inv, energy ) )
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -207,7 +214,7 @@ public class PartImportBus extends PartSharedItemBus implements IGridTickable, I
|
|||
return doBusWork();
|
||||
}
|
||||
|
||||
private boolean importStuff(InventoryAdaptor myAdaptor, IAEItemStack whatToImport, IMEMonitor<IAEItemStack> inv)
|
||||
private boolean importStuff(InventoryAdaptor myAdaptor, IAEItemStack whatToImport, IMEMonitor<IAEItemStack> inv, IEnergySource energy)
|
||||
{
|
||||
if ( itemToSend > 64 )
|
||||
itemToSend = 64;
|
||||
|
@ -215,6 +222,7 @@ public class PartImportBus extends PartSharedItemBus implements IGridTickable, I
|
|||
ItemStack newItems = myAdaptor.removeItems( itemToSend, whatToImport == null ? null : whatToImport.getItemStack(), configDest( inv ) );
|
||||
if ( newItems != null )
|
||||
{
|
||||
newItems.stackSize = (int) (Math.min( newItems.stackSize, energy.extractAEPower( newItems.stackSize, Actionable.SIMULATE, PowerMultiplier.CONFIG ) ) + 0.01);
|
||||
itemToSend -= newItems.stackSize;
|
||||
|
||||
if ( lastItemChecked == null || !lastItemChecked.isSameType( newItems ) )
|
||||
|
@ -222,7 +230,8 @@ public class PartImportBus extends PartSharedItemBus implements IGridTickable, I
|
|||
else
|
||||
lastItemChecked.setStackSize( newItems.stackSize );
|
||||
|
||||
IAEItemStack failed = destination.injectItems( lastItemChecked, Actionable.MODULATE );
|
||||
IAEItemStack failed = Platform.poweredInsert( energy, destination, lastItemChecked, mySrc );
|
||||
// destination.injectItems( lastItemChecked, Actionable.MODULATE );
|
||||
if ( failed != null )
|
||||
{
|
||||
myAdaptor.addItems( failed.getItemStack() );
|
||||
|
@ -239,7 +248,7 @@ public class PartImportBus extends PartSharedItemBus implements IGridTickable, I
|
|||
|
||||
public RedstoneMode getRSMode()
|
||||
{
|
||||
return (RedstoneMode) settings.getSetting( Settings.REDSTONE_OUTPUT );
|
||||
return (RedstoneMode) settings.getSetting( Settings.REDSTONE_CONTROLLED );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -11,6 +11,8 @@ import net.minecraftforge.common.ForgeDirection;
|
|||
import appeng.api.AEApi;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.events.MENetworkCellArrayUpdate;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.networking.security.MachineSource;
|
||||
import appeng.api.networking.ticking.IGridTickable;
|
||||
import appeng.api.networking.ticking.ITickManager;
|
||||
import appeng.api.networking.ticking.TickRateModulation;
|
||||
|
@ -41,9 +43,11 @@ public class PartStorageBus extends PartBasicState implements IGridTickable, ICe
|
|||
{
|
||||
|
||||
int priority = 0;
|
||||
BaseActionSource mySrc;
|
||||
|
||||
public PartStorageBus(ItemStack is) {
|
||||
super( PartStorageBus.class, is );
|
||||
mySrc = new MachineSource( this );
|
||||
}
|
||||
|
||||
boolean cached = false;
|
||||
|
@ -98,6 +102,9 @@ public class PartStorageBus extends PartBasicState implements IGridTickable, ICe
|
|||
{
|
||||
IMEInventory inv = esh.getInventory( target, side.getOpposite(), StorageChannel.ITEMS );
|
||||
|
||||
if ( inv instanceof MEMonitorIInventory )
|
||||
((MEMonitorIInventory) inv).mySource = new MachineSource( this );
|
||||
|
||||
if ( inv instanceof MEMonitorIInventory )
|
||||
monitor = (MEMonitorIInventory) inv;
|
||||
|
||||
|
@ -240,11 +247,11 @@ public class PartStorageBus extends PartBasicState implements IGridTickable, ICe
|
|||
}
|
||||
|
||||
@Override
|
||||
public void postChange(IAEItemStack change)
|
||||
public void postChange(IMEMonitor<IAEItemStack> monitor, IAEItemStack change, BaseActionSource source)
|
||||
{
|
||||
try
|
||||
{
|
||||
proxy.getStorage().postAlterationOfStoredItems( StorageChannel.ITEMS, change );
|
||||
proxy.getStorage().postAlterationOfStoredItems( StorageChannel.ITEMS, change, mySrc );
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
{
|
||||
|
|
|
@ -29,6 +29,8 @@ 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.MachineSource;
|
||||
import appeng.api.networking.storage.IStorageGrid;
|
||||
import appeng.api.storage.ICellHandler;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
|
@ -61,6 +63,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
|
|||
static final int front[] = new int[] { 1 };
|
||||
|
||||
AppEngInternalInventory inv = new AppEngInternalInventory( this, 2 );
|
||||
BaseActionSource mySrc = new MachineSource( this );
|
||||
|
||||
ItemStack storageType;
|
||||
long lastStateChange = 0;
|
||||
|
@ -250,11 +253,11 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
|
|||
}
|
||||
|
||||
@Override
|
||||
public void postChange(T change)
|
||||
public void postChange(IMEMonitor<T> monitor, T change, BaseActionSource source)
|
||||
{
|
||||
try
|
||||
{
|
||||
gridProxy.getStorage().postAlterationOfStoredItems( chan, change );
|
||||
gridProxy.getStorage().postAlterationOfStoredItems( chan, change, mySrc );
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
{
|
||||
|
@ -336,7 +339,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
|
|||
try
|
||||
{
|
||||
IStorageGrid gs = gridProxy.getStorage();
|
||||
Platform.postChanges( gs, removed, added );
|
||||
Platform.postChanges( gs, removed, added, mySrc );
|
||||
|
||||
gridProxy.getGrid().postEvent( new MENetworkCellArrayUpdate() );
|
||||
}
|
||||
|
@ -369,7 +372,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
|
|||
{
|
||||
IMEInventory<IAEItemStack> cell = getHandler( StorageChannel.ITEMS );
|
||||
|
||||
IAEItemStack returns = Platform.poweredInsert( this, cell, AEApi.instance().storage().createItemStack( inv.getStackInSlot( 0 ) ) );
|
||||
IAEItemStack returns = Platform.poweredInsert( this, cell, AEApi.instance().storage().createItemStack( inv.getStackInSlot( 0 ) ), mySrc );
|
||||
|
||||
if ( returns == null )
|
||||
inv.setInventorySlotContents( 0, null );
|
||||
|
|
|
@ -18,6 +18,8 @@ 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.storage.IStorageGrid;
|
||||
import appeng.api.storage.ICellHandler;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
|
@ -45,6 +47,7 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive
|
|||
List<MEInventoryHandler> items = new LinkedList();
|
||||
List<MEInventoryHandler> fluids = new LinkedList();
|
||||
|
||||
BaseActionSource mySrc;
|
||||
long lastStateChange = 0;
|
||||
int state = 0;
|
||||
int priority = 0;
|
||||
|
@ -127,6 +130,7 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive
|
|||
}
|
||||
|
||||
public TileDrive() {
|
||||
mySrc = new MachineSource( this );
|
||||
gridProxy.setFlags( GridFlags.REQURE_CHANNEL );
|
||||
addNewHandler( new invManger() );
|
||||
}
|
||||
|
@ -158,7 +162,7 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive
|
|||
try
|
||||
{
|
||||
IStorageGrid gs = gridProxy.getStorage();
|
||||
Platform.postChanges( gs, removed, added );
|
||||
Platform.postChanges( gs, removed, added, mySrc );
|
||||
|
||||
gridProxy.getGrid().postEvent( new MENetworkCellArrayUpdate() );
|
||||
}
|
||||
|
|
|
@ -51,6 +51,7 @@ import appeng.api.implementations.IAEItemPowerStorage;
|
|||
import appeng.api.implementations.IAEWrench;
|
||||
import appeng.api.implementations.ITileStorageMonitorable;
|
||||
import appeng.api.networking.energy.IEnergySource;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.networking.storage.IStorageGrid;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.IMEMonitorHandlerReciever;
|
||||
|
@ -65,6 +66,7 @@ import appeng.core.AELog;
|
|||
import appeng.core.AppEng;
|
||||
import appeng.core.Configuration;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.me.cache.NetworkMonitor;
|
||||
import appeng.server.AccessType;
|
||||
import appeng.server.Security;
|
||||
import appeng.util.item.AEItemStack;
|
||||
|
@ -217,6 +219,20 @@ public class Platform
|
|||
return null;
|
||||
}
|
||||
|
||||
public static <T extends Enum> T rotateEnum(T ce, boolean backwards, EnumSet ValidOptions)
|
||||
{
|
||||
do
|
||||
{
|
||||
if ( backwards )
|
||||
ce = prevEnum( ce );
|
||||
else
|
||||
ce = nextEnum( ce );
|
||||
}
|
||||
while (!ValidOptions.contains( ce ));
|
||||
|
||||
return ce;
|
||||
}
|
||||
|
||||
/*
|
||||
* Simple way to cycle an enum...
|
||||
*/
|
||||
|
@ -1128,8 +1144,11 @@ public class Platform
|
|||
return 0;
|
||||
}
|
||||
|
||||
public static IAEItemStack poweredExtraction(IEnergySource energy, IMEInventory<IAEItemStack> cell, IAEItemStack request)
|
||||
public static IAEItemStack poweredExtraction(IEnergySource energy, IMEInventory<IAEItemStack> cell, IAEItemStack request, BaseActionSource src)
|
||||
{
|
||||
if ( cell instanceof NetworkMonitor )
|
||||
((NetworkMonitor) cell).setSource( src );
|
||||
|
||||
IAEItemStack possible = cell.extractItems( request.copy(), Actionable.SIMULATE );
|
||||
|
||||
long retrieved = 0;
|
||||
|
@ -1145,14 +1164,22 @@ public class Platform
|
|||
energy.extractAEPower( retrieved, Actionable.MODULATE, PowerMultiplier.CONFIG );
|
||||
|
||||
possible.setStackSize( itemToExtract );
|
||||
return cell.extractItems( possible, Actionable.MODULATE );
|
||||
IAEItemStack ret = cell.extractItems( possible, Actionable.MODULATE );
|
||||
|
||||
if ( cell instanceof NetworkMonitor )
|
||||
((NetworkMonitor) cell).setSource( null );
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static IAEItemStack poweredInsert(IEnergySource energy, IMEInventory<IAEItemStack> cell, IAEItemStack input)
|
||||
public static IAEItemStack poweredInsert(IEnergySource energy, IMEInventory<IAEItemStack> cell, IAEItemStack input, BaseActionSource src)
|
||||
{
|
||||
if ( cell instanceof NetworkMonitor )
|
||||
((NetworkMonitor) cell).setSource( src );
|
||||
|
||||
IAEItemStack possible = cell.injectItems( input.copy(), Actionable.SIMULATE );
|
||||
|
||||
long stored = input.getStackSize();
|
||||
|
@ -1175,13 +1202,19 @@ public class Platform
|
|||
split.add( cell.injectItems( input, Actionable.MODULATE ) );
|
||||
return split;
|
||||
}
|
||||
return cell.injectItems( input, Actionable.MODULATE );
|
||||
|
||||
IAEItemStack ret = cell.injectItems( input, Actionable.MODULATE );
|
||||
|
||||
if ( cell instanceof NetworkMonitor )
|
||||
((NetworkMonitor) cell).setSource( null );
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
return input;
|
||||
}
|
||||
|
||||
public static void postChanges(IStorageGrid gs, ItemStack removed, ItemStack added)
|
||||
public static void postChanges(IStorageGrid gs, ItemStack removed, ItemStack added, BaseActionSource src)
|
||||
{
|
||||
if ( removed != null )
|
||||
{
|
||||
|
@ -1192,7 +1225,7 @@ public class Platform
|
|||
for (IAEItemStack is : myItems.getAvailableItems( new ItemList() ))
|
||||
{
|
||||
is.setStackSize( -is.getStackSize() );
|
||||
gs.postAlterationOfStoredItems( StorageChannel.ITEMS, is );
|
||||
gs.postAlterationOfStoredItems( StorageChannel.ITEMS, is, src );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1203,7 +1236,7 @@ public class Platform
|
|||
for (IAEFluidStack is : myFluids.getAvailableItems( new ItemList() ))
|
||||
{
|
||||
is.setStackSize( -is.getStackSize() );
|
||||
gs.postAlterationOfStoredItems( StorageChannel.ITEMS, is );
|
||||
gs.postAlterationOfStoredItems( StorageChannel.ITEMS, is, src );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1216,7 +1249,7 @@ public class Platform
|
|||
{
|
||||
for (IAEItemStack is : myItems.getAvailableItems( new ItemList() ))
|
||||
{
|
||||
gs.postAlterationOfStoredItems( StorageChannel.ITEMS, is );
|
||||
gs.postAlterationOfStoredItems( StorageChannel.ITEMS, is, src );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1226,13 +1259,14 @@ public class Platform
|
|||
{
|
||||
for (IAEFluidStack is : myFluids.getAvailableItems( new ItemList() ))
|
||||
{
|
||||
gs.postAlterationOfStoredItems( StorageChannel.ITEMS, is );
|
||||
gs.postAlterationOfStoredItems( StorageChannel.ITEMS, is, src );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static public <T extends IAEStack<T>> void postListChanges(IItemList<T> before, IItemList<T> after, IMEMonitorHandlerReciever<T> meMonitorPassthu)
|
||||
static public <T extends IAEStack<T>> void postListChanges(IItemList<T> before, IItemList<T> after, IMEMonitorHandlerReciever<T> meMonitorPassthu,
|
||||
BaseActionSource source)
|
||||
{
|
||||
for (T is : before)
|
||||
is.setStackSize( -is.getStackSize() );
|
||||
|
@ -1244,7 +1278,7 @@ public class Platform
|
|||
{
|
||||
if ( is.getStackSize() != 0 )
|
||||
{
|
||||
meMonitorPassthu.postChange( is );
|
||||
meMonitorPassthu.postChange( null, is, source );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue