private T monitorDifference( final IAEStack<T> original, final T leftOvers, final boolean extraction, final IActionSource src ) { final T diff = original.copy(); if( extraction ) { diff.setStackSize( leftOvers == null ? 0 : -leftOvers.getStackSize() ); } else if( leftOvers != null ) { diff.decStackSize( leftOvers.getStackSize() ); } if( diff.getStackSize() != 0 ) { this.postChangesToListeners( ImmutableList.of( diff ), src ); } return leftOvers; }
private T monitorDifference( final T original, final T leftOvers, final boolean extraction, final IActionSource src ) { final T diff = original.copy(); if( extraction ) { diff.setStackSize( leftOvers == null ? 0 : -leftOvers.getStackSize() ); } else if( leftOvers != null ) { diff.decStackSize( leftOvers.getStackSize() ); } if( diff.getStackSize() != 0 ) { this.postChangesToListeners( ImmutableList.of( diff ), src ); } return leftOvers; }
public static <T extends IAEStack<T>> void postListChanges( final IItemList<T> before, final IItemList<T> after, final IMEMonitorHandlerReceiver<T> meMonitorPassthrough, final IActionSource source ) { final List<T> changes = new ArrayList<>(); for( final T is : before ) { is.setStackSize( -is.getStackSize() ); } for( final T is : after ) { before.add( is ); } for( final T is : before ) { if( is.getStackSize() != 0 ) { changes.add( is ); } } if( !changes.isEmpty() ) { meMonitorPassthrough.postChange( null, changes, source ); } }
@Override public T injectItems( final T input, final Actionable mode, final IActionSource src ) { if( mode == Actionable.SIMULATE ) { return null; } if( input != null ) { this.target.addPower( input.getStackSize() / (double) this.channel.transferFactor() ); } return null; }
@Override public T injectItems( final T input, final Actionable type, final IActionSource src ) { final long size = input.getStackSize(); final T a = super.injectItems( input, type, src ); if( type == Actionable.MODULATE && ( a == null || a.getStackSize() != size ) ) { final int newStatus = this.getStatus(); if( newStatus != this.oldStatus ) { this.cord.blinkCell( this.getSlot() ); this.oldStatus = newStatus; } } return a; }
long stored = input.getStackSize(); if( possible != null ) stored -= possible.getStackSize(); if( itemToAdd < input.getStackSize() ) final long original = input.getStackSize(); final T split = input.copy(); split.decStackSize( itemToAdd ); final long diff = original - split.getStackSize(); Stats.ItemsInserted.addToPlayer( player, (int) diff ); } ); final long diff = ret == null ? input.getStackSize() : input.getStackSize() - ret.getStackSize(); Stats.ItemsInserted.addToPlayer( player, (int) diff ); } ); final T ret = input.copy().setStackSize( input.getStackSize() - itemToAdd ); return ( ret != null && ret.getStackSize() > 0 ) ? ret : null;
request = request.copy(); output.setStackSize( 0 ); final long req = request.getStackSize(); while( ii.hasNext() && output.getStackSize() < req ) request.setStackSize( req - output.getStackSize() ); output.add( inv.extractItems( request, mode, src ) ); if( output.getStackSize() <= 0 )
final long size = Math.min( Integer.MAX_VALUE, request.getStackSize() ); if( l.getStackSize() <= size ) Results.setStackSize( l.getStackSize() ); if( mode == Actionable.MODULATE ) if( mode == Actionable.MODULATE ) l.setStackSize( l.getStackSize() - size ); this.saveChanges();
protected void saveChanges() { // recalculate values this.storedItems = (short) this.cellItems.size(); this.storedItemCount = 0; for( final T v : this.cellItems ) { this.storedItemCount += v.getStackSize(); } this.isPersisted = false; if( this.container != null ) { this.container.saveChanges( this ); } else { // if there is no ISaveProvider, store to NBT immediately this.persist(); } }
if( possible != null ) retrieved = possible.getStackSize(); src.player().ifPresent( player -> Stats.ItemsExtracted.addToPlayer( player, (int) ret.getStackSize() ) );
final long totalStackSize = s.getStackSize(); if( totalStackSize > 0 ) possible = totalStackSize - stack.getStackSize(); if( extracted != null ) possible = extracted.getStackSize(); final IAEStack failed = Platform.poweredInsert( energy, destination, extracted, this.mySrc ); possible -= failed.getStackSize(); src.injectItems( failed, Actionable.MODULATE, this.mySrc );
@Override public void onStackChange( final IItemList o, final IAEStack fullStack, final IAEStack diffStack, final IActionSource src, final IStorageChannel chan ) { if( this.configuredItem != null ) { if( fullStack == null ) { this.configuredItem.setStackSize( 0 ); } else { this.configuredItem.setStackSize( fullStack.getStackSize() ); } final long stackSize = this.configuredItem.getStackSize(); final String humanReadableText = NUMBER_CONVERTER.toWideReadableForm( stackSize ); if( !humanReadableText.equals( this.lastHumanReadableText ) ) { this.lastHumanReadableText = humanReadableText; this.getHost().markForUpdate(); } } }
@Override public void onStackChange( IItemList<?> o, IAEStack<?> fullStack, IAEStack<?> diffStack, IActionSource src, IStorageChannel<?> chan ) { if( chan == AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) && fullStack.equals( this.config.getFluidInSlot( 0 ) ) ) { this.lastReportedValue = fullStack.getStackSize(); this.updateState(); } }
if( input.getStackSize() == 0 ) if( input.getStackSize() > remainingItemCount ) r.setStackSize( r.getStackSize() - remainingItemCount ); if( mode == Actionable.MODULATE ) l.setStackSize( l.getStackSize() + remainingItemCount ); this.saveChanges(); l.setStackSize( l.getStackSize() + input.getStackSize() ); this.saveChanges(); if( remainingItemCount > 0 ) if( input.getStackSize() > remainingItemCount ) toReturn.setStackSize( input.getStackSize() - remainingItemCount ); if( mode == Actionable.MODULATE )
@Override public void onStackChange( final IItemList o, final IAEStack fullStack, final IAEStack diffStack, final IActionSource src, final IStorageChannel chan ) { if( chan == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) && fullStack.equals( this.config.getAEStackInSlot( 0 ) ) && this .getInstalledUpgrades( Upgrades.FUZZY ) == 0 ) { this.lastReportedValue = fullStack.getStackSize(); this.updateState(); } }
for( final T v : this.cellItems ) itemCount += v.getStackSize(); this.tagCompound.setInteger( ITEM_SLOT_COUNT_KEYS[x], (int) v.getStackSize() );
difference.setStackSize( -changedItem.getStackSize() );
public static long getStackSize(Object o) { if (o instanceof ItemStack) return ((ItemStack) o).getCount(); if (o instanceof IAEStack) return ((IAEStack) o).getStackSize(); return 0; }
@SuppressWarnings( { "rawtypes", "unchecked" } ) public static void postChanges( final IStorageGrid gs, final ItemStack removed, final ItemStack added, final IActionSource src ) { for( final IStorageChannel<?> chan : AEApi.instance().storage().storageChannels() ) { final IItemList<?> myChanges = chan.createList(); if( !removed.isEmpty() ) { final IMEInventory myInv = AEApi.instance().registries().cell().getCellInventory( removed, null, chan ); if( myInv != null ) { myInv.getAvailableItems( myChanges ); for( final IAEStack is : myChanges ) { is.setStackSize( -is.getStackSize() ); } } } if( !added.isEmpty() ) { final IMEInventory myInv = AEApi.instance().registries().cell().getCellInventory( added, null, chan ); if( myInv != null ) { myInv.getAvailableItems( myChanges ); } } gs.postAlterationOfStoredItems( chan, myChanges, src ); } }
@Override public void onStackChange(IItemList o, IAEStack fullStack, IAEStack diffStack, IActionSource src, IStorageChannel chan) { if (isGas && chan == StorageChannels.GAS()) onStackChangeGas((IAEGasStack) fullStack, (IAEGasStack) diffStack); else if (chan == StorageChannels.FLUID() && diffStack != null && ((IAEFluidStack) diffStack).getFluid() == this.selectedFluid) { this.currentAmount = fullStack != null ? fullStack.getStackSize() : 0; IGridNode node = getGridNode(); if (node != null) { setActive(node.isActive()); getHost().markForUpdate(); notifyTargetBlock(getHostTile(), getFacing()); } } }