Fixes #4213: Prevent NPE when inserting via conversion monitor (#4265)

This commit is contained in:
yueh
2020-01-26 13:36:06 +01:00
committed by GitHub
parent d5fc7a5b21
commit 1fc1d5517d
@@ -179,9 +179,11 @@ public class PartConversionMonitor extends AbstractPartMonitor
final IEnergySource energy = this.getProxy().getEnergy(); final IEnergySource energy = this.getProxy().getEnergy();
final IMEMonitor<IAEItemStack> cell = this.getProxy() final IMEMonitor<IAEItemStack> cell = this.getProxy()
.getStorage() .getStorage()
.getInventory( .getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
if( allItems ) if( allItems )
{
if( this.getDisplayed() != null )
{ {
final IAEItemStack input = this.getDisplayed().copy(); final IAEItemStack input = this.getDisplayed().copy();
IItemHandler inv = new PlayerMainInvWrapper( player.inventory ); IItemHandler inv = new PlayerMainInvWrapper( player.inventory );
@@ -196,12 +198,14 @@ public class PartConversionMonitor extends AbstractPartMonitor
{ {
input.setStackSize( canExtract.getCount() ); input.setStackSize( canExtract.getCount() );
final IAEItemStack failedToInsert = Platform.poweredInsert( energy, cell, input, new PlayerSource( player, this ) ); final IAEItemStack failedToInsert = Platform.poweredInsert( energy, cell, input, new PlayerSource( player, this ) );
inv.extractItem( x, failedToInsert == null ? canExtract.getCount() : canExtract.getCount() - (int) failedToInsert.getStackSize(), inv.extractItem( x,
failedToInsert == null ? canExtract.getCount() : canExtract.getCount() - (int) failedToInsert.getStackSize(),
false ); false );
} }
} }
} }
} }
}
else else
{ {
final IAEItemStack input = AEItemStack.fromItemStack( player.getHeldItem( hand ) ); final IAEItemStack input = AEItemStack.fromItemStack( player.getHeldItem( hand ) );