Search in sources :

Example 1 with IItemStack

use of com.blamejared.crafttweaker.api.item.IItemStack in project Mekanism by mekanism.

the class SawmillRecipeManager method addRecipe.

/**
 * Adds a sawing recipe that converts an item into a chance based item output. If the weight is 100%, then it will add it as a main output, if the weight is less than
 * 100% then it adds it as a secondary chance, if the weight is over 100% (must be below 200%) it will add it with a main output and a secondary chance based output.
 * Precision Sawmills and Sawing Factories can process this recipe type.
 *
 * @param name   Name of the new recipe.
 * @param input  {@link ItemStackIngredient} representing the input of the recipe.
 * @param output {@link IItemStack} representing the secondary chance based output of the recipe.
 * @param chance Chance of the secondary output being produced. This must be a number greater than zero and at most one.
 */
@ZenCodeType.Method
public void addRecipe(String name, ItemStackIngredient input, IItemStack output, double chance) {
    if (chance < 1) {
        addRecipe(name, input, ItemStack.EMPTY, getAndValidateNotEmpty(output), getAndValidateSecondaryChance(chance));
    } else if (chance == 1) {
        addRecipe(name, input, getAndValidateNotEmpty(output), ItemStack.EMPTY, 0);
    } else if (chance < 2) {
        ItemStack stack = getAndValidateNotEmpty(output);
        addRecipe(name, input, stack, stack.copy(), getAndValidateSecondaryChance(chance - 1));
    } else {
        // Fail as they should just increase the amount
        throw new IllegalArgumentException("This sawing recipe should just have the amount increased or explicitly use the two output method.");
    }
}
Also used : MCWeightedItemStack(com.blamejared.crafttweaker.impl.item.MCWeightedItemStack) IItemStack(com.blamejared.crafttweaker.api.item.IItemStack) ItemStack(net.minecraft.item.ItemStack)

Aggregations

IItemStack (com.blamejared.crafttweaker.api.item.IItemStack)1 MCWeightedItemStack (com.blamejared.crafttweaker.impl.item.MCWeightedItemStack)1 ItemStack (net.minecraft.item.ItemStack)1