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; }
@Override public void add( T option ) { if( option != null && option.isCraftable() ) { option = option.copy(); option.setCraftable( false ); } this.target.add( option ); }
@Override public StackType empty() { final StackType dup = this.copy(); dup.reset(); return dup; }
final long size = Math.min( Integer.MAX_VALUE, request.getStackSize() ); if( l != null ) Results = l.copy(); if( l.getStackSize() <= size ) Results.setStackSize( l.getStackSize() ); if( mode == Actionable.MODULATE ) l.setStackSize( 0 ); this.saveChanges(); Results.setStackSize( size ); if( mode == Actionable.MODULATE ) l.setStackSize( l.getStackSize() - size ); this.saveChanges();
!(this.getViewMode() == ViewItems.CRAFTABLE && !t.isCraftable()) || !(this.getViewMode() == ViewItems.STORED && t.getStackSize() == 0) ); T stack = t.copy(); if (this.getViewMode().equals(ViewItems.CRAFTABLE)) { stack.setStackSize(0);
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 boolean add( final IAEStack e ) { if( this.myInterests.contains( e ) ) { return false; } return this.myInterests.add( e.copy() ) && this.gsc.getInterestManager().put( e, this ); }
@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 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(); } }
for (IAEStack s : this.removeFromExport) { if (s != null) { tag.setBoolean("remove-" + i + "-isItem", s.isItem()); NBTTagCompound data = new NBTTagCompound(); if (s.isItem()) { ((IAEItemStack) s).createItemStack().writeToNBT(data); } else { tag.setLong("remove-" + i + "-amount", s.getStackSize()); for (IAEStack s : this.addToExport) { if (s != null) { tag.setBoolean("add-" + i + "-isItem", s.isItem()); NBTTagCompound data = new NBTTagCompound(); if (s.isItem()) { ((IAEItemStack) s).createItemStack().writeToNBT(data); } else { tag.setLong("add-" + i + "-amount", s.getStackSize()); for (IAEStack s : this.export) { if (s != null) { tag.setBoolean("export-" + i + "-isItem", s.isItem()); NBTTagCompound data = new NBTTagCompound(); if (s.isItem()) { ((IAEItemStack) s).createItemStack().writeToNBT(data); } else { tag.setLong("export-" + i + "-amount", s.getStackSize());
for( final T v : this.cellItems ) itemCount += v.getStackSize(); v.writeToNBT( g ); this.tagCompound.setTag( ITEM_SLOT_KEYS[x], g ); this.tagCompound.setInteger( ITEM_SLOT_COUNT_KEYS[x], (int) v.getStackSize() );
private boolean matches( final FullnessMode fm, final IMEInventory src ) { if( fm == FullnessMode.HALF ) { return true; } final IItemList<? extends IAEStack> myList; if( src instanceof IMEMonitor ) { myList = ( (IMEMonitor) src ).getStorageList(); } else { myList = src.getAvailableItems( src.getChannel().createList() ); } if( fm == FullnessMode.EMPTY ) { return myList.isEmpty(); } final IAEStack test = myList.getFirstItem(); if( test != null ) { test.setStackSize( 1 ); return src.injectItems( test, Actionable.SIMULATE, this.mySrc ) != null; } return false; }
public void partition() { final IItemHandler inv = this.getUpgradeable().getInventoryByName( "config" ); final ItemStack is = this.getUpgradeable().getInventoryByName( "cell" ).getStackInSlot( 0 ); final IStorageChannel channel = is.getItem() instanceof IStorageCell ? ( (IStorageCell) is.getItem() ).getChannel() : AEApi.instance() .storage() .getStorageChannel( IItemStorageChannel.class ); final IMEInventory cellInv = AEApi.instance().registries().cell().getCellInventory( is, null, channel ); Iterator<IAEStack> i = new NullIterator<>(); if( cellInv != null ) { final IItemList list = cellInv.getAvailableItems( channel.createList() ); i = list.iterator(); } for( int x = 0; x < inv.getSlots(); x++ ) { if( i.hasNext() ) { // TODO: check if ok final ItemStack g = i.next().asItemStackRepresentation(); ItemHandlerUtil.setStackInSlot( inv, x, g ); } else { ItemHandlerUtil.setStackInSlot( inv, x, ItemStack.EMPTY ); } } this.detectAndSendChanges(); }
Preconditions.checkNotNull( mode ); final T possible = cell.extractItems( request.copy(), Actionable.SIMULATE, src ); retrieved = possible.getStackSize(); possible.setStackSize( itemToExtract ); final T ret = cell.extractItems( possible, Actionable.MODULATE, src ); src.player().ifPresent( player -> Stats.ItemsExtracted.addToPlayer( player, (int) ret.getStackSize() ) ); return possible.setStackSize( itemToExtract );
final long totalStackSize = s.getStackSize(); if( totalStackSize > 0 ) possible = totalStackSize - stack.getStackSize(); s.setStackSize( possible ); 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 boolean add( final IAEStack e ) { if( this.myInterests.contains( e ) ) { return false; } return this.myInterests.add( e.copy() ) && this.gsc.getInterestManager().put( e, this ); }
@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; }
@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 (IAEStack s : this.removeFromExport) { if (s != null) { tag.setBoolean("remove-" + i + "-isItem", s.isItem()); NBTTagCompound data = new NBTTagCompound(); if (s.isItem()) { ((IAEItemStack) s).createItemStack().writeToNBT(data); } else { tag.setLong("remove-" + i + "-amount", s.getStackSize()); for (IAEStack s : this.addToExport) { if (s != null) { tag.setBoolean("add-" + i + "-isItem", s.isItem()); NBTTagCompound data = new NBTTagCompound(); if (s.isItem()) { ((IAEItemStack) s).createItemStack().writeToNBT(data); } else { tag.setLong("add-" + i + "-amount", s.getStackSize()); for (IAEStack s : this.export) { if (s != null) { tag.setBoolean("export-" + i + "-isItem", s.isItem()); NBTTagCompound data = new NBTTagCompound(); if (s.isItem()) { ((IAEItemStack) s).createItemStack().writeToNBT(data); } else { tag.setLong("export-" + i + "-amount", s.getStackSize());