@Override public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> list) { for(int i = 0; i < 9; i++) list.add(new ItemStack(this, 1, i)); }
/** * Builds an Itemstack of this tool with the given materials, if applicable. * * @param stacks Items to build with. Have to be in the correct order and have exact length. No nulls! * @return The built item or null if invalid input. */ @Nonnull public ItemStack buildItemFromStacks(NonNullList<ItemStack> stacks) { long itemCount = stacks.stream().filter(stack -> !stack.isEmpty()).count(); List<Material> materials = new ArrayList<>(stacks.size()); if(itemCount != requiredComponents.length) { return ItemStack.EMPTY; } // not a valid part arrangement for this tool for(int i = 0; i < itemCount; i++) { if(!validComponent(i, stacks.get(i))) { return ItemStack.EMPTY; } materials.add(TinkerUtil.getMaterialFromStack(stacks.get(i))); } return buildItem(materials); }
@Override public Optional<Match> matches(NonNullList<ItemStack> stacks) { List<ItemStack> matches = Lists.newArrayList(); Optional<Match> match = super.matches(stacks); while(match.isPresent() && matches.size() < 3) { ItemStack stack = match.get().stacks.get(0); matches.add(stack); // remove all meats of the same kind for(int i = 0; i < stacks.size(); i++) { if(stacks.get(i).getItem() == stack.getItem()) { stacks.set(i, ItemStack.EMPTY); } } match = super.matches(stacks); } if(matches.size() >= 3) { return Optional.of(new Match(matches, 1)); } return Optional.empty(); } }
@Override public NonNullList<ItemStack> getRemainingItems(InventoryCrafting inventory) { NonNullList<ItemStack> aitemstack = NonNullList.withSize(inventory.getSizeInventory(), ItemStack.EMPTY); for (int i = 0; i < aitemstack.size(); ++i) { ItemStack itemstack = inventory.getStackInSlot(i); aitemstack.set(i, net.minecraftforge.common.ForgeHooks.getContainerItem(itemstack)); } return aitemstack; }
@Override public ItemStack[] getMatchingStacks() { if (this.items == null) { NonNullList<ItemStack> stacks = NonNullList.withSize(types.size(), ItemStack.EMPTY); for (int i = 0; i < types.size(); i++) { ItemStack stack = IronBackpacksAPI.getStack(types.get(i), specialty); stacks.set(i, stack); } this.items = stacks.toArray(new ItemStack[0]); } return this.items; }
try { toolPart = ToolBuilder.tryBuildToolPart(patternSlot.getStack(), ListUtil.getListFrom(input1.getStack(), input2.getStack()), false); if(toolPart != null && !toolPart.get(0).isEmpty()) { TinkerCraftingEvent.ToolPartCraftingEvent.fireEvent(toolPart.get(0), player); (secondary.isEmpty() || toolPart.get(1).isEmpty() || ItemStack.areItemsEqual(secondary, toolPart.get(1)) && ItemStack.areItemStackTagsEqual(secondary, toolPart.get(1)))) { craftResult.setInventorySlotContents(0, toolPart.get(0));
stacks.set(i, inv.getStackInSlot(i)); if(!stacks.get(i).isEmpty() && stacks.get(i).getItem() instanceof TinkersItem) { tool = stacks.get(i); stacks.set(i, ItemStack.EMPTY); stacks.set(i, inv.getStackInSlot(i)); if(!stacks.get(i).isEmpty() && stacks.get(i).getItem() instanceof TinkersItem) { tool = stacks.get(i); stacks.set(i, ItemStack.EMPTY);
private static ShapelessOreRecipe shapelessFactory( JsonContext context, JsonObject json ) { String group = JsonUtils.getString( json, "group", "" ); NonNullList<Ingredient> ings = NonNullList.create(); for( JsonElement ele : JsonUtils.getJsonArray( json, "ingredients" ) ) { ings.add( CraftingHelper.getIngredient( ele, context ) ); } if( ings.isEmpty() ) { throw new JsonParseException( "No ingredients for shapeless recipe" ); } return new ShapelessOreRecipe( group.isEmpty() ? null : new ResourceLocation( group ), ings, getResult( json, context ) ); } }
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; }
public TileItemGen() { if( POSSIBLE_ITEMS.isEmpty() ) { for( final Object obj : Item.REGISTRY ) { final Item mi = (Item) obj; if( mi != null && mi != Items.AIR ) { if( mi.isDamageable() ) { for( int dmg = 0; dmg < mi.getMaxDamage(); dmg++ ) { POSSIBLE_ITEMS.add( new ItemStack( mi, 1, dmg ) ); } } else { final NonNullList<ItemStack> list = NonNullList.create(); mi.getSubItems( mi.getCreativeTab(), list ); POSSIBLE_ITEMS.addAll( list ); } } } } }
player.inventory.mainInventory.set(player.inventory.currentItem, rest); return true; public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> list) { list.add(new ItemStack(this, 1, TableTypes.CraftingStation.meta)); list.add(new ItemStack(this, 1, TableTypes.PatternChest.meta)); list.add(new ItemStack(this, 1, TableTypes.PartChest.meta)); list.add(new ItemStack(this, 1, TableTypes.ToolStation.meta));
/** * Maps an ore (ore dictionary key) to it's weight on the nether world generation. This * is used for the Orechid Ignem flower. Check the static block in the BotaniaAPI class * to get the weights for the vanilla blocks.<br> * Alternatively get the values with the OreDetector mod:<br> * https://gist.github.com/Vazkii/9493322 */ public static void addOreWeightNether(String ore, int weight) { if(ore.contains("Nether") && OreDictionary.getOres(ore.replace("Nether", "")).size() == 0) return; oreWeightsNether.put(ore, weight); }
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 void updateItemList() { itemNames.clear(); Iterator<Item> iterator = Item.REGISTRY.iterator(); NonNullList<ItemStack> curList = NonNullList.create(); while(iterator.hasNext()) { Item item = iterator.next(); if(item != null && item.getCreativeTab() != null) { curList.clear(); try { item.getSubItems(null, curList); for(ItemStack stack : curList) itemNames.add(CorporeaHelper.stripControlCodes(stack.getDisplayName().trim())); } catch (Exception e) {} } } }