@Override public int getItemStackLimit( @Nonnull ItemStack stack ) { return Math.min( this.getSlotStackLimit(), stack.getMaxStackSize() ); }
protected int getStackLimit( int slot, @Nonnull ItemStack stack ) { return Math.min( this.getSlotLimit( slot ), stack.getMaxStackSize() ); }
protected Collection<? extends ItemStack> breakDownBigStack(ItemStack stack) { List<ItemStack> stacks = new ArrayList<ItemStack>(); int additionalStacks = stack.getCount() / stack.getMaxStackSize(); int lastStackSize = stack.getCount() % stack.getMaxStackSize(); if(additionalStacks > 0) { ItemStack fullStack = stack.copy(); fullStack.setCount(stack.getMaxStackSize()); for (int i = 0; i < additionalStacks; i++) { stacks.add(fullStack.copy()); } } ItemStack lastStack = stack.copy(); lastStack.setCount(lastStackSize); stacks.add(lastStack); return stacks; } }
public void doRequest(boolean fullStack) { if(world.isRemote) return; ICorporeaSpark spark = getSpark(); if(spark != null && spark.getMaster() != null && requestTarget != null) { int count = fullStack ? requestTarget.getMaxStackSize() : 1; doCorporeaRequest(requestTarget, count, spark); } }
ais.setStackSize( ais.getDefinition().getMaxStackSize() ); while( true )
public boolean canAcceptItem(ItemStack stack, List<ItemStack> filter, int filterType) { if(stack.isEmpty()) return false; if(filter.isEmpty()) return true; switch(filterType) { case 0 : { // Accept items in frames only boolean anyFilter = false; for(ItemStack filterEntry : filter) { if(filterEntry == null) continue; anyFilter = true; boolean itemEqual = stack.getItem() == filterEntry.getItem(); boolean damageEqual = stack.getItemDamage() == filterEntry.getItemDamage(); boolean nbtEqual = ItemStack.areItemStackTagsEqual(filterEntry, stack); if(itemEqual && damageEqual && nbtEqual) return true; if(!stack.getHasSubtypes() && stack.isItemStackDamageable() && stack.getMaxStackSize() == 1 && itemEqual && nbtEqual) return true; if(stack.getItem() instanceof IManaItem && itemEqual) return true; } return !anyFilter; } case 1 : return !canAcceptItem(stack, filter, 0); // Accept items not in frames only default : return true; // Accept all items } }
@Override public boolean onClicked( EntityPlayer player, EnumHand hand, Vec3d pos ) { if( Platform.isClient() ) { return true; } if( !this.getProxy().isActive() ) { return false; } if( !Platform.hasPermissions( this.getLocation(), player ) ) { return false; } if( this.getDisplayed() != null ) { this.extractItem( player, this.getDisplayed().getDefinition().getMaxStackSize() ); } return true; }
@SubscribeEvent public static void buttonPressed(KeyboardInputEvent.Post event) { Minecraft mc = Minecraft.getMinecraft(); if(mc.world == null || !supportedGuiFilter.test(mc.currentScreen) || Keyboard.getEventKey() != ClientProxy.CORPOREA_REQUEST.getKeyCode() || !Keyboard.getEventKeyState() || Keyboard.isRepeatEvent() || TileCorporeaIndex.InputHandler.getNearbyIndexes(mc.player).isEmpty()) return; ItemStack stack = getStackUnderMouse(); if(stack != null && !stack.isEmpty()) { int count = 1; int max = stack.getMaxStackSize(); if(GuiScreen.isShiftKeyDown()) { count = max; if(GuiScreen.isCtrlKeyDown()) count /= 4; } else if(GuiScreen.isCtrlKeyDown()) count = max / 2; if(count > 0) { String name = CorporeaHelper.stripControlCodes(stack.getDisplayName()); String full = count + " " + name; mc.ingameGUI.getChatGUI().addToSentMessages(full); mc.player.sendChatMessage(full); event.setCanceled(true); } } }
public static boolean canFurnaceSmelt(TileEntityFurnace furnace){ if(furnace.getStackInSlot(0).isEmpty()) return false; else { ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(furnace.getStackInSlot(0)); if(itemstack.isEmpty()) return false; if(furnace.getStackInSlot(2).isEmpty()) return true; if(!furnace.getStackInSlot(2).isItemEqual(itemstack)) return false; int result = furnace.getStackInSlot(2).getCount() + itemstack.getCount(); return result <= 64 && result <= itemstack.getMaxStackSize(); } }
maxTimesToCraft = (int) Math.floor( (double) this.getStack().getMaxStackSize() / (double) howManyPerCraft ); maxTimesToCraft = (int) Math.floor( (double) this.getStack().getMaxStackSize() / (double) howManyPerCraft );
@Override protected int getNumCanMerge(@Nonnull ItemStack itemStack, @Nonnull ItemStack result) { if (!ItemUtil.areStackMergable(itemStack, result)) { // next result is a different item type return 0; } return Math.min(itemStack.getMaxStackSize() - itemStack.getCount(), result.getCount()); }
text = TextFormatting.GREEN + stack.getDisplayName(); if(count >= 0) { int max = stack.getMaxStackSize(); int stacks = count / max; int rem = count % max;
protected int getNumCanMerge(@Nonnull ItemStack itemStack, @Nonnull ItemStack result) { if (!itemStack.isItemEqual(result) || !ItemStack.areItemStackTagsEqual(itemStack, result)) { return 0; } return Math.min(itemStack.getMaxStackSize() - itemStack.getCount(), result.getCount()); }
IItemHandler inv = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side); ItemStack toAdd = new ItemStack(bBlock, 1, bmeta); int maxSize = toAdd.getMaxStackSize(); toAdd.setCount(remove(stack, maxSize)); ItemStack remainder = ItemHandlerHelper.insertItemStacked(inv, toAdd, false);
int maxSize = t.getMaxStackSize(); if( maxSize > d.getSlotStackLimit() ) int maxSize = t.getMaxStackSize(); if( d.getSlotStackLimit() < maxSize ) int maxSize = tis.getMaxStackSize(); if( maxSize > d.getSlotStackLimit() )
is.setCount( Math.min( is.getMaxStackSize(), is.getCount() + 1 ) ); ItemStack myItem = ais.createItemStack(); ais.setStackSize( myItem.getMaxStackSize() ); if( item.getCount() >= item.getMaxStackSize() ) ais.setStackSize( ais.getDefinition().getMaxStackSize() ); ais = Platform.poweredExtraction( this.getPowerSource(), this.getCellInventory(), ais, this.getActionSource() ); if( ais != null ) final long maxSize = ais.getDefinition().getMaxStackSize(); ais.setStackSize( maxSize ); ais = this.getCellInventory().extractItems( ais, Actionable.SIMULATE, this.getActionSource() ); is.setCount( is.getMaxStackSize() ); player.inventory.setItemStack( is ); this.updateHeld( player ); ItemStack myItem = ais.createItemStack(); ais.setStackSize( myItem.getMaxStackSize() );
@Override public boolean hasResourcesMin(float percentage) { IInventoryAdapter inventory = getInternalInventory(); if (inventory.getStackInSlot(InventoryCentrifuge.SLOT_RESOURCE).isEmpty()) { return false; } return (float) inventory.getStackInSlot(InventoryCentrifuge.SLOT_RESOURCE).getCount() / (float) inventory.getStackInSlot(InventoryCentrifuge.SLOT_RESOURCE).getMaxStackSize() > percentage; }
private boolean canMergeOutput() { ItemStack oldOutput = getInventory().getSlot(OUTPUT_SLOT).get(); if (oldOutput.isEmpty()) { return true; } ItemStack output = craftingGrid.getOutput(); if (!ItemUtil.areStackMergable(oldOutput, output)) { return false; } return output.getMaxStackSize() >= (oldOutput.getCount() + output.getCount()); }
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; }
final Item i = is.getItem(); long maxStorage = Math.min( input.getStackSize(), is.getMaxStackSize() ); boolean worked = false;