public ItemStack[] getRemainingItems(InventoryCrafting craftMatrix, World worldIn) { for (IRecipe irecipe : this.recipes) { if (irecipe.matches(craftMatrix, worldIn)) { return irecipe.getRemainingItems(craftMatrix); } } ItemStack[] aitemstack = new ItemStack[craftMatrix.getSizeInventory()]; for (int i = 0; i < aitemstack.length; ++i) { aitemstack[i] = craftMatrix.getStackInSlot(i); } return aitemstack; }
@Override public ItemStack getCraftingResult(InventoryCrafting inv) { ItemStack out = new ItemStack(ModItems.hoe); if (adornmentMat == null) { adornmentMat = ModMaterials.ADORNMENT_NULL; } if (headMat == null || haftMat == null || handleMat == null || adornmentMat == null) { return ItemStack.EMPTY; } NBTTagCompound tag = new NBTTagCompound(); tag.setString(IHeadTool.HEAD_TAG, headMat.getName()); tag.setString(IHaftTool.HAFT_TAG, haftMat.getName()); tag.setString(IHandleTool.HANDLE_TAG, handleMat.getName()); tag.setString(IAdornedTool.ADORNMENT_TAG, adornmentMat.getName()); out.setTagCompound(tag); return out; }
@Test public void test_useUpItem() { DamageableShapelessOreRecipe recipe = new DamageableShapelessOreRecipe(new ResourceLocation("group"), new int[] {60}, new ItemStack(Blocks.DIRT), new ItemStack(Items.WOODEN_SWORD)); InventoryCrafting inv = new InventoryCrafting(new Container() { @Override public boolean canInteractWith(EntityPlayer playerIn) { return false; } }, 3, 3); inv.setInventorySlotContents(3, new ItemStack(Items.WOODEN_SWORD)); assertTrue(recipe.matches(inv, null)); NonNullList<ItemStack> remaining = recipe.getRemainingItems(inv); assertTrue(remaining.get(3).isEmpty()); }
@Override public ItemStack getCraftingResult(InventoryCrafting inv) { ItemStack out = new ItemStack(ModItems.shovel); if (adornmentMat == null) { adornmentMat = ModMaterials.ADORNMENT_NULL; } if (headMat == null || haftMat == null || handleMat == null || adornmentMat == null) { return ItemStack.EMPTY; } NBTTagCompound tag = new NBTTagCompound(); tag.setString(IHeadTool.HEAD_TAG, headMat.getName()); tag.setString(IHaftTool.HAFT_TAG, haftMat.getName()); tag.setString(IHandleTool.HANDLE_TAG, handleMat.getName()); tag.setString(IAdornedTool.ADORNMENT_TAG, adornmentMat.getName()); out.setTagCompound(tag); return out; }
@Override public ItemStack getCraftingResult(InventoryCrafting invCrafting) { ItemStack potion = ItemStack.EMPTY; ItemStack ammo = ItemStack.EMPTY; for (int i = 0; i < invCrafting.getSizeInventory(); i++) { ItemStack stack = invCrafting.getStackInSlot(i); if (!stack.isEmpty()) { if (stack.getItem() == Items.POTIONITEM) { potion = stack; } else { ammo = stack; } } } ammo = ammo.copy(); ItemGunAmmo.setPotion(ammo, potion); return ammo; }
public ItemStack[] getRemainingItems(InventoryCrafting inv) { ItemStack[] aitemstack = new ItemStack[inv.getSizeInventory()]; for (int i = 0; i < aitemstack.length; ++i) { ItemStack itemstack = inv.getStackInSlot(i); if (itemstack != null && itemstack.getItem().hasContainerItem()) { aitemstack[i] = new ItemStack(itemstack.getItem().getContainerItem()); } } return aitemstack; }
@Override public ItemStack getCraftingResult(InventoryCrafting inv) { // TODO Auto-generated method stub ItemStack stack2 = ItemStack.EMPTY; for (int x = 0; x < inv.getSizeInventory(); x++) { ItemStack stack = inv.getStackInSlot(x); if (!stack.isEmpty()) if (!(stack.getItem() == Items.FEATHER)) stack2 = stack; } // System.out.println("OutPut: "+stack2); if (!stack2.isEmpty()) { if(ItemFromData.isSameType(stack2, nameBefore)) stack2=ItemFromData.getNewStack(nameAfter); } return stack2; }
/** * Returns an Item that is the result of this recipe */ public ItemStack getCraftingResult(InventoryCrafting inv) { ItemStack itemstack = null; for (int i = 0; i < inv.getSizeInventory() && itemstack == null; ++i) { ItemStack itemstack1 = inv.getStackInSlot(i); if (itemstack1 != null && itemstack1.getItem() == Items.filled_map) { itemstack = itemstack1; } } itemstack = itemstack.copy(); itemstack.stackSize = 1; if (itemstack.getTagCompound() == null) { itemstack.setTagCompound(new NBTTagCompound()); } itemstack.getTagCompound().setBoolean("map_is_scaling", true); return itemstack; }
/** * Used to check if a recipe matches current crafting inventory */ public boolean matches(InventoryCrafting inv, World worldIn) { for (int i = 0; i <= 3 - this.recipeWidth; ++i) { for (int j = 0; j <= 3 - this.recipeHeight; ++j) { if (this.checkMatch(inv, i, j, true)) { return true; } if (this.checkMatch(inv, i, j, false)) { return true; } } } return false; }
@Override public ItemStack getCraftingResult(InventoryCrafting inv) { ItemStack inputSlaw = inv.getStackInSlot(0); byte additions = 0; if (inputSlaw.hasTagCompound()) { additions = inputSlaw.getTagCompound().getByte("additions"); } additions += 1; ItemStack outputStack = new ItemStack(ModItems.simic_slaw); outputStack.setTagCompound(new NBTTagCompound()); outputStack.getTagCompound().setByte("additions", additions); return outputStack; }
@Override public ItemStack getCraftingResult(InventoryCrafting inventoryCrafting) { ItemStack result = super.getCraftingResult(inventoryCrafting); if (!result.isEmpty()) { ItemStack portalGunItem = ItemStack.EMPTY; for (int i = 0; i < inventoryCrafting.getSizeInventory(); ++i) { ItemStack stack = inventoryCrafting.getStackInSlot(i); if (!stack.isEmpty()) { if (stack.getItem() instanceof PortalGunItem) { portalGunItem = stack; } } } if (!portalGunItem.isEmpty()) { int charge = PortalGunItem.getCharge(portalGunItem); CartridgeItem.setCharge(result, charge); } } return result; }
/** * Returns an Item that is the result of this recipe */ public ItemStack getCraftingResult(InventoryCrafting inv) { ItemStack itemstack = this.getRecipeOutput().copy(); if (this.copyIngredientNBT) { for (int i = 0; i < inv.getSizeInventory(); ++i) { ItemStack itemstack1 = inv.getStackInSlot(i); if (itemstack1 != null && itemstack1.hasTagCompound()) { itemstack.setTagCompound((NBTTagCompound)itemstack1.getTagCompound().copy()); } } } return itemstack; }
public boolean matches(InventoryCrafting invCrafting, InventoryWorkbenchAdditionalMaterials materials, World world) { for (int i = 0; i <= 3 - recipeWidth; ++i) { for (int j = 0; j <= 3 - recipeHeight; ++j) { if (checkMatch(invCrafting, materials, i, j, false)) { return true; } if (mirrored && checkMatch(invCrafting, materials, i, j, true)) { return true; } } } return false; }
@Override public boolean matches(InventoryCrafting inv, World worldIn) { int count = 0; boolean forge = false; for (int i = 0; i < inv.getSizeInventory(); i++) { ItemStack stack = inv.getStackInSlot(i); if(!stack.isEmpty()) { if(stack.getItem() instanceof ItemBlock && ((ItemBlock) stack.getItem()).getBlock() instanceof CraftiniumForge) { if(forge && !this.combining) { return false; } else { forge = true; if(!stack.hasTagCompound() || stack.getSubCompound("randores") == null || !stack.getSubCompound("randores").hasKey("furnace_speed")) { return false; } } } else if (this.upgrades.keySet().stream().noneMatch(k -> k.apply(stack))) { return false; } count++; } } return count >= 2 && forge; }
@Override public ItemStack getCraftingResult(InventoryCrafting inv) { double speed = 0; for (int i = 0; i < inv.getSizeInventory(); i++) { ItemStack stack = inv.getStackInSlot(i); if(stack.getItem() instanceof ItemBlock && ((ItemBlock) stack.getItem()).getBlock() instanceof CraftiniumForge) { speed += stack.getSubCompound("randores").getInteger("furnace_speed"); } else { speed += this.upgrades.entrySet().stream().filter(e -> e.getKey().apply(stack)).map(Entry::getValue).findFirst().orElse(0d); } } int intSpeed = (int) speed; if(intSpeed > this.clamp) { intSpeed = this.clamp; } ItemStack res = new ItemStack(CraftingBlocks.forgeItem); res.getOrCreateSubCompound("randores").setInteger("furnace_speed", intSpeed); return res; }
private ItemStack getAAFromMatrix(InventoryCrafting matrix) { int counter = 0; while (counter < matrix.getSizeInventory()) { if (matrix.getStackInSlot(counter) != null && matrix.getStackInSlot(counter).getItem() instanceof PackedUpAA) { return matrix.getStackInSlot(counter); // Found it } counter += 1; } return null; }
@Override public boolean matches(InventoryCrafting inv, World worldIn) { boolean book = false; boolean material = false; for (int i = 0; i < inv.getSizeInventory(); i++) { ItemStack stack = inv.getStackInSlot(i); if (!stack.isEmpty()) { if (this.book.apply(stack)) { if (book) { return false; } else { book = true; } } else if (stack.getItem() instanceof RandoresMaterial && RandoresItemData.hasData(stack)) { if(material) { return false; } else { material = true; } } else { return false; //Not a book, not a data'd material, not empty } } } return book && material; }
public ItemStack getCraftingResult(InventoryCrafting crafting) { ItemStack itemstack = getRecipeOutput().copy(); if (strangeFlag) { for (int i = 0; i < crafting.getSizeInventory(); ++i) { ItemStack itemstack1 = crafting.getStackInSlot(i); if (itemstack1 != null && itemstack1.hasTagCompound()) { itemstack.setTagCompound((NBTTagCompound)itemstack1.getTagCompound().copy()); } } } return itemstack; }
public ItemStack getCraftingResult(InventoryCrafting inv) { for (int i = 0; i < inv.getSizeInventory(); ++i) { ItemStack itemstack = inv.getStackInSlot(i); if (itemstack != null && TileEntityBanner.getPatterns(itemstack) > 0) { ItemStack itemstack1 = itemstack.copy(); itemstack1.stackSize = 1; return itemstack1; } } return null; }
/** * Returns an Item that is the result of this recipe */ @Nullable public ItemStack getCraftingResult(InventoryCrafting inv) { ItemStack itemstack = this.getRecipeOutput().copy(); if (this.copyIngredientNBT) { for (int i = 0; i < inv.getSizeInventory(); ++i) { ItemStack itemstack1 = inv.getStackInSlot(i); if (itemstack1 != null && itemstack1.hasTagCompound()) { itemstack.setTagCompound(itemstack1.getTagCompound().copy()); } } } return itemstack; }
@Override public boolean matches(InventoryCrafting inv, World worldIn) { int slots = inv.getHeight() * inv.getWidth(); int center = (int) ((float)slots / 2F); ItemStack checked = inv.getStackInSlot(center); if(checked.isEmpty() || !checked.hasTagCompound()) return false; int amount = 0; for(int j = 0; j < slots; j++) { ItemStack stack = inv.getStackInSlot(j); if(!stack.isEmpty() && (!hasTag(stack) || stack.getItem() != checked.getItem())) return false; if(!stack.isEmpty() && j != center) { amount++; } } return amount > 0; }
@Override public ItemStack getCraftingResult(InventoryCrafting matrix) { ItemStack stack = this.result.copy(); ItemStack previousAA = this.getAAFromMatrix(matrix); if (previousAA != null && previousAA.hasTagCompound()) // Copying existing properties { stack.setTagCompound((NBTTagCompound) previousAA.getTagCompound().copy()); } else // ...or just applying new ones { stack.setTagCompound(new NBTTagCompound()); } // Apply the new upgrade now stack.getTagCompound().setBoolean("hasWeaponUpgrade", true); if (stack.getTagCompound().getInteger("currentHealth") == 0) // Just making sure it's not shown with 0 health { if (stack.getTagCompound().getBoolean("hasArmorUpgrade")) { stack.getTagCompound().setInteger("currentHealth", 40); } else { stack.getTagCompound().setInteger("currentHealth", 20); } // Fresh turret, so setting some health } return stack; }
public ItemStack[] getRemainingItems(InventoryCrafting inv) { ItemStack[] aitemstack = new ItemStack[inv.getSizeInventory()]; for (int i = 0; i < aitemstack.length; ++i) { ItemStack itemstack = inv.getStackInSlot(i); if (itemstack != null && itemstack.getItem() instanceof ItemEditableBook) { aitemstack[i] = itemstack; break; } } return aitemstack; }
@Override public ItemStack getCraftingResult(InventoryCrafting inv) { ItemStack out = new ItemStack(ModItems.axe); if (adornmentMat == null) { adornmentMat = ModMaterials.ADORNMENT_NULL; } if (headMat == null || haftMat == null || handleMat == null || adornmentMat == null) { return ItemStack.EMPTY; } NBTTagCompound tag = new NBTTagCompound(); tag.setString(IHeadTool.HEAD_TAG, headMat.getName()); tag.setString(IHaftTool.HAFT_TAG, haftMat.getName()); tag.setString(IHandleTool.HANDLE_TAG, handleMat.getName()); tag.setString(IAdornedTool.ADORNMENT_TAG, adornmentMat.getName()); out.setTagCompound(tag); return out; }
public ItemStack[] getSmeltingResult(InventoryCrafting inv, World world, Tier tier) { return new ItemStack[] { CraftingManager.getInstance().findMatchingRecipe(inv, world) }; /* @SuppressWarnings("unchecked") List<IRecipe> recipeList = CraftingManager.getInstance().getRecipeList(); Iterator<IRecipe> iterator = recipeList.iterator(); while(iterator.hasNext()) { IRecipe recipe = iterator.next(); if(recipe != null && inv != null) { if(recipe.getCraftingResult(inv) != null) FMLLog.log(Level.INFO, "result: " + recipe.getCraftingResult(inv)); else FMLLog.log(Level.INFO, "result: null"); if(recipe.matches(inv, world)) { return new ItemStack[] { recipe.getCraftingResult(inv) }; } } else { FMLLog.log(Level.INFO, "_null"); } } return null; */ }
/** * Used to check if a recipe matches current crafting inventory */ public boolean matches(InventoryCrafting inv, World worldIn) { ItemStack itemstack = null; List<ItemStack> list = Lists.<ItemStack>newArrayList(); for (int i = 0; i < inv.getSizeInventory(); ++i) { ItemStack itemstack1 = inv.getStackInSlot(i); if (itemstack1 != null) { if (itemstack1.getItem() instanceof ItemArmor) { ItemArmor itemarmor = (ItemArmor)itemstack1.getItem(); if (itemarmor.getArmorMaterial() != ItemArmor.ArmorMaterial.LEATHER || itemstack != null) { return false; } itemstack = itemstack1; } else { if (itemstack1.getItem() != Items.DYE) { return false; } list.add(itemstack1); } } } return itemstack != null && !list.isEmpty(); }
/** * Retrieves an ItemStack that has multiple recipes for it. */ @Nullable public ItemStack findMatchingRecipe(InventoryCrafting craftMatrix, World worldIn) { for (IRecipe irecipe : this.recipes) if (irecipe.matches(craftMatrix, worldIn)) return irecipe.getCraftingResult(craftMatrix); return ItemStack.EMPTY; }
@Override public ItemStack getCraftingResult(InventoryCrafting inventory) { ItemStack output = getRecipeOutput(); //As the recipe is 2 high it could be in the 2nd row too. int offsetY = inventory.getStackInRowAndColumn(0, 0).isEmpty() ? 1 : 0; int totalDamage = inventory.getStackInRowAndColumn(0, offsetY).getItemDamage() + inventory.getStackInRowAndColumn(2, offsetY).getItemDamage() + inventory.getStackInRowAndColumn(0, offsetY + 1).getItemDamage() + inventory.getStackInRowAndColumn(2, offsetY + 1).getItemDamage(); ((IPressurizable) output.getItem()).addAir(output, PneumaticValues.PNEUMATIC_HELMET_VOLUME * 10 - totalDamage); return output; }
/** * Used to check if a recipe matches current crafting inventory */ public boolean matches(InventoryCrafting inv, World worldIn) { List<ItemStack> list = Lists.<ItemStack>newArrayList(); for (int i = 0; i < inv.getSizeInventory(); ++i) { ItemStack itemstack = inv.getStackInSlot(i); if (itemstack != null) { list.add(itemstack); if (list.size() > 1) { ItemStack itemstack1 = (ItemStack)list.get(0); if (itemstack.getItem() != itemstack1.getItem() || itemstack1.stackSize != 1 || itemstack.stackSize != 1 || !itemstack1.getItem().isDamageable()) { return false; } } } } return list.size() == 2; }
private boolean isInMatrix(InventoryCrafting matrix, Item item) { if (item == null) { return false; } // Can't find what doesn't exist int counter = 0; ItemStack stack = matrix.getStackInSlot(counter); while (counter < matrix.getSizeInventory()) // scouring through the entire thing { if (stack != null && stack.getItem().getClass() == item.getClass()) // Found one! { if (stack.getItem() instanceof _WeaponBase) // Is a weapon, so need to ensure that it's empty { if (stack.getItemDamage() == stack.getMaxDamage()) { return true; } // else, isn't empty } else if (stack.getItem() instanceof _AmmoBase) // is ammo { this.metadata = stack.getItemDamage(); // Keeping track of what this is gonna make, so I don't have to constantly recheck return true; } // else, don't care what this is } // else, empty. That's fine // Next! counter += 1; stack = matrix.getStackInSlot(counter); } return false; // Fallback. Didn't find what I'm looking for }
@Override public boolean matches(InventoryCrafting inventoryCrafting, World world) { boolean hasDrone = false, hasDye = false; for (int i = 0; i < inventoryCrafting.getSizeInventory(); i++) { ItemStack stack = inventoryCrafting.getStackInSlot(i); if (stack.getItem() == Itemss.DRONE) { if (!hasDrone) hasDrone = true; else return false; } else if (!stack.isEmpty() && TileEntityPlasticMixer.getDyeIndex(stack) >= 0) { if (!hasDye) hasDye = true; else return false; } } return hasDrone && hasDye; }
/** * Copied from ShapedRecipes */ @Override public NonNullList<ItemStack> getRemainingItems(InventoryCrafting inv) { NonNullList<ItemStack> aitemstack = NonNullList.withSize(inv.getSizeInventory(), ItemStack.EMPTY); for (int i = 0; i < aitemstack.size(); ++i) { ItemStack itemstack = inv.getStackInSlot(i); aitemstack.set(i, net.minecraftforge.common.ForgeHooks.getContainerItem(itemstack)); } return aitemstack; }