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; } }
/** * Sets the itemstack at the given index to Itemstack.EMPTY. * Does nothing if the index is out of bounds. * * @param index The index to set empty */ public void setEmpty(int index) { if(index >= 0 && index < size()) { set(index, ItemStack.EMPTY); } }
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. 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; }
/** * 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; } }