@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; } }
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; } }
input = ItemStackList.of(stacks);
/** * 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; }
/** * 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(); }
/** * 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; }
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; }
public static ItemStackList create() { return new ItemStackList(); }
/** * 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; } }
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 empty ItemStackList with the given size */ public static ItemStackList withSize(int size) { ItemStack[] aobject = new ItemStack[size]; Arrays.fill(aobject, ItemStack.EMPTY); return new ItemStackList(Arrays.asList(aobject)); }
/** * @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); }
NonNullList<ItemStack> inputItems = ItemStackList.of(Util.deepCopyFixedNonNullList(toolPartsIn)); if(!TinkerEvent.OnToolPartReplacement.fireEvent(inputItems, toolStack)) {