private NonNullList<ItemStack> getInputs() { NonNullList<ItemStack> input = NonNullList.withSize(tile.getSizeInventory() - 1, ItemStack.EMPTY); for(int i = 1; i < tile.getSizeInventory(); i++) { input.set(i - 1, tile.getStackInSlot(i)); } return input; }
protected ItemStackList getDemoTools(ItemStack[][] inputItems) { ItemStackList demo = ItemStackList.withSize(tool.size()); for(int i = 0; i < tool.size(); i++) { if(tool.get(i) instanceof ToolCore) { ToolCore core = (ToolCore) tool.get(i); List<Material> mats = ImmutableList.of(TinkerMaterials.wood, TinkerMaterials.cobalt, TinkerMaterials.ardite, TinkerMaterials.manyullyn); mats = mats.subList(0, core.getRequiredComponents().size()); demo.set(i, ((ToolCore) tool.get(i)).buildItemForRendering(mats)); } else if(tool != null) { demo.set(i, new ItemStack(tool.get(i))); } if(!demo.get(i).isEmpty()) { modifier.apply(demo.get(i)); } } return demo; } }
private ItemStack buildTool() throws TinkerGuiException { NonNullList<ItemStack> input = ItemStackList.withSize(tile.getSizeInventory()); for(int i = 0; i < input.size(); i++) { input.set(i, tile.getStackInSlot(i)); } ItemStack result = ToolBuilder.tryBuildTool(input, toolName, getBuildableTools()); if(!result.isEmpty()) { TinkerCraftingEvent.ToolCraftingEvent.fireEvent(result, player, input); } return result; }
/** * Create an ItemStackList from the given elements. */ public static ItemStackList of(IInventory inventory) { ItemStackList itemStackList = withSize(inventory.getSizeInventory()); for(int i = 0; i < inventory.getSizeInventory(); i++) { itemStackList.add(inventory.getStackInSlot(i)); } return itemStackList; }
/** * @param name Localization String for the inventory title. Can be overridden through setCustomName */ public TileInventory(String name, int inventorySize, int maxStackSize) { this.inventory = NonNullList.<ItemStack> withSize(inventorySize, ItemStack.EMPTY); this.stackSizeLimit = maxStackSize; this.inventoryTitle = name; this.itemHandler = new InvWrapper(this); }
public void resize(int size) { ItemStackList newInventory = ItemStackList.withSize(size); for (int i = 0; i < size && i < inventory.size(); i++) { newInventory.set(i, inventory.get(i)); } inventory = newInventory; }
/** * Creates a new list with the same content, but Itemstacks are copied too, * meaning changes to the copy will not affect the itemstacks in the original list. * @param fixed If true the list will have fixed size */ public ItemStackList deepCopy(boolean fixed) { ItemStackList copy = fixed ? withSize(this.size()) : create(); for(int i = 0; i < size(); i++) { copy.set(i, get(i).copy()); } return copy; } }
/** * Creates a new list with the same content. ItemStacks are shared between lists! * @param fixed If true the list will have fixed size */ public ItemStackList copy(boolean fixed) { ItemStackList copy = fixed ? withSize(this.size()) : create(); for(int i = 0; i < size(); i++) { copy.set(i, get(i)); } return copy; }