Search in sources :

Example 1 with CentrifugeRecipe

use of techreborn.api.recipe.machines.CentrifugeRecipe in project TechReborn by TechReborn.

the class CTCentrifuge method addRecipe.

@ZenMethod
public static void addRecipe(IItemStack output1, IItemStack output2, IItemStack output3, IItemStack output4, IIngredient input1, IIngredient input2, int ticktime, int euTick) {
    Object oInput1 = CraftTweakerCompat.toObject(input1);
    Object oInput2 = CraftTweakerCompat.toObject(input2);
    CentrifugeRecipe r = new CentrifugeRecipe(oInput1, oInput2, CraftTweakerCompat.toStack(output1), CraftTweakerCompat.toStack(output2), CraftTweakerCompat.toStack(output3), CraftTweakerCompat.toStack(output4), ticktime, euTick);
    addRecipe(r);
}
Also used : CentrifugeRecipe(techreborn.api.recipe.machines.CentrifugeRecipe) ZenMethod(stanhebben.zenscript.annotations.ZenMethod)

Example 2 with CentrifugeRecipe

use of techreborn.api.recipe.machines.CentrifugeRecipe in project TechReborn by TechReborn.

the class IndustrialCentrifugeRecipes method register.

static void register(Object input, int ticks, boolean oreDict, ItemStack... outputs) {
    ItemStack output1;
    ItemStack output2 = null;
    ItemStack output3 = null;
    ItemStack output4 = null;
    if (outputs.length == 3) {
        output1 = outputs[0];
        output2 = outputs[1];
        output3 = outputs[2];
    } else if (outputs.length == 2) {
        output1 = outputs[0];
        output2 = outputs[1];
    } else if (outputs.length == 1) {
        output1 = outputs[0];
    } else if (outputs.length == 4) {
        output1 = outputs[0];
        output2 = outputs[1];
        output3 = outputs[2];
        output4 = outputs[3];
    } else {
        throw new InvalidParameterException("Invalid industrial centrifuge outputs: " + outputs);
    }
    int cellCount = 0;
    for (ItemStack stack : outputs) {
        if (stack.getItem() instanceof DynamicCell) {
            cellCount += stack.getCount();
        }
    }
    if (input instanceof ItemStack) {
        if (((ItemStack) input).getItem() instanceof DynamicCell) {
            int inputCount = ((ItemStack) input).getCount();
            if (cellCount < inputCount) {
                if (output2 == null) {
                    output2 = DynamicCell.getEmptyCell(inputCount - cellCount);
                } else if (output3 == null) {
                    output3 = DynamicCell.getEmptyCell(inputCount - cellCount);
                } else if (output4 == null) {
                    output4 = DynamicCell.getEmptyCell(inputCount - cellCount);
                }
            }
            cellCount -= inputCount;
        }
    }
    if (cellCount < 0) {
        cellCount = 0;
    }
    ItemStack cells = null;
    if (cellCount > 0) {
        if (cellCount > 64) {
            throw new InvalidParameterException("Invalid industrial centrifuge outputs: " + outputs + "(Recipe requires > 64 cells)");
        }
        cells = DynamicCell.getEmptyCell(cellCount);
    }
    RecipeHandler.addRecipe(new CentrifugeRecipe(input, cells, output1, output2, output3, output4, ticks, 5, oreDict));
}
Also used : InvalidParameterException(java.security.InvalidParameterException) DynamicCell(techreborn.items.DynamicCell) ItemStack(net.minecraft.item.ItemStack) CentrifugeRecipe(techreborn.api.recipe.machines.CentrifugeRecipe)

Aggregations

CentrifugeRecipe (techreborn.api.recipe.machines.CentrifugeRecipe)2 InvalidParameterException (java.security.InvalidParameterException)1 ItemStack (net.minecraft.item.ItemStack)1 ZenMethod (stanhebben.zenscript.annotations.ZenMethod)1 DynamicCell (techreborn.items.DynamicCell)1