private void addStack(ItemStack stack) { if(stack.isEmpty()) return; for(ItemStack oStack : materials) if(oStack.isItemEqual(stack) && ItemStack.areItemStackTagsEqual(oStack, stack)) { oStack.grow(stack.getCount()); return; } materials.add(stack); }
@Override public ItemStack addItems( final ItemStack toBeAdded ) { if( toBeAdded.isEmpty() ) { return ItemStack.EMPTY; } if( toBeAdded.getCount() == 0 ) { return ItemStack.EMPTY; } final ItemStack left = toBeAdded.copy(); for( final ItemStack is : this.i ) { if( ItemStack.areItemsEqual( is, left ) ) { is.grow( left.getCount() ); return ItemStack.EMPTY; } } this.i.add( left ); return ItemStack.EMPTY; }
is.grow( -amount );
is.grow( -amount );
@Override public ItemStack extractItem( int slot, int amount, boolean simulate ) { if( this.inv[slot] != null ) { final ItemStack split = this.getStackInSlot( slot ); if( amount >= split.getCount() ) { if( !simulate ) { this.inv[slot] = null; this.fireOnChangeInventory( slot, InvOperation.EXTRACT, split, ItemStack.EMPTY ); } return split; } else { if( !simulate ) { split.grow( -amount ); this.fireOnChangeInventory( slot, InvOperation.EXTRACT, ItemHandlerHelper.copyStackWithSize( split, amount ), ItemStack.EMPTY ); } return ItemHandlerHelper.copyStackWithSize( split, amount ); } } return ItemStack.EMPTY; }
/** * Helper method to add stack size and return the stack. */ public static ItemStack grow(ItemStack s, int i) { s.grow(i); return s; }
gathered.grow( extracted.getCount() );
rv.grow( extracted.getCount() ); amount -= extracted.getCount();
rv.grow( extracted.getCount() ); amount -= extracted.getCount();
existing.grow( reachedLimit ? limit : stack.getCount() );
public static int mergeItemsBetweenStacks(ItemStack takeFrom, ItemStack moveTo) { int room = moveTo.getMaxStackSize() - moveTo.getCount(); int moveover = 0; if (room > 0) { moveover = Math.min(takeFrom.getCount(), room); moveTo.grow(moveover); takeFrom.shrink(moveover); } return moveover; }
private void cookItem() { ItemStack itemstack = new ItemStack(slots().get(0).getItem(), 4, slots().get(0).getItemDamage()); ItemStack output = slots().get(8); if (output.isEmpty()) { slots().set(8, itemstack); } else if (output.isItemEqual(itemstack)) { output.grow(4); } for (int i = 0; i < 8; i++) { slots().get(i).shrink(1); } }
private void outputSlotIncrement() { ItemStack fullOnes = this.getStackInSlot(SLOT_OUTPUT); if (UtilItemStack.isEmpty(fullOnes)) { fullOnes = new ItemStack(Items.EXPERIENCE_BOTTLE); } else { fullOnes.grow(1); } this.setInventorySlotContents(SLOT_OUTPUT, fullOnes); }
private void smeltItem() { ItemStack toSmelt = inputInventory.getStackInSlot(0); ItemStack smeltResult = FurnaceRecipes.instance().getSmeltingResult(toSmelt).copy(); if (world.rand.nextFloat() < getOreDoubleChance() && ItemHelper.getOreDictionaryName(toSmelt).startsWith("ore")) { smeltResult.grow(smeltResult.getCount()); } ItemHandlerHelper.insertItemStacked(outputInventory, smeltResult, false); toSmelt.shrink(1); }
protected void catchFish() { ItemStack fish = FisherManager.getFish(); for (int j = 1; j < 5; j++) { if (inventory[j].isEmpty()) { inventory[j] = ItemHelper.cloneStack(fish); break; } else if (inventory[j].getCount() < inventory[j].getMaxStackSize() && ItemHelper.itemsIdentical(inventory[j], fish)) { inventory[j].grow(1); break; } } }
private boolean mergeOutput(@Nonnull ItemStack stack) { ItemStack oldOutput = getInventory().getSlot(OUTPUT_SLOT).get(); if (oldOutput.isEmpty()) { getInventory().getSlot(OUTPUT_SLOT).set(stack); return true; } else if (ItemUtil.areStackMergable(oldOutput, stack)) { oldOutput.grow(stack.splitStack(Math.min(oldOutput.getMaxStackSize() - oldOutput.getCount(), stack.getCount())).getCount()); getInventory().getSlot(OUTPUT_SLOT).set(oldOutput); return stack.isEmpty(); } return false; }
public void finishBurning(int theInput, int theOutput) { ItemStack output = FurnaceRecipes.instance().getSmeltingResult(this.inv.getStackInSlot(theInput)); if (!StackUtil.isValid(this.inv.getStackInSlot(theOutput))) { this.inv.setStackInSlot(theOutput, output.copy()); } else if (this.inv.getStackInSlot(theOutput).getItem() == output.getItem()) { this.inv.getStackInSlot(theOutput).grow(output.getCount()); } this.inv.getStackInSlot(theInput).shrink(1); }