Fixed some storage bus related crashes.
Fixed an issue where the storage might access inventories that have been removed from the world. Fixed an issue caused by refactoring.
This commit is contained in:
parent
42b6647ec3
commit
2b6cca0267
5 changed files with 22 additions and 14 deletions
|
@ -25,13 +25,13 @@ public class MEInventoryHandler<T extends IAEStack<T>> implements IMEInventoryHa
|
|||
public AccessRestriction myAccess = AccessRestriction.READ_WRITE;
|
||||
public IPartitionList<T> myPartitionList = new DefaultPriorityList<T>();
|
||||
|
||||
public MEInventoryHandler(IMEInventory<T> i, StorageChannel channel ) {
|
||||
public MEInventoryHandler(IMEInventory<T> i, StorageChannel channel) {
|
||||
this.channel = channel;
|
||||
|
||||
if ( i instanceof IMEInventoryHandler )
|
||||
internal = (IMEInventoryHandler<T>) i;
|
||||
else
|
||||
internal = new MEPassthru<T>( i );
|
||||
internal = new MEPassthru<T>( i, channel );
|
||||
|
||||
monitor = internal instanceof IMEMonitor ? (IMEMonitor<T>) internal : null;
|
||||
}
|
||||
|
|
|
@ -79,6 +79,8 @@ public class MEMonitorIInventory implements IMEInventory<IAEItemStack>, IMEMonit
|
|||
else
|
||||
out = adaptor.addItems( input.getItemStack() );
|
||||
|
||||
onTick();
|
||||
|
||||
if ( out == null )
|
||||
return null;
|
||||
|
||||
|
@ -127,8 +129,8 @@ public class MEMonitorIInventory implements IMEInventory<IAEItemStack>, IMEMonit
|
|||
@Override
|
||||
public IItemList<IAEItemStack> getAvailableItems(IItemList out)
|
||||
{
|
||||
for (ItemSlot is : adaptor)
|
||||
out.addStorage( is.getAEItemStack() );
|
||||
for (CachedItemStack is : memory.values())
|
||||
out.addStorage( is.aeStack );
|
||||
|
||||
return out;
|
||||
}
|
||||
|
@ -149,6 +151,9 @@ public class MEMonitorIInventory implements IMEInventory<IAEItemStack>, IMEMonit
|
|||
// better then doing construction from scratch :3
|
||||
IAEItemStack o = request.copy();
|
||||
o.setStackSize( out.stackSize );
|
||||
|
||||
onTick();
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,13 +20,11 @@ public class MEMonitorPassthu<T extends IAEStack<T>> extends MEPassthru<T> imple
|
|||
|
||||
HashMap<IMEMonitorHandlerReceiver<T>, Object> listeners = new HashMap();
|
||||
IMEMonitor<T> monitor;
|
||||
StorageChannel channel;
|
||||
|
||||
public BaseActionSource changeSource;
|
||||
|
||||
public MEMonitorPassthu(IMEInventory<T> i, StorageChannel channel ) {
|
||||
super( i );
|
||||
this.channel = channel;
|
||||
public MEMonitorPassthu(IMEInventory<T> i, StorageChannel channel) {
|
||||
super( i, channel );
|
||||
if ( i instanceof IMEMonitor )
|
||||
monitor = (IMEMonitor<T>) i;
|
||||
}
|
||||
|
@ -38,13 +36,15 @@ public class MEMonitorPassthu<T extends IAEStack<T>> extends MEPassthru<T> imple
|
|||
monitor.removeListener( this );
|
||||
|
||||
monitor = null;
|
||||
IItemList<T> before = getInternal() == null ? channel.createList() : getInternal().getAvailableItems( new ItemListIgnoreCrafting( channel.createList() ) );
|
||||
IItemList<T> before = getInternal() == null ? channel.createList() : getInternal()
|
||||
.getAvailableItems( new ItemListIgnoreCrafting( channel.createList() ) );
|
||||
|
||||
super.setInternal( i );
|
||||
if ( i instanceof IMEMonitor )
|
||||
monitor = (IMEMonitor<T>) i;
|
||||
|
||||
IItemList<T> after = getInternal() == null ? channel.createList() : getInternal().getAvailableItems( new ItemListIgnoreCrafting( channel.createList() ) );
|
||||
IItemList<T> after = getInternal() == null ? channel.createList() : getInternal()
|
||||
.getAvailableItems( new ItemListIgnoreCrafting( channel.createList() ) );
|
||||
|
||||
if ( monitor != null )
|
||||
monitor.addListener( this, monitor );
|
||||
|
|
|
@ -13,13 +13,15 @@ public class MEPassthru<T extends IAEStack<T>> implements IMEInventoryHandler<T>
|
|||
{
|
||||
|
||||
private IMEInventory<T> internal;
|
||||
final protected StorageChannel channel;
|
||||
|
||||
protected IMEInventory<T> getInternal()
|
||||
{
|
||||
return internal;
|
||||
}
|
||||
|
||||
public MEPassthru( IMEInventory<T> i ) {
|
||||
public MEPassthru(IMEInventory<T> i, StorageChannel channel) {
|
||||
this.channel = channel;
|
||||
setInternal( i );
|
||||
}
|
||||
|
||||
|
|
|
@ -152,9 +152,6 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
|
|||
|
||||
private void resetCache(boolean fullReset)
|
||||
{
|
||||
if ( monitor != null )
|
||||
monitor.onTick();
|
||||
|
||||
if ( host == null || host.getTile() == null || host.getTile().getWorldObj() == null )
|
||||
return;
|
||||
|
||||
|
@ -168,6 +165,10 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
|
|||
handlerHash = 0;
|
||||
|
||||
IMEInventory<IAEItemStack> out = getInternalHandler();
|
||||
|
||||
if ( monitor != null )
|
||||
monitor.onTick();
|
||||
|
||||
IItemList<IAEItemStack> after = AEApi.instance().storage().createItemList();
|
||||
if ( out != null )
|
||||
after = out.getAvailableItems( after );
|
||||
|
|
Loading…
Reference in a new issue