@Override public long requesting( IAEItemStack what ) { long requested = 0; for( final CraftingCPUCluster cluster : this.craftingCPUClusters ) { final IAEItemStack stack = cluster.making( what ); requested += stack != null ? stack.getStackSize() : 0; } return requested; }
private void updateCPU() { IAEItemStack send = this.finalOutput; if( this.finalOutput != null && this.finalOutput.getStackSize() <= 0 ) { send = null; } for( final TileCraftingMonitorTile t : this.status ) { t.setJob( send ); } }
@Override public IAEItemStack injectItems( final IAEItemStack input, final Actionable mode, final IActionSource src ) { if( mode == Actionable.MODULATE && input != null ) { this.target.addPower( input.getStackSize() ); } return null; }
public boolean canAccept( final IAEItemStack input ) { if( input instanceof IAEItemStack ) { final IAEItemStack is = this.waitingFor.findPrecise( input ); if( is != null && is.getStackSize() > 0 ) { return true; } } return false; }
private long getTotal( final IAEItemStack is ) { final IAEItemStack a = this.storage.findPrecise( is ); final IAEItemStack c = this.pending.findPrecise( is ); final IAEItemStack m = this.missing.findPrecise( is ); long total = 0; if( a != null ) { total += a.getStackSize(); } if( c != null ) { total += c.getStackSize(); } if( m != null ) { total += m.getStackSize(); } return total; }
private void updateElapsedTime( final IAEItemStack is ) { final long nextStartTime = System.nanoTime(); this.elapsedTime = this.getElapsedTime() + nextStartTime - this.lastTime; this.lastTime = nextStartTime; this.remainingItemCount = this.getRemainingItemCount() - is.getStackSize(); }
private void handleItemChanged( int slot, IAEItemStack oldAeIS, ItemStack newIS, List<IAEItemStack> changes ) { // Completely different item this.cachedAeStacks[slot] = AEItemStack.fromItemStack( newIS ); // If we had a stack previously in this slot, notify the network about its disappearance if( oldAeIS != null ) { oldAeIS.setStackSize( -oldAeIS.getStackSize() ); changes.add( oldAeIS ); } // Notify the network about the new stack. Note that this is null if newIS was null if( this.cachedAeStacks[slot] != null ) { changes.add( this.cachedAeStacks[slot] ); } } }
public void setJob( final IAEItemStack is ) { if( ( is == null ) != ( this.dspPlay == null ) ) { this.dspPlay = is == null ? null : is.copy(); this.markForUpdate(); } else if( is != null && this.dspPlay != null ) { if( is.getStackSize() != this.dspPlay.getStackSize() ) { this.dspPlay = is.copy(); this.markForUpdate(); } } }
void addTask( IAEItemStack what, final long crafts, final ICraftingPatternDetails details, final int depth ) { if( crafts > 0 ) { what = what.copy(); what.setStackSize( what.getStackSize() * crafts ); this.crafting.add( what ); } }
@Override public void addStorage( final IAEItemStack option ) { if( option == null ) { return; } final IAEItemStack st = this.records.get( ( (AEItemStack) option ).getSharedStack() ); if( st != null ) { st.incStackSize( option.getStackSize() ); return; } final IAEItemStack opt = option.copy(); this.putItemRecord( opt ); }
void getPlan( final IItemList<IAEItemStack> plan ) { for( IAEItemStack i : this.details.getOutputs() ) { i = i.copy(); i.setCountRequestable( i.getStackSize() * this.crafts ); plan.addRequestable( i ); } for( final CraftingTreeNode pro : this.nodes.keySet() ) { pro.getPlan( plan ); } } }
@Override public boolean canInsert( final ItemStack stack ) { if( stack.isEmpty() ) { return false; } final IAEItemStack failed = this.me.injectItems( AEItemStack.fromItemStack( stack ), Actionable.SIMULATE, null ); if( failed == null ) { return true; } return failed.getStackSize() != stack.getCount(); } }
private void updateReportingValue( final IMEMonitor<IAEItemStack> itemInventory ) { if( this.configuredItem != null ) { final IAEItemStack result = itemInventory.getStorageList().findPrecise( this.configuredItem ); if( result == null ) { this.configuredItem.setStackSize( 0 ); } else { this.configuredItem.setStackSize( result.getStackSize() ); } } }
private void handleStackSizeChanged( int slot, IAEItemStack oldAeIS, ItemStack newIS, List<IAEItemStack> changes ) { // Still the same item, but amount might have changed final long diff = newIS.getCount() - oldAeIS.getStackSize(); if( diff != 0 ) { final IAEItemStack stack = oldAeIS.copy(); stack.setStackSize( newIS.getCount() ); this.cachedAeStacks[slot] = stack; final IAEItemStack a = stack.copy(); a.setStackSize( diff ); changes.add( a ); } }
@Override public IAEItemStack extractItems( final IAEItemStack request, final Actionable mode, final IActionSource src ) { AEItemStack ret = null; ItemStack slotItem = this.target.getOutputSlot().getStackInSlot( 0 ); if( !slotItem.isEmpty() && request.isSameType( slotItem ) ) { int count = (int) Math.min( request.getStackSize(), Integer.MAX_VALUE ); ret = AEItemStack.fromItemStack( this.target.getOutputSlot().extractItem( 0, count, mode == Actionable.SIMULATE ) ); } return ret; }
private void prepareElapsedTime() { this.lastTime = System.nanoTime(); this.elapsedTime = 0; final IItemList<IAEItemStack> list = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList(); this.getListOfItem( list, CraftingItemList.ACTIVE ); this.getListOfItem( list, CraftingItemList.PENDING ); int itemCount = 0; for( final IAEItemStack ge : list ) { itemCount += ge.getStackSize(); } this.startItemCount = itemCount; this.remainingItemCount = itemCount; }
@Override public boolean canInsert( final ItemStack stack ) { final IAEItemStack out = this.destination.injectItems( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createStack( stack ), Actionable.SIMULATE, null ); if( out == null ) { return true; } return out.getStackSize() != stack.getCount(); // ItemStack after = adaptor.simulateAdd( stack ); // if ( after == null ) // return true; // return after.stackSize != stack.stackSize; }
@Override public void add( final IAEItemStack option ) { if( option == null ) { return; } this.incStackSize( option.getStackSize() ); this.setCountRequestable( this.getCountRequestable() + option.getCountRequestable() ); this.setCraftable( this.isCraftable() || option.isCraftable() ); }
private boolean handleCrafting( final int x, final InventoryAdaptor d, final IAEItemStack itemStack ) { try { if( this.getInstalledUpgrades( Upgrades.CRAFTING ) > 0 && itemStack != null ) { return this.craftingTracker.handleCrafting( x, itemStack.getStackSize(), itemStack, d, this.iHost.getTileEntity().getWorld(), this.gridProxy.getGrid(), this.gridProxy.getCrafting(), this.mySource ); } } catch( final GridAccessException e ) { // :P } return false; }
/** * Render an item in 2D and the given text below it. * * @param spacing Specifies how far apart the item and the item stack amount are rendered. */ public static void renderItem2dWithAmount( IAEItemStack itemStack, float itemScale, float spacing ) { final ItemStack renderStack = itemStack.asItemStackRepresentation(); TesrRenderHelper.renderItem2d( renderStack, itemScale ); final long stackSize = itemStack.getStackSize(); final String renderedStackSize = NUMBER_CONVERTER.toWideReadableForm( stackSize ); // Render the item count final FontRenderer fr = Minecraft.getMinecraft().fontRenderer; final int width = fr.getStringWidth( renderedStackSize ); GlStateManager.translate( 0.0f, spacing, 0 ); GlStateManager.scale( 1.0f / 62.0f, 1.0f / 62.0f, 1.0f / 62.0f ); GlStateManager.translate( -0.5f * width, 0.0f, 0.5f ); fr.drawString( renderedStackSize, 0, 0, 0 ); }