This commit is contained in:
@@ -218,11 +218,12 @@ public class CellInventory implements ICellInventory
|
|||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
|
||||||
final ItemStack sharedItemStack = input.createItemStack();
|
// This is slightly hacky as it expects a read-only access, but fine for now.
|
||||||
|
// TODO: Guarantee a read-only access. E.g. provide an isEmpty() method and ensure CellInventory does not write
|
||||||
if( CellInventory.isStorageCell( sharedItemStack ) )
|
// any NBT data for empty cells instead of relying on an empty IItemContainer
|
||||||
|
if( CellInventory.isStorageCell( input.getDefinition() ) )
|
||||||
{
|
{
|
||||||
final IMEInventory meInventory = getCell( sharedItemStack, null );
|
final IMEInventory meInventory = getCell( input.getDefinition(), null );
|
||||||
if( meInventory != null && !this.isEmpty( meInventory ) )
|
if( meInventory != null && !this.isEmpty( meInventory ) )
|
||||||
{
|
{
|
||||||
return input;
|
return input;
|
||||||
@@ -232,20 +233,20 @@ public class CellInventory implements ICellInventory
|
|||||||
final IAEItemStack l = this.getCellItems().findPrecise( input );
|
final IAEItemStack l = this.getCellItems().findPrecise( input );
|
||||||
if( l != null )
|
if( l != null )
|
||||||
{
|
{
|
||||||
final long remainingItemSlots = this.getRemainingItemCount();
|
final long remainingItemCount = this.getRemainingItemCount();
|
||||||
if( remainingItemSlots < 0 )
|
if( remainingItemCount < 0 )
|
||||||
{
|
{
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( input.getStackSize() > remainingItemSlots )
|
if( input.getStackSize() > remainingItemCount )
|
||||||
{
|
{
|
||||||
final IAEItemStack r = input.copy();
|
final IAEItemStack r = input.copy();
|
||||||
r.setStackSize( r.getStackSize() - remainingItemSlots );
|
r.setStackSize( r.getStackSize() - remainingItemCount );
|
||||||
if( mode == Actionable.MODULATE )
|
if( mode == Actionable.MODULATE )
|
||||||
{
|
{
|
||||||
l.setStackSize( l.getStackSize() + remainingItemSlots );
|
l.setStackSize( l.getStackSize() + remainingItemCount );
|
||||||
this.updateItemCount( remainingItemSlots );
|
this.updateItemCount( remainingItemCount );
|
||||||
this.saveChanges();
|
this.saveChanges();
|
||||||
}
|
}
|
||||||
return r;
|
return r;
|
||||||
@@ -269,19 +270,19 @@ public class CellInventory implements ICellInventory
|
|||||||
{
|
{
|
||||||
if( input.getStackSize() > remainingItemCount )
|
if( input.getStackSize() > remainingItemCount )
|
||||||
{
|
{
|
||||||
final ItemStack toReturn = sharedItemStack.copy();
|
final IAEItemStack toReturn = input.copy();
|
||||||
toReturn.setCount( sharedItemStack.getCount() - remainingItemCount );
|
toReturn.setStackSize( input.getStackSize() - remainingItemCount );
|
||||||
if( mode == Actionable.MODULATE )
|
if( mode == Actionable.MODULATE )
|
||||||
{
|
{
|
||||||
final ItemStack toWrite = sharedItemStack.copy();
|
final IAEItemStack toWrite = input.copy();
|
||||||
toWrite.setCount( remainingItemCount );
|
toWrite.setStackSize( remainingItemCount );
|
||||||
|
|
||||||
this.cellItems.add( AEItemStack.fromItemStack( toWrite ) );
|
this.cellItems.add( toWrite );
|
||||||
this.updateItemCount( toWrite.getCount() );
|
this.updateItemCount( toWrite.getStackSize() );
|
||||||
|
|
||||||
this.saveChanges();
|
this.saveChanges();
|
||||||
}
|
}
|
||||||
return AEItemStack.fromItemStack( toReturn );
|
return toReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( mode == Actionable.MODULATE )
|
if( mode == Actionable.MODULATE )
|
||||||
|
|||||||
Reference in New Issue
Block a user