@Override protected ItemStackList getDemoTools(ItemStack[][] inputItems) { if(inputItems.length == 0) { return ItemStackList.create(); } ItemStackList demo = super.getDemoTools(inputItems); ItemStackList out = ItemStackList.create(); for(int i = 0; i < inputItems[0].length; i++) { if(inputItems[0][i].getItem() == TinkerTools.sharpeningKit) { Material material = TinkerTools.sharpeningKit.getMaterial(inputItems[0][i]); IModifier modifier = TinkerRegistry.getModifier("fortify" + material.getIdentifier()); if(modifier != null) { ItemStack stack = demo.get(i % demo.size()).copy(); modifier.apply(stack); out.add(stack); } } } return out; } }
/** * Checks if an Itemstack at a specific index is not empty * * @param index The index to check * @return true if the itemstack at index <i>index</i> is not empty, false otherwise or if the index is out of bounds */ public boolean hasItem(int index) { return index >= 0 && index < size() && !get(index).isEmpty(); }
/** * 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); } }
/** * 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; } }